Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LINCOA in multiple threads odd results #206

Open
asenzz opened this issue May 17, 2024 · 2 comments
Open

LINCOA in multiple threads odd results #206

asenzz opened this issue May 17, 2024 · 2 comments

Comments

@asenzz
Copy link

asenzz commented May 17, 2024

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.

@zaikunzhang
Copy link
Member

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.

@asenzz
Copy link
Author

asenzz commented Jun 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants