-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathopen_parpool.m
51 lines (39 loc) · 1.12 KB
/
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
44
45
disp(['PPN: ',num2str(no_par_processes)]);
if usejava('desktop')
disp('Local Job')
mycluster = 'local';
mypool = parcluster(mycluster);
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
else
cp=gcp('nocreate');
if ~isempty(cp)
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;
parpool(mypool, no_par_processes);
else
disp('Cluster job with existing pool');
end
end