Skip to content

Commit 2e48081

Browse files
alexeyvoronov-intelbader
authored andcommitted
[SYCL] Enable sampler support in set_arg(s) method.
Signed-off-by: Alexey Voronov <alexey.voronov@intel.com>
1 parent a718871 commit 2e48081

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

sycl/include/CL/sycl/handler.hpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,11 @@ class handler {
464464
sizeof(T), ArgIndex);
465465
}
466466

467-
// TODO: implement when sampler class is ready
468-
// void setArgHelper(int argIndex, sampler &&arg) {}
467+
void setArgHelper(int ArgIndex, sampler &&Arg) {
468+
void *StoredArg = (void *)storePlainArg(Arg);
469+
MArgs.emplace_back(detail::kernel_param_kind_t::kind_sampler, StoredArg,
470+
sizeof(sampler), ArgIndex);
471+
}
469472

470473
void verifySyclKernelInvoc(const kernel &SyclKernel) {
471474
if (is_host()) {

sycl/test/kernel-and-program/kernel-and-program.cpp

+24-4
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,16 @@ int main() {
5252
assert(data == 1);
5353

5454
// OpenCL interoperability kernel invocation
55-
// TODO add set_args(cl::sycl::sampler) use case once it's supported
5655
if (!q.is_host()) {
57-
cl_int err;
58-
if (0) {
56+
{
57+
cl_int err;
5958
cl::sycl::context ctx = q.get_context();
6059
cl_context clCtx = ctx.get();
6160
cl_command_queue clQ = q.get();
6261
cl_mem clBuffer =
6362
clCreateBuffer(clCtx, CL_MEM_WRITE_ONLY, sizeof(int), NULL, NULL);
6463
err = clEnqueueWriteBuffer(clQ, clBuffer, CL_TRUE, 0, sizeof(int),
6564
&data, 0, NULL, NULL);
66-
// Kernel interoperability constructor
6765
assert(err == CL_SUCCESS);
6866
cl::sycl::program prog(ctx);
6967
prog.build_with_source(
@@ -101,6 +99,28 @@ int main() {
10199
assert(a == b + c);
102100
}
103101
}
102+
{
103+
cl::sycl::queue Queue;
104+
if (!Queue.is_host()) {
105+
cl::sycl::sampler first(
106+
cl::sycl::coordinate_normalization_mode::normalized,
107+
cl::sycl::addressing_mode::clamp, cl::sycl::filtering_mode::linear);
108+
cl::sycl::sampler second(
109+
cl::sycl::coordinate_normalization_mode::unnormalized,
110+
cl::sycl::addressing_mode::clamp_to_edge,
111+
cl::sycl::filtering_mode::nearest);
112+
cl::sycl::program prog(Queue.get_context());
113+
prog.build_with_source(
114+
"kernel void sampler_args(int a, sampler_t first, "
115+
"int b, sampler_t second, int c) {}\n");
116+
cl::sycl::kernel krn = prog.get_kernel("sampler_args");
117+
118+
Queue.submit([&](cl::sycl::handler &cgh) {
119+
cgh.set_args(0, first, 2, second, 3);
120+
cgh.single_task(krn);
121+
});
122+
}
123+
}
104124
}
105125
// Parallel for with range
106126
{

0 commit comments

Comments
 (0)