...
In order to utilise multi-cores within a single compute node, typically, the minimum programming effort would be the revision of the for
loops into parfor
loops in the .m
file. For example, to parallelise the matlab jobs with the majority computation in a for loop read as
Code Block |
---|
% Initialisation A = 512; N = 1024; y = NaN(1,N); % Executing serial `for` loop for i = 1:N y(i) = max(abs(eig(rand(A)))) end % Print results disp(y); disp("Done"); |
simply do
Code Block |
---|
% Initialisation numberOfWorkers =8 48; A = 512; N = 1024; y = NaN(1,N); localCluster% Parallel =pool parclustercreation parpool('local', numberOfWorkers); localCluster.NumWorkers = numberOfWorkers; parpool(localCluster); parfor (i= % Executing parallel `for` loop parfor(i = 1:N, numberOfWorkers) y(i) = max(abs(eig(rand(A)))) end % Print results disp(y); disp("Done"); |
For further explorations of the functionality provided by the Parallel Computing Toolbox
, please refer to Mathworks website [https://au.mathworks.com/help/distcomp/index.html]. If you want to run Matlab jobs across more than one compute nodes and confirm that you get access to the feature Distributed Computing Server
, please contact help@nci.org.au for further instructions.
...
Code Block | ||
---|---|---|
| ||
#!/bin/bash #PBS -q normal #PBS -l walltime=02:00:00 #PBS -l ncpus=48 #PBS -l mem=190GB #PBS -l jobfs=400GB #PBS -l software=matlab_<institution> #PBS -l wd module load matlab/R2019b module load matlab_licence/<institution> # Must include `#PBS -l storage=scratch/ab12+gdata/yz98` if the job # needs access to `/scratch/ab12/` and `/g/data/yz98/`. Details on # https://opus.nci.org.au/display/Help/PBS+Directives+Explained. matlab -nodisplay -nosplash -r "outputDir='$PBS_JOBFS',numberOfWorkers=$PBS_NCPUS, mfile, exitquit" > $PBS_JOBID.log |
Please note, the flag -nodisplay
passed to matlab
enables running without the GUI, while the flag -nosplash
disables the display of the Matlab logo.
...