Skip to content

Commit

Permalink
fix parallel execution of c code
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasneubrand committed Sep 18, 2024
1 parent 6c62144 commit a34e4a0
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions arFramework3/Advanced/arSetParallelThreads.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,32 @@ function arSetParallelThreads(n, silent)
n = ar.config.nMaxThreads;
end

if ~silent
fprintf(1, 'requesting %i thread(s) for %i task(s) on %i core(s).\n', ...
n, ar.config.nTasks, ar.config.nCore);
end

if n > ar.config.nMaxThreads
if ar.config.useParallel == 0
if ~silent
fprintf(1, 'request exceeds thread limit, reset requested threads to %i.\n', ...
ar.config.nMaxThreads);
fprintf(1, 'parallel computing is disabled, reset requested threads to 1.\n');
fprintf(1, 'enable parallel computing with "ar.config.useParallel=1".\n');
end
n = ar.config.nMaxThreads;
end
n = 1;

if n > ar.config.nTasks
if~silent
fprintf(1, 'request exceeds number of tasks, reset requested threads to %i.\n', ...
ar.config.nTasks);
else
if ~silent
fprintf(1, 'requesting %i thread(s) for %i task(s) on %i core(s).\n', ...
n, ar.config.nTasks, ar.config.nCore);
end
if n > ar.config.nMaxThreads
if ~silent
fprintf(1, 'request exceeds thread limit, reset requested threads to %i.\n', ...
ar.config.nMaxThreads);
end
n = ar.config.nMaxThreads;
end
if n > ar.config.nTasks
if~silent
fprintf(1, 'request exceeds number of tasks, reset requested threads to %i.\n', ...
ar.config.nTasks);
end
n = ar.config.nTasks;
end
n = ar.config.nTasks;
end

ar.config.nParallel = n;
Expand Down

0 comments on commit a34e4a0

Please sign in to comment.