createTask example code seems to sit idle

1 view (last 30 days)
Greg
Greg on 15 Jun 2012
Using MATLAB version 7.14.0.739 (R2012a) and the Parallel Computing Toolkit ver 6.0, I've been unable to run the createTask example code to completion. The code is copied from
with the addition of the first line to open matlabpool, as needed:
if ~matlabpool('size'),matlabpool('open','local');end
% Create a job object.
c = parcluster(); % Use default profile
j = createJob(c);
% Add a task object which generates a 10-by-10 random matrix.
t = createTask(j, @rand, 1, {10,10});
% Run the job.
submit(j);
% Wait for the job to finish running, and get the output from the task evaluation.
wait(j);
taskoutput = get(t, 'OutputArguments');
% Show the 10-by-10 random matrix.
disp(taskoutput{1});
When I run it, the only output is
Starting matlabpool using the 'local' profile ... connected to 4 labs.
The MATLAB windows continue to respond to user input, but the script never finishes nor displays output. The Windows Task Manager shows 5 MATLAB processes running, but only the first one gets CPU time (and only in response to user input) -- the other four get no CPU time.
Any help most appreciated.
Regards.
Greg

Answers (1)

Greg
Greg on 25 Jun 2012
Just for the record: Removing the one line that I had added
if ~matlabpool('size'),matlabpool('open','local');end
seemed to resolve the problem.
I don't understand how initializing the matlab pool might interfere with subsequently creating jobs & tasks and submitting jobs, but that seemed to make the difference all the same.
Greg

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!