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

Commit a38a484

Browse files
[SYCL] Add check for carrying real kernel IDs (#616)
1 parent e052442 commit a38a484

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// REQUIRES: opencl
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
3+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
4+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
5+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
6+
7+
#include <CL/opencl.h>
8+
#include <CL/sycl.hpp>
9+
#include <CL/sycl/backend/opencl.hpp>
10+
11+
using namespace cl::sycl;
12+
13+
int main() {
14+
queue Queue{};
15+
16+
const char KernelCode[] = "__kernel void foo() { }\n";
17+
const size_t KernelCodeSize = sizeof(KernelCode);
18+
const char *CLCode[1] = {KernelCode};
19+
20+
auto Context = Queue.get_info<info::queue::context>();
21+
auto Device = Queue.get_info<info::queue::device>();
22+
cl_context CLContext = get_native<backend::opencl>(Context);
23+
cl_device_id CLDevice = get_native<backend::opencl>(Device);
24+
25+
cl_int Err;
26+
27+
cl_program CLProgram =
28+
clCreateProgramWithSource(CLContext, 1, CLCode, &KernelCodeSize, &Err);
29+
assert(Err == CL_SUCCESS);
30+
Err = clBuildProgram(CLProgram, 1, &CLDevice, "", nullptr, nullptr);
31+
assert(Err == CL_SUCCESS);
32+
33+
cl_kernel CLKernel = clCreateKernel(CLProgram, "foo", &Err);
34+
assert(Err == CL_SUCCESS);
35+
kernel SYCLKernel = sycl::make_kernel<backend::opencl>(CLKernel, Context);
36+
37+
Queue.submit(
38+
[&](handler &commandgroup) { commandgroup.single_task(SYCLKernel); });
39+
return 0;
40+
}

0 commit comments

Comments
 (0)