multiple instances of function call in paralle
Show older comments
hi,currently this is is my code structure
arg4=10;
open a txt file
for arg1=20:10:60 for arg2= 20:10:60 for arg3= 20:10:60 [ans1 ans2]=myfunt([arg1 arg2],[arg3,arg4]); write in txt file end end end close txt file
note: 1. myfunt.m further calls to different files. 2. each myfunt()function call is Independent from each other.
total calls 50*50*50= 125000 times
Q1:Now i do consider code like a distributed job as multiple instances of same function call with different data parameters.is it right?
Q2:how can i run it on local machine with dual2core or quadcore processor in a more faster manner. like i want maximum instances to run parallel.i dont want to use parfor etc because its putting many limitations on my code.
Q3: how can i run this code at some/any server with 16 or more core?
thank you
Answers (1)
Friedrich
on 15 Jul 2011
Hi,
Iam not sure if this will speed up things but I would try the following
%generate all input args
all_args ={};
i = 1;
arg4=10;
for arg1 = 20:10:60
for arg2 = 20:10:60
for arg3= 20:10:60
all_args{i} = [arg1,arg2,arg3,arg4];
i = i +1;
end
end
end
%call cellfun, should work more or less in parallel,
%NOTE: you have to modify the myfunt input structure to 1x4
%array instead of two arrays of size 1x2
[out1,out2] = cellfun(@myfunt,all_args,'UniformOutput',false);
%write the stuff to file
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!