Hello everyone,
I encountered a problem with the Matlab Parallel Computing functionalities, for which I could not find a solution in the Forum or Documentation.
I have a function, say "my_parallel_function" within which I use an spmd block to execute code in parallel. In the real case I also make use of the labSend/labReceive functionalities.
function [ ] = my_parallel_function( N_R, parameter )
spmd(N_R)
disp( [ 'Hello from lab ' num2str(labindex) ': P=' num2str(parameter) ] );
end
end
Now I want to execute this function in parallel, for different values of "parameter". My first attempt was to create a job object with independent tasks and let each task evaluate the function:
N_T = 2;
N_R = 3;
c = parcluster;
j = createJob( c, 'Name', 'my_job');
parameter = 1;
t1 = createTask( j, @my_parallel_function, 0, { N_R, parameter }, 'CaptureDiary', true );
parameter = 2;
t2 = createTask( j, @my_parallel_function, 0, { N_R, parameter }, 'CaptureDiary', true );
submit(j);
However, this fails with the follwing error: "Could not create an SPMD block to match the requested size: 3. The parallel pool size is: 0."
So, I figured out the problem is that within a task (which is apparently always associated with 1 worker) a parallel pool cannot be created.
I also tried to work with "batch" but the same problem occurs.
Is there a way to associate multiple workers with the execution of a task which itself uses spmd?
As far as I understand, nesting of spmd and/or parfor is also not possible.
Any help is very much appreciated.
Thanks, Jan