forked from timlandvoigt/FinRegModernBanking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
open_parpool.m
43 lines (36 loc) · 960 Bytes
/
open_parpool.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
if ~exist('no_par_processes','var')
no_par_processes=2;
end
if usejava('desktop')
disp('Local Job')
mycluster = 'local';
mypool = parcluster(mycluster);
else
if contains(getenv('QUEUE'), 'aws-')
disp('AWS Job')
mycluster = 'local';
myfolderbase = strcat(getenv('TMP'), '/');
else
disp('HPCC Job')
mycluster = 'WhartonHPC';
myfolderbase = '~/matlabtmp/';
end
mypool = parcluster(mycluster);
tmpFolder = strcat(myfolderbase, getenv('JOB_ID'), '-', getenv('SGE_TASK_ID'));
mkdir(tmpFolder);
mypool.JobStorageLocation = tmpFolder;
end
disp(['PPN: ',num2str(no_par_processes)]);
cp=gcp('nocreate');
if ~isempty(cp)
if cp.NumWorkers~=no_par_processes
delete(cp);
if no_par_processes>0
parpool(mypool, no_par_processes);
end
end
else
if no_par_processes>0
parpool(mypool, no_par_processes);
end
end