diff --git a/CMakeLists.txt b/CMakeLists.txt index 9742ae33a3..190de1701b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,6 +301,7 @@ if (ONEDPL_BACKEND MATCHES "^(tbb|dpcpp|dpcpp_only)$") target_compile_definitions(oneDPL INTERFACE $<$,$>:ONEDPL_FPGA_DEVICE> $<$:ONEDPL_FPGA_EMULATOR> + ONEDPL_USE_DPCPP_BACKEND=1 ) # DPC++ specific link options diff --git a/include/oneapi/dpl/pstl/onedpl_config.h b/include/oneapi/dpl/pstl/onedpl_config.h index 23dbbcb43a..e10dd9dd08 100644 --- a/include/oneapi/dpl/pstl/onedpl_config.h +++ b/include/oneapi/dpl/pstl/onedpl_config.h @@ -54,20 +54,34 @@ but OpenMP headers are not found or the compiler does not support OpenMP" #endif -#if defined(__INTEL_LLVM_COMPILER) && (defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)) -# define _ONEDPL_SYCL_ENABLED_FOR_INTEL_LLVM 1 -#endif +// Preliminary check SYCL availability #if (__has_include() || __has_include()) -// Intel(R) oneAPI DPC++/C++ Compiler is known to provide SYCL_LANGUAGE_VERSION with certain compiler options, -// while other implementations may require inclusion of sycl/sycl.hpp, which is not desired in onedpl_config.h -# if _ONEDPL_SYCL_ENABLED_FOR_INTEL_LLVM || !defined(__INTEL_LLVM_COMPILER) -# define _ONEDPL_SYCL_AVAILABLE 1 -# endif +# define _ONEDPL_SYCL_HEADER_PRESENT 1 +#endif +#if defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION) +# define _ONEDPL_SYCL_LANGUAGE_VERSION_PRESENT 1 +#endif +#if _ONEDPL_SYCL_HEADER_PRESENT && _ONEDPL_SYCL_LANGUAGE_VERSION_PRESENT +# define _ONEDPL_SYCL_AVAILABLE 1 #endif -#if ONEDPL_USE_DPCPP_BACKEND && !_ONEDPL_SYCL_AVAILABLE +// Intel(R) oneAPI DPC++/C++ Compiler provides SYCL_LANGUAGE_VERSION without sycl.hpp inclusion +#if _ONEDPL_SYCL_HEADER_PRESENT && !_ONEDPL_SYCL_LANGUAGE_VERSION_PRESENT && !defined(__INTEL_LLVM_COMPILER) +# define _ONEDPL_SYCL_POSSIBLY_AVAILABLE 1 +#endif + +// If DPCPP backend is explicitly requested and SYCL is (possibly) available, enable it +#if ONEDPL_USE_DPCPP_BACKEND && (_ONEDPL_SYCL_AVAILABLE || _ONEDPL_SYCL_POSSIBLY_AVAILABLE) +# define _ONEDPL_BACKEND_SYCL 1 +#endif +// If DPCPP backend is explicitly requested and SYCL is definitely not available, throw an error +#if ONEDPL_USE_DPCPP_BACKEND && !(_ONEDPL_SYCL_AVAILABLE || _ONEDPL_SYCL_POSSIBLY_AVAILABLE) # error "Device execution policies are enabled, \ but SYCL* headers are not found or the compiler does not support SYCL" #endif +// If DPCPP backend is not requested explicitly and SYCL is definitely available, enable it +#if !defined(ONEDPL_USE_DPCPP_BACKEND) && _ONEDPL_SYCL_AVAILABLE +# define _ONEDPL_BACKEND_SYCL 1 +#endif // Check the user-defined macro for warnings #if !defined(_PSTL_USAGE_WARNINGS) && defined(PSTL_USAGE_WARNINGS) @@ -258,10 +272,6 @@ #define _ONEDPL_HAS_NUMERIC_SERIAL_IMPL \ (__GLIBCXX__ && (_GLIBCXX_RELEASE < 9 || (_GLIBCXX_RELEASE == 9 && __GLIBCXX__ < 20200312))) -#if ONEDPL_USE_DPCPP_BACKEND || (!defined(ONEDPL_USE_DPCPP_BACKEND) && _ONEDPL_SYCL_AVAILABLE) -# define _ONEDPL_BACKEND_SYCL 1 -#endif - // if SYCL policy switch on then let's switch hetero policy macro on #if _ONEDPL_BACKEND_SYCL # if _ONEDPL_HETERO_BACKEND diff --git a/test/support/test_config.h b/test/support/test_config.h index d481365646..d85301b227 100644 --- a/test/support/test_config.h +++ b/test/support/test_config.h @@ -88,16 +88,28 @@ #define _PSTL_SYCL_TEST_USM 1 -// Enable test when the DPC++ backend is available -#if defined(__INTEL_LLVM_COMPILER) && (defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)) -# define TEST_SYCL_ENABLED_FOR_INTEL_LLVM 1 +// If DPCPP is requested, enable its testing +#if ONEDPL_USE_DPCPP_BACKEND +# define TEST_DPCPP_BACKEND_PRESENT 1 #endif -#if __has_include() || __has_include() && \ - (TEST_SYCL_ENABLED_FOR_INTEL_LLVM || !defined(__INTEL_LLVM_COMPILER)) && \ - (!defined(ONEDPL_USE_DPCPP_BACKEND) || ONEDPL_USE_DPCPP_BACKEND != 0) -# define TEST_DPCPP_BACKEND_PRESENT 1 -#else -# define TEST_DPCPP_BACKEND_PRESENT 0 + +// If DPCPP backend is not explicitly requested, repeat oneDPL behavior +// which enables DPCPP backend when SYCL is definitely available +#if (__has_include() || __has_include()) +# define TEST_SYCL_HEADER_PRESENT 1 +#endif +#if defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION) +# define TEST_SYCL_LANGUAGE_VERSION_PRESENT 1 +#endif +#if TEST_SYCL_HEADER_PRESENT && TEST_SYCL_LANGUAGE_VERSION_PRESENT +# define TEST_SYCL_AVAILABLE 1 +#endif +#if !defined(ONEDPL_USE_DPCPP_BACKEND) && TEST_SYCL_AVAILABLE +# define TEST_DPCPP_BACKEND_PRESENT 1 +#endif + +#if !defined(TEST_DPCPP_BACKEND_PRESENT) +# define TEST_DPCPP_BACKEND_PRESENT 0 #endif #ifdef __SYCL_UNNAMED_LAMBDA__