help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting For Loop to use 7 of my 8 cores


From: RT
Subject: Getting For Loop to use 7 of my 8 cores
Date: Sun, 21 Jun 2015 23:05:29 -0400

I have 8 cores and I'm trying to use 7 of them to compute a For loop
I know parfor is just a for loop command in 3.8.1 Octave and I looked at the examples but they are very sparse.
http://wiki.octave.org/Parallel_package.

What I've tried:
1) I've tried vectorizing the for loop which runs out of memory due to the large arrays. (100000x6)
2) I've tried vectorizing the loop and splitting them into smaller sections and appending the arrays together as not to run out of memory but the for loop ends up being faster.

So I'm trying to see how I can use the Parallel Package and use 7 of my 8 cores to increase speed.
Any ideas how to convert this code into a form that can work with the Parallel Package?

%a_main=rand(60373,6); %example of large array dataset
a_main=rand(8193,6);
t_rebuilt=rand(1,120744);
kk=0;
fo_yo_po=zeros(1,length(t_rebuilt));
fr_yr_pr=zeros(1,length(t_rebuilt));

tic
for kk=1:1:length(a_main(:,1));
       
        fo_yo_po=fo_yo_po+a_main(kk,3)*cos ((a_main(kk,1))*t_rebuilt+(a_main(kk, 5)));
        fr_yr_pr=fr_yr_pr+a_main(kk,4)*cos ((a_main(kk,2))*t_rebuilt+(a_main(kk, 6)));
       
   
end
fprintf('\nDone-elapsed time -%4.4fsec- or -%4.4fmins- or -%4.4fhours-\n',toc,toc/60,toc/3600);

I'm using Octave 3.8.1 on ubuntu 14.04

reply via email to

[Prev in Thread] Current Thread [Next in Thread]