libprima / prima

PRIMA is a package for solving general nonlinear optimization problems without using derivatives. It provides the reference implementation for Powell's derivative-free optimization methods, i.e., COBYLA, UOBYQA, NEWUOA, BOBYQA, and LINCOA. PRIMA means Reference Implementation for Powell's methods with Modernization and Amelioration, P for Powell.
http://libprima.net
BSD 3-Clause "New" or "Revised" License
292 stars 36 forks source link

The MATLAB interface does not pass the recursive test on macOS and Windows #83

Closed zaikunzhang closed 10 months ago

zaikunzhang commented 10 months ago

The MATLAB interface does not pass the recursive test on macOS and Windows, even if the recursion depth is only one:

https://github.com/libprima/prima/blob/main/matlab/tests/recursive.m

The same test succeeds on Linux. See

https://github.com/sprimalib/prima/actions/runs/6247172429

Is this a limitation of MATLAB, OS, or PRIMA?

zaikunzhang commented 10 months ago

Update: The Windows / macOS test does not always fail. This is even stranger.

https://github.com/sprimalib/prima/actions/runs/6247172429

zaikunzhang commented 10 months ago

Fixed by adding -assume recursion (macos) or /assume:recursion (windows) to the flags of ifort. See

https://github.com/libprima/prima/blob/65267f34984d8ccaddc67a5bb477cd05d033281a/matlab/setup_tools/compile.m#L62-L92

https://fortran-lang.discourse.group/t/frecursive-assume-recursion-and-recursion-thread-safety