stack-of-tasks / pinocchio

A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
http://stack-of-tasks.github.io/pinocchio/
BSD 2-Clause "Simplified" License
1.83k stars 383 forks source link

openmp issue on Windows #2440

Open jorisv opened 1 week ago

jorisv commented 1 week ago

When building on Windows, with clang-cl and conda-forge dependencies some tests fails:

Error message is the following:

OMP: Error #15: Initializing libomp140.x86_64.dll, but found libomp.dll already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://openmp.llvm.org/

It's because the default numpy backend is mkl that use intel-openmp on Windows.

When using clang-cl, CMake will take openmp from the clang-cl installation: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/lib/x64/libomp.lib

This is a bad behavior since it hide openmp implementation by taking a non conda library as dependency. In this case, this create a conflict with intel-openmp initialized by the mkl and make the tests fails.

There is two way to solve this issue:

  1. Using intel-openmp
  2. Using blis instead of mkl and use llvm-openmp

Since the ipopt issue should be removed in few weeks we will take option 2 to solve the issue.

In the meantime, we will deactivate parallel build from the Windows CI.