MPI measurements
This commit is contained in:
54
projects/ECOC_2025/submit_dsp.m
Normal file
54
projects/ECOC_2025/submit_dsp.m
Normal file
@@ -0,0 +1,54 @@
|
||||
function [output, future] = submit_dsp(run_id, basePath, database_name, savePath, options)
|
||||
% runDSPInBackground Runs or submits DSP processing based on 'parallel' flag.
|
||||
%
|
||||
% [output, future] = runDSPInBackground(..., options)
|
||||
% - output: result from dsp_run_id (only immediately available in serial mode)
|
||||
% - future: FevalFuture object if run in parallel, otherwise []
|
||||
|
||||
arguments
|
||||
run_id
|
||||
basePath
|
||||
database_name
|
||||
savePath
|
||||
options.parallel (1,1) logical = true
|
||||
options.max_occurences = 1;
|
||||
end
|
||||
|
||||
if options.parallel
|
||||
% Check if a pool exists
|
||||
pool = gcp('nocreate');
|
||||
if isempty(pool)
|
||||
parpool;
|
||||
end
|
||||
|
||||
% Submit the DSP function asynchronously
|
||||
future = parfeval( ...
|
||||
@dsp_run_id, 1, ... % One output
|
||||
run_id, ...
|
||||
"database_path", basePath, ...
|
||||
"database_name", database_name, ...
|
||||
'storage_path', savePath, ...
|
||||
'append_to_db', 1, ...
|
||||
'max_occurences', options.max_occurences ...
|
||||
);
|
||||
|
||||
output = [];
|
||||
fprintf('DSP task for run_id %d submitted to the pool.\n', run_id);
|
||||
|
||||
|
||||
else
|
||||
% Run synchronously (debug mode), capture output
|
||||
fprintf('Running DSP task for run_id %d in main thread (debug mode).\n', run_id);
|
||||
|
||||
output = dsp_run_id( ...
|
||||
run_id, ...
|
||||
"database_path", basePath, ...
|
||||
"database_name", database_name, ...
|
||||
'storage_path', savePath, ...
|
||||
'append_to_db', 1, ...
|
||||
'max_occurences', options.max_occurences ...
|
||||
);
|
||||
|
||||
future = []; % No future since it's synchronous
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user