grokkingstuff Home Blog Projects Wiki Calculators About

Matlab

https://raw.githubusercontent.com/hpjeonGIT/training_slides/master/Using_matlab.md

https://hplgit.github.io/prog4comp/doc/pub/p4c-sphinx-Matlab/index.html

Adjusting the number of threads in MATLAB

parpool(npool)
a = zeros(nloop);
parfor i = 1:nloop
    workersCompThreads(i) = feature('numThreads',nthreads);
    a(i) = max(abs(eig(rand(nsize))));
end
sum(a)
poolobj = gcp('nocreate');
delete(poolobj);
parpool(npool)
a = zeros(nloop);
parfor i = 1:nloop
    maxNumCompThreads(nthreads);
    workersCompThreads(i) = maxNumCompThreads;
    a(i) = max(abs(eig(rand(nsize))));
end
poolobj = gcp('nocreate');
delete(poolobj);

Checking License status of MATLAB

Windows

Linux

/opt/apps/matlab/R2014a/etc/glnxa64/lmutil lmstat -a -c 27000@license_server

Debugging MATLAB in Linux CLI

-Install Windows SDK

Introduction to MATLAB standalone applications

What is a stand-alone application?

Sample tutorial to produce a stand-alone application

#parpool
10
#Loop
100
#numThreads
4
#matrix size
1000
tic
fid = fopen('./input.txt');
line = fgetl(fid);line = fgetl(fid);npool = str2num(line)
line = fgetl(fid);line = fgetl(fid);nloop = str2num(line)
line = fgetl(fid);line = fgetl(fid);nthreads = str2num(line)
line = fgetl(fid);line = fgetl(fid);nsize = str2num(line)
fclose(fid);
%feature('numThreads',nthreads)
parpool(npool)
a = zeros(nloop);
parfor i = 1:nloop
    workersCompThreads(i) = feature('numThreads',nthreads);
    a(i) = max(abs(eig(rand(nsize))));
end
sum(a)
poolobj = gcp('nocreate');
delete(poolobj);
toc

Running MATLAB stand alone applications

#!/bin/bash
#PBS -q @myserver
#PBS -l select=1:ncpus=20:mpiprocs=20
#PBS -l walltime=100:00:00
echo $PBS_O_WORKDIR
cd $PBS_O_WORKDIR
export TMPDIR=/scratch/$USER/tmp
export SCRATCH=$TMPDIR/$PBS_JOBID
mkdir -p $SCRATCH
export  MCR_CACHE_ROOT=$SCRATCH
export V95LIB=/usr/local/matlab/MATLAB_Runtime/v95
export EXE=/home/foo/some_app/for_redistribution_files_only/run_my_app.sh
$EXE $V95LIB