|
| 1 | +// REQUIRES: gpu && linux |
| 2 | +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out |
| 3 | +// RUN: %GPU_RUN_PLACEHOLDER SYCL_HOST_UNIFIED_MEMORY=1 %t.out |
| 4 | + |
| 5 | +#include <CL/sycl.hpp> |
| 6 | +#include <stdio.h> |
| 7 | +#include <stdlib.h> |
| 8 | +#include <unistd.h> |
| 9 | + |
| 10 | +using namespace cl::sycl; |
| 11 | + |
| 12 | +static buffer<char, 1> *inBufP = nullptr; |
| 13 | + |
| 14 | +int main(int argc, char *argv[]) { |
| 15 | + queue Q; |
| 16 | + auto BE = |
| 17 | + (bool)(Q.get_device() |
| 18 | + .template get_info<sycl::info::device::opencl_c_version>() |
| 19 | + .empty()) |
| 20 | + ? "L0" |
| 21 | + : "OpenCL"; |
| 22 | + device dev = Q.get_device(); |
| 23 | + size_t max_compute_units = dev.get_info<info::device::max_compute_units>(); |
| 24 | + printf("Device: %s max_compute_units %zu, Backend: %s\n", |
| 25 | + dev.get_info<info::device::name>().c_str(), max_compute_units, BE); |
| 26 | + |
| 27 | + size_t size = 32; |
| 28 | + void *p; |
| 29 | + posix_memalign(&p, 8, size); |
| 30 | + property::buffer::use_host_ptr prop_use_host_ptr; |
| 31 | + inBufP = new buffer<char, 1>((char *)p, size, prop_use_host_ptr); |
| 32 | + |
| 33 | + int iters = 3; |
| 34 | + for (int r = 0; r < iters; r++) { |
| 35 | + printf("Start iter %d\n", r); |
| 36 | + { host_accessor InhostAcc{*inBufP, write_only}; } |
| 37 | + Q.submit([&](handler &cgh) { |
| 38 | + accessor inAcc{*inBufP, cgh, read_write}; |
| 39 | + cgh.single_task<class X5>([=]() { (void)inAcc; }); |
| 40 | + }); |
| 41 | + Q.wait(); |
| 42 | + printf("End iter\n"); |
| 43 | + } |
| 44 | + delete inBufP; |
| 45 | + free(p); |
| 46 | + |
| 47 | + return 0; |
| 48 | +} |
0 commit comments