help-octave
[Top][All Lists]
Advanced

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

Re: Getting For Loop to use 7 of my 8 cores


From: Olaf Till
Subject: Re: Getting For Loop to use 7 of my 8 cores
Date: Mon, 22 Jun 2015 08:29:42 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun, Jun 21, 2015 at 11:05:29PM -0400, RT wrote:
> 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?

I'm afraid there is no way at the moment. 'parcellfun' or
'pararrayfun' would compute each term and you would have to sum them
up afterwards. This causes the same memory problem as vectorization.

Such a problem came up on this list before, I believe. Maybe we should
enhance 'parcellfun' to optionally perform some accumulating operation
on the results, like adding, instead of returning them all.

Olaf

> %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

> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave


-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

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