[Scilab-users] issue with parallel_run

Stéphane Mottelet stephane.mottelet at utc.fr
Tue Jun 14 10:17:32 CEST 2016


Hello,

1-parallel_run is designed to cope with input-output data organized in 
columns
2-you have to precise the size of the output of yout fct() function.

Here is your corrected script (with comments) :

mode(0);
clear;

function  random_matrix=fct(n)
     M  =  grand(n,12,'unf',-1,1);
     M  =  gsort(M,"lr","d");
     random_matrix  =  M(1,:)';  // transpose the output
     clear  M;
endfunction


num  =  10;
n  =  1000;

// classical calculation

Result  =  zeros(12,num);  // swap the dimensions

tic()

for  i  =  1  :  num
     Result(:,i)  =  fct(n);
end

disp(Result);

time1  =  toc();  printf("time 1 = %g\n",time1);

// using parallel_run

Result2  =  zeros(num,12);
vect_n  =  n*ones(1,num);
tic()
Result2  =  parallel_run(vect_n,  fct,[12,1]);  // precise size of output
disp(Result2);
time2  =  toc();  printf("time 2 = %g\n",time2);



S.


Le 14/06/2016 à 10:06, Carrico, Paul a écrit :
>
> mode(0);
>
> clear;
>
> function*random_matrix*=_fct_(*n*)
>
> M = grand(*n*,12,'unf',-1,1);
>
> M = gsort(M,"lr","d");
>
> *random_matrix* = M(1,:);
>
> clear M;
>
> endfunction
>
> num= 10;
>
> n= 1000;
>
> /// classical calculation/
>
> Result= zeros(num,12);
>
> _tic_()
>
> fori = 1 : num
>
> Result(i,:) = _fct_(n);
>
> end
>
> disp(Result);
>
> time1= _toc_(); printf("time 1 = %g\n",time1);
>
> /// using parallel_run/
>
> Result2= zeros(num,12);
>
> vect_n= n*ones(1,num);
>
> _tic_()
>
> Result2= parallel_run(vect_n, _fct_);
>
> disp(Result2);
>
> time2= _toc_(); rintf("time 2 = %g\n",time2);
>
> *//*
>


-- 
Département de Génie Informatique
EA 4297 Transformations Intégrées de la Matière Renouvelable
Université de Technologie de Compiègne -  CS 60319
60203 Compiègne cedex

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160614/43704f3a/attachment.htm>


More information about the users mailing list