Dear Heinz,
Here is what can be done in Scilab-5.5.2 to accelerate your computations
on a multi-core architecture under Linux :
function out=distances(X)
function out=distance(k)
this=X(k,:);XX=X;XX(k,:)=[];
DIFF=XX-ONE*this;
out=sqrt(min((DIFF.*DIFF)*[1;1;1]));
endfunction
n=size(X,1);
ONE=ones(n-1,1);
out=parallel_run(1:n,distance);
endfunction
n=40000;
r=23;
radius = r*grand(n,1,'def').^(1/3);
phi = 2*%pi*grand(n,1, 'def');
costheta = 1 - 2*grand(n,1, 'def');
radsintheta = radius.*sin(acos(costheta));
X = [radsintheta.*cos(phi),radsintheta.*sin(phi), radius.*costheta];
On a modest server (two 10-core/20-threads Intel(R) Xeon(R) CPU E5-2660
v2 @ 2.20GHz = 40 threads),
-->tic;distances(X);toc
ans =
13.063
On a smarter server (sixteen 6-core/6-threads Intel(R) Xeon(R) CPU X7542
@ 2.67GHz = 96 threads)
-->tic;d=distances(X);toc
ans =
2.498
I hope that parallel_run will be available again in the next version of
scilab.
S.
Le 31/01/2018 à 10:53, Stéphane Mottelet a écrit :
Replacing
MinDist=[MinDist sqrt(min(sum(DIFF.^2,2)))];
by
MinDist=[MinDist sqrt(min(sum(DIFF.*DIFF,2)))];
will be at least twice faster. Crunching elapsed time could be done by
using parallel_run (with 5.5.2 version) if you have a multi-core
processor.
S.
Le 31/01/2018 à 09:36, Dang Ngoc Chan, Christophe a écrit :
Hello,
The following suggestions will probably not have a drastic influence
(I don't see how it could be more vectorised)
but his a little thing I see:
De : users [mailto:[email protected]] De la part de
Heinz Nabielek
Envoyé : mercredi 31 janvier 2018 00:13
MinDist=[MinDist sqrt(min(sum(DIFF.^2,2)))];
Maybe you could concatenate the squares of the distance
and then compute the square root of the whole vector in the end:
sqMinDist=[sqMinDist min(sum(DIFF.^2,2))];
…
end
…
MinDist = sqrt(sqMinDist)
Hope this helps,
Regards
--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail
in error), please notify the sender immediately and destroy this
e-mail. Any unauthorized copying, disclosure or distribution of the
material in this e-mail is strictly forbidden.
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users
--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users