|
| 1 | +// REQUIRES: hip_be |
| 2 | +// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s -o %t.out |
| 3 | +// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -D__SYCL_INTERNAL_API %s -o %t.out |
| 4 | +// expected-no-diagnostics |
| 5 | + |
| 6 | +// Test for HIP interop API |
| 7 | + |
| 8 | +#include <sycl/sycl.hpp> |
| 9 | +#include <sycl/ext/oneapi/backend/hip.hpp> |
| 10 | + |
| 11 | +using namespace sycl; |
| 12 | + |
| 13 | +// |
| 14 | +// 4.5.1 SYCL application interoperability may be provided for |
| 15 | +// platform, |
| 16 | +// device, |
| 17 | +// context, |
| 18 | +// queue, |
| 19 | +// event, |
| 20 | +// buffer, |
| 21 | +// device_image, |
| 22 | +// sampled_image, |
| 23 | +// unsampled_image. |
| 24 | + |
| 25 | +int main() { |
| 26 | + |
| 27 | + // Create SYCL objects |
| 28 | + device Device; |
| 29 | + context Context(Device); |
| 30 | + queue Queue(Device); |
| 31 | + event Event; |
| 32 | + |
| 33 | + // 4.5.1.1 For each SYCL runtime class T which supports SYCL application |
| 34 | + // interoperability with the SYCL backend, a specialization of return_type |
| 35 | + // must be defined as the type of SYCL application interoperability native |
| 36 | + // backend object associated with T for the SYCL backend, specified in the |
| 37 | + // SYCL backend specification. |
| 38 | + // |
| 39 | + // return_type is used when retrieving the backend specific native object from |
| 40 | + // a SYCL object. See the relevant backend specification for details. |
| 41 | + |
| 42 | + backend_traits<backend::ext_oneapi_hip>::return_type<device> hip_device; |
| 43 | + backend_traits<backend::ext_oneapi_hip>::return_type<context> hip_context; |
| 44 | + backend_traits<backend::ext_oneapi_hip>::return_type<event> hip_event; |
| 45 | + backend_traits<backend::ext_oneapi_hip>::return_type<queue> hip_queue; |
| 46 | + |
| 47 | + // 4.5.1.2 For each SYCL runtime class T which supports SYCL application |
| 48 | + // interoperability, a specialization of get_native must be defined, which |
| 49 | + // takes an instance of T and returns a SYCL application interoperability |
| 50 | + // native backend object associated with syclObject which can be used for SYCL |
| 51 | + // application interoperability. The lifetime of the object returned are |
| 52 | + // backend-defined and specified in the backend specification. |
| 53 | + |
| 54 | + hip_device = get_native<backend::ext_oneapi_hip>(Device); |
| 55 | + hip_context = get_native<backend::ext_oneapi_hip>(Context); |
| 56 | + hip_event = get_native<backend::ext_oneapi_hip>(Event); |
| 57 | + hip_queue = get_native<backend::ext_oneapi_hip>(Queue); |
| 58 | + |
| 59 | + return 0; |
| 60 | +} |
0 commit comments