oneapi-src / oneDPL

oneAPI DPC++ Library (oneDPL) https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/dpc-library.html
Apache License 2.0
714 stars 110 forks source link

libc++-14 incompatibility #1602

Open dbs4261 opened 1 month ago

dbs4261 commented 1 month ago

Hi folks, looks like there is an issue with using gcc-14. When compiling Open3d using oneApi with gcc-14, I am getting a build error. I've traced it to oneapi/dpl/pstl/algorithm_impl.h. It seems to be an issue with the macro #if (_PSTL_UDR_PRESENT || _ONEDPL_UDR_PRESENT) (actual error: error: operator '||' has no left operand). Now, I'm reporting the bug here because _PSTL_UDR_PRESENT is defined in pstl_config.h but that is never included. My IDE is telling me that the definition is coming instead from pstl_config.h libc++-14 shown below:

#if (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1900) || \
    (!defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900) || \
    (defined(_OPENMP) && _OPENMP >= 201307)
#    define _PSTL_UDR_PRESENT
#endif

#if (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626) || \
    (!defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 100000)
#   define _PSTL_UDS_PRESENT
#endif

Now, in all versions of the file included in my oneApi installation have a value after _PSTL_UDR_PRESENT. This is also the case with libc++-13. So the fix might need to be made on that end.

jwakely commented 1 month ago

libc++ is part of LLVM, I guess you mean libstdc++.

jwakely commented 1 month ago

The problem is that the upstream PSTL (which is also part of LLVM!) changed the definition of that macro: https://github.com/llvm/llvm-project/commit/3b9a1bb1af90db9472340ef2122d3855eb9ba3fc#diff-4c6821476cefc699b801f5fdbeda3341e3c64626dcf39a79621ea02031bdd50eL113

It's no longer defined to 1, which seems like a bad decision in the upstream code IMHO.

But the real problem is that onedpl is not including its own pstl_config.h and is relying on an incompatible "third-party" header of the same name, found elsewhere in the include path.

dbs4261 commented 1 month ago

Quick correction, libc++-13 and libc++-14 are the apt packages proving those files. However your point is a good one that both GNU C++ and Clang++ use LLVM's PSTL implementation. I tried adding #include "pstl_config.h" to the top of algorithm_impl.h, and that made me realize both the LLVM PSTL and oneDPL implementation use the same include guard, so that wont work. Looks like this will need to be resolved by either changing the code that checks for _PSTL_UDR_PRESENT or by fixing the upstream header. I think fixing the LLVM PSTL header is the better choice for backwards compatibility reasons.