LINCOA in multiple threads odd results
Hi Zhang, first thank you for the great library. I'm using LINCOA as it's giving me good results compared to other optimization algorithms, but when I start Prima with LINCOA in several different threads (C++ Intel compiler) I notice memory corruption issues. I'm investigating now what exactly is the cause but not proficient with Fortran.
Hi,
Which interface are you using? Could you provide a minimal example?
PRIMA is designed to be and thread-safe. This is tested during CI:
https://github.com/libprima/prima/blob/main/fortran/tests/test_bobyqa.f90#L289-L303
A more extensive test (also included in the CI) is done via the MATLAB interface:
https://github.com/libprima/prima/blob/main/matlab/tests/parallel.m
Of course, bugs may exist.
One thing to check: did you use proper compiler options to enforce thread-safety when building the Fortran library? For gfortran, it is -frecursive, and for Intel oneAPI, it is -assume recursion (Unix) or /assume:recursion (Win).
Thank you.
Hi, Zaikun I found the bug yesterday, sorry for the delayed response and it was in my code, not in yours. I apologize for alarming you for no reason. I create a macro algorithm using your library that starts several optimizers in parallel at even parameter distances and selects the best ones at several points in time. This way I am able to boost the precision of the result by a significant amount (sacrificing computational resources). If you are interested I can contribute the code back to you so you will integrate it in Prima. I named it PPrima, stands for Parallel Prima, and it provides a C plus plus interface to Prima-C. Thanks for understanding, Žarko