Unable to view saved mpiprofile stats from compute cluster on local machine

조회 수: 3(최근 30일)
Hi, I am trying to use the Matlab Profiler to analyze my code. I used the "normal" Profiler via
profile on
% Code to be analyzed
profile off
stats = profile("info");
% And then later to view
I then identified runtime hotspots using the report and optimized the code by parallelizing using a spmd block. Now I want to analyze the code again. The normal Profiler fails on parallel code so I used
mpiprofile on
% Code to be analyzed
mpiprofile off
stats = mpiprofile("info");
% And then later to view
So far, so good. I have access to a large computation cluster and ran everything on there using
c = parcluster;
job = c.batch(@myFcn, 3, {}, 'AutoAddClientPath', false, 'CurrentFolder', '.');
The computation works perfectly. The third output is the stats-struct saved from the mpiprofile. On manual inspection, the struct seems to be correct, as there are 47 fields for each of the used workers, each with a function history etc.
The problem now is, when I type
to view the report in HTML form, nothing is displayed. The mpiprofiler opens showing the interface of the parallel profiler but acts as if I started it to start profiling new code, displaying
MATLAB has started profiling. Run the code or app that you want to profile in MATLAB. Then, click Stop Profiling to display the results.
Does anyone know how to resolve this? I am sure there is a simple solution to this :D
Thanks in advance

채택된 답변

LukasG 2022년 8월 19일
I figured out some workaround. I noticed, that in the returned struct the functions and files were obviously given with directories on the computation cluster. I then just iterated over the struct replacing all paths with the corresponding paths, i.e. as if the program were to be run on my local machine. And indeed, that just did the trick. I can now view the report on my local machine.
For curiosity: That probably is not the "official" way to do it. Is there something I missed?
For completeness, here is the code for the path replacement:
function NewReport = replacePathsInProfileReport(Report)
LOCAL_CODE_AT = '\\Local\path\\to\\my\\own\\code\\';
LOCAL_TOOLBOX_AT = 'C:\\Program Files\\MATLAB\\R2021b\\toolbox\\';
CLUSTER_CODE_AT = '/cluster/path/to/the/transferred/temporary/files/';
CLUSTER_TOOLBOX_AT = '/cluster/path/to/the/matlab/toolbox/';
NewReport = Report;
for worker=1:size(NewReport,1)
for fcn=1:size(NewReport(worker).FunctionTable,1)
NewReport(worker).FunctionTable(fcn).CompleteName = regexprep(NewReport(worker).FunctionTable(fcn).CompleteName,CLUSTER_TOOLBOX_AT,LOCAL_TOOLBOX_AT);
NewReport(worker).FunctionTable(fcn).CompleteName = regexprep(NewReport(worker).FunctionTable(fcn).CompleteName,CLUSTER_CODE_AT,LOCAL_CODE_AT);
NewReport(worker).FunctionTable(fcn).CompleteName = regexprep(NewReport(worker).FunctionTable(fcn).CompleteName,'/','\\');
NewReport(worker).FunctionTable(fcn).FileName = regexprep(NewReport(worker).FunctionTable(fcn).FileName,CLUSTER_TOOLBOX_AT,LOCAL_TOOLBOX_AT);
NewReport(worker).FunctionTable(fcn).FileName = regexprep(NewReport(worker).FunctionTable(fcn).FileName,CLUSTER_CODE_AT,LOCAL_CODE_AT);
NewReport(worker).FunctionTable(fcn).FileName = regexprep(NewReport(worker).FunctionTable(fcn).FileName,'/','\\');

추가 답변(0개)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by