SyneRBI / SIRF

Main repository for the CCP SynerBI software
http://www.ccpsynerbi.ac.uk
Other
58 stars 29 forks source link

MATLAB crashes on osem_reconstruction.m with OpenMP on Windows #687

Open evgueni-ovtchinnikov opened 4 years ago

evgueni-ovtchinnikov commented 4 years ago

MATLAB crashes on osem_reconstruction.m.

I managed to trace the source of trouble to the call this->compute_sensitivities(); in PoissonLogLikelihoodWithLinearModelForMean<TargetT>::set_up (line 318 in PoissonLogLikelihoodWithLinearModelForMean.cxx).

Apparent reason is a conflict between multithreading in STIR and MATLAB - if STIR is built without OpenMP, the script runs ok.

Python script osem_reconstruction.py runs ok regardless (Python does not use multithreading).

KrisThielemans commented 4 years ago

duplicate with previous issue I believe.

I really can't understand this. Unless you use parfor etc in Matlab, I can't see how Matlab's multi-threading would come into play. I can see conflicts on openmp DLLs of course...

KrisThielemans commented 4 years ago

assuming this is on Windows?

evgueni-ovtchinnikov commented 4 years ago

yes

rijobro commented 4 years ago

I can see conflicts on openmp DLLs of course...

My guess is that this is the source of the problems. Would potentially be fixed by building STIR using OpenMP DLLs to those provided by Matlab.

evgueni-ovtchinnikov commented 4 years ago

should I remove osem_reconstruction.m for now and tag?

KrisThielemans commented 4 years ago

Would potentially be fixed by building STIR using OpenMP DLLs to those provided by Matlab.

probably can't be done, as no .h and .lib files available I guess. I'm not sure how this works on Windows with Visual Studio by the way (there isn't an equivalent of libgomp or so). There isn't anything relevant in C:\Program Files\MATLAB\R2019a\bin\win64 for instance

rijobro commented 4 years ago

@evgueni-ovtchinnikov no need to remove as it's not a problem with SIRF, but with your particular set up.

KrisThielemans commented 4 years ago

should I remove osem_reconstruction.m for now and tag?

this is a Windows-only problem as far as we know. We don't officially support it, let's not remove functionality therefore. In any case, removing a demo will not solve the problem.

AnderBiguri commented 4 years ago

Not sure how much this helps, but there is some Staff Q&A about this on the Mathworks site, explaining that indeed there can be issues regarding libraries, as you are discussing in this thread.

https://uk.mathworks.com/matlabcentral/answers/237411-can-i-make-use-of-openmp-in-my-matlab-mex-files

KrisThielemans commented 4 years ago

yup. that looks like a good find. In particular,

we recommend you also use Intel's OpenMP implementation in your MEX-files

fun!

evgueni-ovtchinnikov commented 3 years ago

same with hkem_reconstruction.m

acquisition_sensitivity_from_ecat8.m crashes too, albeit on a different step (on AcquisitionSensitivityModel.forward, the other two on reconstructor set_up).

@KrisThielemans I take it I should ignore this and press on with 3.0.0-rc1 checklist?