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
720 stars 113 forks source link

oneDPL/include/oneapi/dpl/pstl/./omp/parallel_merge.h:87: undefined reference to `omp_in_parallel' #510

Closed jeffhammond closed 2 years ago

jeffhammond commented 2 years ago

I'm trying to build 67383db9ac3223c825f4b8783b38bb9ab01aa757 like this:

cmake .. -DONEDPL_BACKEND=dpcpp_only -DONEDPL_DEVICE_TYPE=GPU -DONEDPL_DEVICE_BACKEND=level_zero -DONEDPL_USE_UNNAMED_LAMBDA=TRUE -DCMAKE_CXX_COMPILER=dpcpp -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_STANDARD=17

It fails because OpenMP isn't available. I know how to tell it where OpenMP is, but I should not have to do that, since I am building a DPC++-only backend for the GPU.

[ 16%] Linking CXX executable merge.pass
/usr/bin/ld: /tmp/merge-bd963e.o: in function `_ZN6oneapi3dpl13__omp_backend16__parallel_mergeIRKNS0_9execution2v115parallel_policyEN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEENS9_IPKiSD_EESE_NS0_10__internal11__pstl_lessEZNSI_15__pattern_mergeIS7_SE_SH_SE_SJ_St17integral_constantIbLb0EEEENSt9enable_ifIXsr6oneapi3dpl10__internal26__is_host_execution_policyINSt5decayIT_E4typeEEE5valueET2_E4typeEOSP_T0_SW_T1_SX_SS_T3_T4_SL_IbLb1EEEUlSE_SE_SH_SH_SE_SJ_E_EEvSV_SW_SW_SX_SX_SS_SY_SZ_':
/tmp/oneDPL/include/oneapi/dpl/pstl/./omp/parallel_merge.h:87: undefined reference to `omp_in_parallel'
/usr/bin/ld: /tmp/merge-bd963e.o: in function `_ZN6oneapi3dpl13__omp_backend16__parallel_mergeIRKNS0_9execution2v115parallel_policyEN9__gnu_cxx17__normal_iteratorIPdSt6vectorIdSaIdEEEENS9_IPKdSD_EESE_NS0_10__internal11__pstl_lessEZNSI_15__pattern_mergeIS7_SE_SH_SE_SJ_St17integral_constantIbLb0EEEENSt9enable_ifIXsr6oneapi3dpl10__internal26__is_host_execution_policyINSt5decayIT_E4typeEEE5valueET2_E4typeEOSP_T0_SW_T1_SX_SS_T3_T4_SL_IbLb1EEEUlSE_SE_SH_SH_SE_SJ_E_EEvSV_SW_SW_SX_SX_SS_SY_SZ_':
/tmp/oneDPL/include/oneapi/dpl/pstl/./omp/parallel_merge.h:87: undefined reference to `omp_in_parallel'
/usr/bin/ld: /tmp/merge-bd963e.o: in function `_ZN6oneapi3dpl13__omp_backend16__parallel_mergeIRKNS0_9execution2v115parallel_policyESt16reverse_iteratorIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEES8_INSA_IPKiSE_EEESG_St7greaterIiEZNS0_10__internal15__pattern_mergeIS7_SG_SK_SG_SM_St17integral_constantIbLb0EEEENSt9enable_ifIXsr6oneapi3dpl10__internal26__is_host_execution_policyINSt5decayIT_E4typeEEE5valueET2_E4typeEOST_T0_S10_T1_S11_SW_T3_T4_SP_IbLb1EEEUlSG_SG_SK_SK_SG_SM_E_EEvSZ_S10_S10_S11_S11_SW_S12_S13_':
/tmp/oneDPL/include/oneapi/dpl/pstl/./omp/parallel_merge.h:87: undefined reference to `omp_in_parallel'
/usr/bin/ld: /tmp/merge-bd963e.o: in function `_ZN6oneapi3dpl13__omp_backend16__parallel_mergeIRKNS0_9execution2v127parallel_unsequenced_policyESt16reverse_iteratorIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEES8_INSA_IPKiSE_EEESG_St7greaterIiEZNS0_10__internal15__pattern_mergeIS7_SG_SK_SG_SM_St17integral_constantIbLb1EEEENSt9enable_ifIXsr6oneapi3dpl10__internal26__is_host_execution_policyINSt5decayIT_E4typeEEE5valueET2_E4typeEOST_T0_S10_T1_S11_SW_T3_T4_SQ_EUlSG_SG_SK_SK_SG_SM_E_EEvSZ_S10_S10_S11_S11_SW_S12_S13_':
/tmp/oneDPL/include/oneapi/dpl/pstl/./omp/parallel_merge.h:87: undefined reference to `omp_in_parallel'
/usr/bin/ld: /tmp/merge-bd963e.o: in function `_ZN6oneapi3dpl13__omp_backend16__parallel_mergeIRKNS0_9execution2v115parallel_policyESt16reverse_iteratorIN9__gnu_cxx17__normal_iteratorIPdSt6vectorIdSaIdEEEEES8_INSA_IPKdSE_EEESG_St7greaterIdEZNS0_10__internal15__pattern_mergeIS7_SG_SK_SG_SM_St17integral_constantIbLb0EEEENSt9enable_ifIXsr6oneapi3dpl10__internal26__is_host_execution_policyINSt5decayIT_E4typeEEE5valueET2_E4typeEOST_T0_S10_T1_S11_SW_T3_T4_SP_IbLb1EEEUlSG_SG_SK_SK_SG_SM_E_EEvSZ_S10_S10_S11_S11_SW_S12_S13_':
/tmp/oneDPL/include/oneapi/dpl/pstl/./omp/parallel_merge.h:87: undefined reference to `omp_in_parallel'
/usr/bin/ld: /tmp/merge-bd963e.o:/tmp/oneDPL/include/oneapi/dpl/pstl/./omp/parallel_merge.h:87: more undefined references to `omp_in_parallel' follow
rarutyun commented 2 years ago

Thanks for finding it Jeff. It definitely looks like a bug. We will look into that.

MikeDvorskiy commented 2 years ago

Probably, when we were considering "the host backend default selection logic", we missed the case "-DONEDPL_BACKEND=dpcpp_only". In that case the all host backends (corresponding macros) should be switched OFF. So, it should be fixed.

MikeDvorskiy commented 2 years ago

@jeffhammond, actually, we couldn't reproduce the original issue - we didn't see OpenMP runtime linkage errors. Did you modify cmake files locally? Also, could you please perform make VERBOSE=1 merge.pass and provide a command line output? What we can see right now (from the oneDPL code) is we enable OpenMP backend implicitly only if -fopenmp option is specified.

jeffhammond commented 2 years ago

It is doing weird stuff for me now. I reproduced just now but couldn't do it again. I guess you can close it. My environment must be cursed.

rarutyun commented 2 years ago

Anyway, that's interesting finding. We need to double check if our behavior is correct for dpcpp_only option. Thanks.

MikeDvorskiy commented 2 years ago

@jeffhammond, I've just reproduced the same linkage problem - "...undefined reference to omp_in_parallel ...." with the release compiler (Intel(R) oneAPI DPC++/C++ Compiler 2022.0.0 (2022.0.0.20211123) Macro _OPENMP is enabled by option -fopenmp-simd. It looks like an error in compiler driver (.exe). In the current nightly version the error is fixed. I guess, a new version (update) of the compiler will be released soon.