MATLAB Answers

parfeval diaries sometimes missing

3 views (last 30 days)
Ben Wetherill
Ben Wetherill on 2 Feb 2018
Edited: Ben Wetherill on 2 Feb 2018
I have a script that runs parfeval on a bunch tasks. The code is below. The code has two outputs:
  1. Results in an Excel file (one row per task)
  2. A log file which gets appended with the diary from each worker.
Once all tasks have been completed, I have a complete set of results in the Excel file, but I'm missing some logs. The attached file is the list of tests reported in the log. There should be 59 rows, but there are only 50. Any idea why some diaries aren't being written to the file? My understanding is that it shouldn't be a file access issue because the second for loop is not executed in parallel. So the log file is opened, appended and closed as each worker finishes a task. Could it be a flushing issue?
Edit: I should add that if I run the job in single tasking mode everything is fine. All logs are present.
Code:
for i = casesToRun
f(i) = parfeval(p, @doStuff, 2, i, j, test_cases, HitsToAutoTRFile, FailureType, Standard, ModelAssembley);
end
for i = casesToRun
[completedIdx, status, xlRow] = fetchNext(f);
writeWorkerLog(f(i).Diary, logFileName);
xlswrite(TestCasesFile,status,'Sheet1',xlRow);
end
function writeWorkerLog(logData, fName)
% create the file if it doesn't exist, then close it
fid=fopen(fName, 'a+');
fprintf(fid, logData);
fclose(fid);

  0 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!