Code covered by the BSD License  

Highlights from
Pass task-parallel jobs with multiple tasks to a scheduler.

Pass task-parallel jobs with multiple tasks to a scheduler.

by

 

This script creates 2 jobs, each with 2 parallel tasks, to pass to a local or remote scheduler.

myrand(n)
function rMatrix = myrand(n)
% Essentially a wrapper function for MATLAB's built-in rand.
% The function creates a random number stream and returns a random matrix 
% of size n x n. 
% NB: n must be a scalar input and 'myrand' uses functions 
% from the Parallel Computing Toolbox.
%
% examples of usage:
% myrand(3);
% a = myrand(3);

ctask = getCurrentTask;
cjob = getCurrentJob;
taskid = get(ctask,'ID');
jobid = get(cjob,'ID');
idprod = taskid * jobid;
clockvector = clock; 
secs = clockvector(6); 
%Create only one random number stream using the 'combined
%multiple recursive generator'
mrg = RandStream.create('mrg32k3a','NumStreams',1,'Seed',secs*idprod);
rMatrix = rand(mrg,n);
end

Contact us