DPC++ Runtime
Runtime libraries for oneAPI DPC++
hip.hpp
Go to the documentation of this file.
1 //==--------- hip.hpp - SYCL HIP backend -----------------------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <sycl/backend.hpp>
12 
13 namespace sycl {
15 
16 template <>
17 inline backend_return_t<backend::ext_oneapi_hip, device>
18 get_native<backend::ext_oneapi_hip, device>(const device &Obj) {
19  // TODO use SYCL 2020 exception when implemented
20  if (Obj.get_backend() != backend::ext_oneapi_hip) {
21  throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch",
22  PI_ERROR_INVALID_OPERATION);
23  }
24  // HIP uses a 32-bit int instead of an opaque pointer like other backends,
25  // so we need a specialization with static_cast instead of reinterpret_cast.
27  Obj.getNative());
28 }
29 
30 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
31 } // namespace sycl
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:11
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
sycl::_V1::device::get_backend
backend get_backend() const noexcept
Returns the backend associated with this device.
Definition: device.cpp:198
sycl::_V1::backend_return_t
typename backend_traits< Backend >::template return_type< SyclType > backend_return_t
Definition: backend.hpp:72
sycl::_V1::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:49
backend.hpp