Skip to content

Commit

Permalink
SYCL: Error out on initialization if the backend is different from ex…
Browse files Browse the repository at this point in the history
…t_oneapi_* (kokkos#6784)

* SYCL: Error out on initialization if the backend is different from ext_oneapi_*

* Use a macro instead.

Co-authored-by: Damien L-G <dalg24@gmail.com>

---------

Co-authored-by: Damien L-G <dalg24@gmail.com>
  • Loading branch information
masterleinad and dalg24 committed Feb 6, 2024
1 parent 63a1208 commit 01d5f81
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/src/SYCL/Kokkos_SYCL_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ void SYCLInternal::initialize(const sycl::device& d) {
void SYCLInternal::initialize(const sycl::queue& q) {
KOKKOS_EXPECTS(!is_initialized());

#define KOKKOS_IMPL_CHECK_SYCL_BACKEND_SUPPORT(BACKEND, REQUIRED) \
if (BACKEND != REQUIRED) \
Kokkos::abort( \
"The SYCL execution space instance was initialized with an " \
"unsupported backend type! For this GPU architecture, only " #REQUIRED \
" is supported.")
#if defined(KOKKOS_ARCH_INTEL_GPU)
KOKKOS_IMPL_CHECK_SYCL_BACKEND_SUPPORT(q.get_backend(),
sycl::backend::ext_oneapi_level_zero);
#elif defined(KOKKOS_IMPL_ARCH_NVIDIA_GPU)
KOKKOS_IMPL_CHECK_SYCL_BACKEND_SUPPORT(q.get_backend(),
sycl::backend::ext_oneapi_cuda);
#elif defined(KOKKOS_ARCH_AMD_GPU)
KOKKOS_IMPL_CHECK_SYCL_BACKEND_SUPPORT(q.get_backend(),
sycl::backend::ext_oneapi_hip);
#endif

if (was_finalized)
Kokkos::abort("Calling SYCL::initialize after SYCL::finalize is illegal\n");

Expand Down

0 comments on commit 01d5f81

Please sign in to comment.