% Example of using MATLAB with shared memory % https://www.mathworks.com/help/parallel-computing/examples/scale-up-from-desktop-to-cluster.html;jsessionid=4eccb67d206a27bdd06a25973764#distcomp-ex17015848 % Taken from MATLAB webpage and made into a function in order to specify the processor number % from the bsub script rather than hardcoding into the MATLAB script function [ierr] = int_fun(numprocs) % Don't use a semi-colon to see more details from parpool parpool(numprocs) primeNumbers = primes(uint64(2^21)); compositeNumbers = primeNumbers.*primeNumbers(randperm(numel(primeNumbers))); factors = zeros(numel(primeNumbers),2); tic; parfor idx = 1:numel(compositeNumbers) factors(idx,:) = factor(compositeNumbers(idx)); end toc ierr = 0;