Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] test for https://github.com/intel/llvm/pull/4405 #424

Merged
merged 1 commit into from
Sep 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions SYCL/Regression/host_unified_memory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// REQUIRES: gpu && linux
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER SYCL_HOST_UNIFIED_MEMORY=1 %t.out

#include <CL/sycl.hpp>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

using namespace cl::sycl;

static buffer<char, 1> *inBufP = nullptr;

int main(int argc, char *argv[]) {
queue Q;
auto BE =
(bool)(Q.get_device()
.template get_info<sycl::info::device::opencl_c_version>()
.empty())
? "L0"
: "OpenCL";
device dev = Q.get_device();
size_t max_compute_units = dev.get_info<info::device::max_compute_units>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor.
Information about compute units seems to be irrelevant to the test case.

printf("Device: %s max_compute_units %zu, Backend: %s\n",
dev.get_info<info::device::name>().c_str(), max_compute_units, BE);

size_t size = 32;
void *p;
posix_memalign(&p, 8, size);
property::buffer::use_host_ptr prop_use_host_ptr;
inBufP = new buffer<char, 1>((char *)p, size, prop_use_host_ptr);

int iters = 3;
for (int r = 0; r < iters; r++) {
printf("Start iter %d\n", r);
{ host_accessor InhostAcc{*inBufP, write_only}; }
Q.submit([&](handler &cgh) {
accessor inAcc{*inBufP, cgh, read_write};
cgh.single_task<class X5>([=]() { (void)inAcc; });
});
Q.wait();
printf("End iter\n");
}
delete inBufP;
free(p);

return 0;
}