HomerReid / scuff-em

A comprehensive and full-featured computational physics suite for boundary-element analysis of electromagnetic scattering, fluctuation-induced phenomena (Casimir forces and radiative heat transfer), nanophotonics, RF device engineering, electrostatics, and more. Includes a core library with C++ and python APIs as well as many command-line applications.
http://www.homerreid.com/scuff-em
GNU General Public License v2.0
126 stars 50 forks source link

Fix thread safety of the GSL version of GetYlmDerivArray. #137

Closed texnokrates closed 7 years ago

texnokrates commented 7 years ago

Hi,

one can't simply use static variables in multi-threaded code like this. I guess the purpose of the previous version was to avoid allocation on every call, but it simply does not work (scuff-tmatrix will crash on multicore machine) and the performance gain would be insignificant anyway – there are ways to do that correctly, but it is in my opinion not worth it just to save two tiny allocations and one gsl_sf_legendre_array_n per call.

Marek

HomerReid commented 7 years ago

Thanks for taking the time to debug and fix that. Your analysis is correct of course. Not sure what I was thinking---must have been rushing to get something working quickly in a non-multithreaded code and left it in there by mistake.