Skip to content

Commit

Permalink
Align the approach with the review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Sobolev <dmitriy.sobolev@intel.com>
  • Loading branch information
dmitriy-sobolev committed Oct 15, 2024
1 parent 5da43fa commit e8cedef
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 22 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ if (ONEDPL_BACKEND MATCHES "^(tbb|dpcpp|dpcpp_only)$")
target_compile_definitions(oneDPL INTERFACE
$<$<OR:$<BOOL:${ONEDPL_USE_DEVICE_FPGA_HW}>,$<BOOL:${ONEDPL_USE_DEVICE_FPGA_EMU}>>:ONEDPL_FPGA_DEVICE>
$<$<BOOL:${ONEDPL_USE_DEVICE_FPGA_EMU}>:ONEDPL_FPGA_EMULATOR>
ONEDPL_USE_DPCPP_BACKEND=1
)

# DPC++ specific link options
Expand Down
36 changes: 23 additions & 13 deletions include/oneapi/dpl/pstl/onedpl_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(<sycl/sycl.hpp>) || __has_include(<CL/sycl.hpp>))
// 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)
Expand Down Expand Up @@ -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
Expand Down
30 changes: 21 additions & 9 deletions test/support/test_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(<sycl/sycl.hpp>) || __has_include(<CL/sycl.hpp>) && \
(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(<sycl/sycl.hpp>) || __has_include(<CL/sycl.hpp>))
# 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__
Expand Down

0 comments on commit e8cedef

Please sign in to comment.