|
| 1 | +// RUN: %clangxx -fsycl-device-only -fsycl-targets=spir64_fpga -S -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR |
| 2 | + |
| 3 | +// Tests that the address space of `annotated_arg` kernel argument is refined |
| 4 | +// when: |
| 5 | +// 1. `usm_kind` property is specified in annotated_arg type, and |
| 6 | +// 2. both `__SYCL_DEVICE_ONLY__` and `__ENABLE_USM_ADDR_SPACE__` are turned on |
| 7 | +// (i.e. equiv to flags "-fsycl-device-only -fsycl-targets=spir64_fpga") |
| 8 | + |
| 9 | +#include "sycl/sycl.hpp" |
| 10 | + |
| 11 | +#include <sycl/ext/intel/fpga_extensions.hpp> |
| 12 | + |
| 13 | +#include <iostream> |
| 14 | + |
| 15 | +using namespace sycl; |
| 16 | +using namespace ext::oneapi::experimental; |
| 17 | +using namespace ext::intel::experimental; |
| 18 | + |
| 19 | +using annotated_arg_t1 = |
| 20 | + annotated_arg<int *, |
| 21 | + decltype(properties(buffer_location<0>, usm_kind_device))>; |
| 22 | +using annotated_arg_t2 = |
| 23 | + annotated_arg<int *, |
| 24 | + decltype(properties(buffer_location<1>, usm_kind_host))>; |
| 25 | +using annotated_arg_t3 = |
| 26 | + annotated_arg<int *, |
| 27 | + decltype(properties(buffer_location<2>, usm_kind_shared))>; |
| 28 | + |
| 29 | +struct MyIP { |
| 30 | + |
| 31 | + // CHECK-IR: spir_kernel void @_ZTS4MyIP(ptr addrspace(5) {{.*}} %_arg_a, ptr addrspace(6) {{.*}} %_arg_b, ptr addrspace(1) {{.*}} %_arg_c) |
| 32 | + annotated_arg_t1 a; |
| 33 | + annotated_arg_t2 b; |
| 34 | + annotated_arg_t3 c; |
| 35 | + |
| 36 | + void operator()() const { *a = *b + *c; } |
| 37 | +}; |
| 38 | + |
| 39 | +void TestVectorAddWithAnnotatedMMHosts() { |
| 40 | + queue q; |
| 41 | + auto p1 = malloc_device<int>(5, q); |
| 42 | + auto p2 = malloc_host<int>(5, q); |
| 43 | + auto p3 = malloc_shared<int>(5, q); |
| 44 | + |
| 45 | + q.submit([&](handler &h) { h.single_task(MyIP{p1, p2, p3}); }).wait(); |
| 46 | + |
| 47 | + free(p1, q); |
| 48 | + free(p2, q); |
| 49 | + free(p3, q); |
| 50 | +} |
| 51 | + |
| 52 | +int main() { |
| 53 | + TestVectorAddWithAnnotatedMMHosts(); |
| 54 | + return 0; |
| 55 | +} |
0 commit comments