Skip to content
Snippets Groups Projects
Commit 73b112e8 authored by Wolfgang Ludwig's avatar Wolfgang Ludwig
Browse files

- enable the use of 'list' as varargin for gtReconstructGrains (overwrites grain.rec.list)

- added the use of lists as varargin in OAR_make  (enable with oar.distribute= true)
- use these two in gtSetupReconstruction  in order to distribute the grains

Signed-off-by: default avatarWolfgang Ludwig <wolfgang.ludwig@esrf.fr>
parent 66229666
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,8 @@ function gtReconstructGrains(first, last, workingdirectory, phaseID, parameters,
parameters.rec.grains = rec_gr;
end
samplefile = fullfile(parameters.acq.dir, '4_grains', 'sample.mat');
sample = GtSample.loadFromFile(samplefile);
......@@ -62,7 +64,11 @@ function gtReconstructGrains(first, last, workingdirectory, phaseID, parameters,
num_grains = sample.phases{phaseID}.getNumberOfGrains();
if ~isempty(rec_gr.list)
grains_list = rec_gr.list;
if isnumeric(rec_gr.list)
grains_list = rec_gr.list;
else
grains_list = str2num(rec_gr.list);
end
else
grains_list = first:last;
end
......@@ -70,7 +76,8 @@ function gtReconstructGrains(first, last, workingdirectory, phaseID, parameters,
% Filtering out deselected/deactivated/bad grains
active_grains = sample.phases{phaseID}.getSelected(grains_list);
grains_list = grains_list(active_grains);
t = GtThreshold();
fprintf('Reconstructing grains: ');
c = tic();
for ii = 1 : numel(grains_list)
......@@ -93,14 +100,10 @@ function gtReconstructGrains(first, last, workingdirectory, phaseID, parameters,
gtReconstructGrainOrientation(gr_id, phaseID, parameters);
end
end
t.singleGrainAutoThreshold(phaseID, gr_id);
fprintf(repmat('\b', [1 num_chars]))
end
fprintf('Done (in %f seconds).\n', toc(c))
if (isdeployed)
t = GtThreshold();
t.batchThreshold(phaseID, first, last);
end
cd(currentDir);
end
......@@ -142,8 +142,8 @@ if strcmpi(check, 'y')
end
if (rec_on_OAR)
launch_on_OAR('gtReconstructGrains', first, last, phaseID_str, ...
parameters, 'mem', 32 * 1024, 'njobs', 8, ...
'walltime', 3600 * 16, 'gpu', true);
parameters, 'core', 8, 'njobs', 8, ...
'walltime', 3600 * 16, 'gpu', true, 'distribute', true);
else
gtReconstructGrains(first, last, parameters.acq.dir, phaseID, parameters);
end
......@@ -173,11 +173,12 @@ end
function launch_on_OAR(func_name, first, last, phaseID_str, parameters, varargin)
disp('Launching several separate OAR jobs');
oar.njobs = max(ceil(last/30), 30); % max 30 jobs
oar.walltime = last / oar.njobs * 300; % allow up to 300 seconds per grain
oar.mem = 2048; % Mb
oar.gpu = false;
oar.njobs = max(ceil(last/30), 30); % max 30 jobs
oar.walltime = last / oar.njobs * 300; % allow up to 300 seconds per grain
oar.mem = 2048; % Mb
oar.gpu = true;
oar.core = 8;
oar.distribute = true;
oar = parse_pv_pairs(oar, varargin);
% oar parameters are defined in build_list_v2
......@@ -196,8 +197,9 @@ function launch_on_OAR(func_name, first, last, phaseID_str, parameters, varargin
pause(0.5);
OAR_make(func_name, first, last, OAR_parameters.njobs, ...
[parameters.acq.dir ' ' phaseID_str], true, ...
[parameters.acq.dir ' ' phaseID_str ' '''''], true, ...
'walltime', OAR_parameters.walltime, 'mem', OAR_parameters.mem, ...
'gpu', OAR_parameters.gpu);
'core', OAR_parameters.core, 'gpu', OAR_parameters.gpu, ...,
'distribute', true);
end
......@@ -92,6 +92,7 @@ oarpars.checkpoint = 600;
oarpars.signal = 2;
oarpars.type = 'idempotent'; % You can also chose 'besteffort'
oarpars.resubmit = 0;
oarpars.distribute = false;
oarpars = parse_pv_pairs(oarpars, varargin);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -218,6 +219,11 @@ set.oarparameters = strrep(set.oardirectives, '.oar', '.params');
fid = fopen(set.oarparameters, 'w');
jobsize = ceil((last-first+1)/njobs);
% construct lists of grainids (will only be used when oar.distribute=true)
for i = 1 : njobs
jobs{i} = [(first + i -1) : njobs : last];
end
range_firsts = first:jobsize:last;
range_lasts = range_firsts(2:end)-1;
range_lasts(end+1) = last;
......@@ -240,10 +246,17 @@ if strcmpi(func_path, m_func_path)
end
fprintf(fid, '# %s', help_str);
fprintf(fid, '# \n');
for n = 1:length(range_firsts)
fprintf(fid, '%s %d %d %s\n', executable, range_firsts(n), ...
range_lasts(n), otherparameters);
if oarpars.distribute
for n = 1:njobs
fprintf(fid, '%s %d %d %s list ''%s''\n', executable, range_firsts(n), ...
range_lasts(n), otherparameters, num2str([jobs{n}]));
end
else
for n = 1:length(range_firsts)
fprintf(fid, '%s %d %d %s\n', executable, range_firsts(n), ...
range_lasts(n), otherparameters);
end
end
else
fid_tmp = fopen(func_path, 'r');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment