TRIQS / nda

C++ library for multi-dimensional arrays
https://triqs.github.io/nda
Other
13 stars 11 forks source link

Fix Intel vs GNU ABI when building against MKL #69

Closed hmenke closed 2 months ago

hmenke commented 3 months ago

For functions that return complex values, there are two strategies how values can be returned. Either via a value on the stack (aka return value) or via an implicit first argument (aka output argument). The former is called GNU ABI and the latter Intel ABI by the Intel MKL. There are two variants of the Intel MKL and when calling functions like zdotu that return a complex value it does make a difference which one the application is linked to.

Unfortunately, there is no way to detect this at runtime and other libraries that are linked into the application might have other preferences with regards to which MKL interface they want to use. With this commit we make the code ABI agnostic by simply using the CBLAS API which always uses an output argument.

https://www.intel.com/content/www/us/en/docs/onemkl/developer-guide-linux/2024-1/call-blas-funcs-return-complex-values-in-c-code.html

Fixes https://github.com/TRIQS/nda/issues/67

hmenke commented 3 months ago

Backport to 1.3.x is also necessary.

Thoemi09 commented 3 months ago

I can reproduce the problem and the fix is working for me as well.