Many thanks for your helpful reply. I understand that with "Vectorized", the output can be a 2d matrix, but I am not quite there yet. I modified your script as:
clear all;
nproc=4;
function N = single_thread (arg)
Array2d=arg*[1,i;-i,1];
N=Array2d(:);
endfunction
b = pararrayfun (nproc, @single_thread, [1:4],'Vectorized',true,'ChunksPerProc',1)
b = pararrayfun (nproc, @single_thread, [1:5],'Vectorized',true,'ChunksPerProc',2)
b = pararrayfun (nproc, @single_thread, [1:5],'Vectorized',true,'ChunksPerProc',1)
the output:
octave:1> test_pararray
parcellfun: 4/4 jobs done
b =
1 + 0i 2 + 0i 3 + 0i 4 + 0i
-0 - 1i -0 - 2i -0 - 3i -0 - 4i
0 + 1i 0 + 2i 0 + 3i 0 + 4i
1 + 0i 2 + 0i 3 + 0i 4 + 0i
parcellfun: 5/5 jobs done
b =
1 + 0i 2 + 0i 3 + 0i 4 + 0i 5 + 0i
-0 - 1i -0 - 2i -0 - 3i -0 - 4i -0 - 5i
0 + 1i 0 + 2i 0 + 3i 0 + 4i 0 + 5i
1 + 0i 2 + 0i 3 + 0i 4 + 0i 5 + 0i
parcellfun: 2/4 jobs done
warning: parcellfun: unhandled error in subprocess 1
warning: called from
parcellfun at line 291 column 9
chunk_parcellfun at line 47 column 23
pararrayfun at line 73 column 26
test_pararray at line 13 column 3
parcellfun: 3/4 jobs done
error: reshape: can't reshape 12x1 array to 1x5 array
error: called from
chunk_parcellfun>@<anonymous> at line 55 column 33
chunk_parcellfun at line 55 column 15
pararrayfun at line 73 column 26
test_pararray at line 13 column 3
The first two calls work fine, but the third does not, leading me to conclude I dont undestand what ChunksPerProc means. For instance if the input vector had 256 values, and nproc=16, the should ChunksPerProc need to be 16? Clearly not, if it was that simple, the program would it compute it by itself.
Sorry to be so dense. The possibilty of breaking large calculations into "chunks" and using multiple processors is such a giant step forward, Perhaps I could contribute in some way?