function matlab_example % Anzahl der paralellen MATLAB-Worker definieren % (am LRZ-LX-Cluster momentan <= 8) global poolsize poolsize = getenv('MATLAB_POOL_SIZE') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% serial part %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% a=4+4; b=2^a; save('matlab_example.out','a','b','-ascii','-double'); save %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% parallel part, if MATLAB_POOL_SIZE %% environment variable is defined %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if ~isempty(poolsize) matlabpool('local', poolsize) end matlabpool size % distributed data x=rand(10000); xd=distributed(x); tic; gather(xd*xd); toc % single program multiple data tic; spmd, sum(sum(rand(10))); end toc % parallel for tic; parfor i=1:100 a=sum(sum(rand(10000))); end toc if ~isempty(poolsize) matlabpool close end exit; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%