1
+ // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -L %opencl_libs_dir -lOpenCL
2
+ // RUN: %CPU_RUN_PLACEHOLDER %t.out
3
+ // RUN: %GPU_RUN_PLACEHOLDER %t.out
4
+ // RUN: %ACC_RUN_PLACEHOLDER %t.out
5
+
6
+ // ==--- kernel_info.cpp - SYCL kernel info test ----------------------------==//
7
+ //
8
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9
+ // See https://llvm.org/LICENSE.txt for license information.
10
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11
+ //
12
+ // ===----------------------------------------------------------------------===//
13
+
14
+ #include < CL/sycl.hpp>
15
+
16
+ using namespace cl ::sycl;
17
+
18
+ void check (bool condition, const char *conditionString, const char *filename,
19
+ const long line) noexcept {
20
+ if (!condition) {
21
+ std::cerr << " CHECK failed in " << filename << " #" << line << " "
22
+ << conditionString << " \n " ;
23
+ std::abort ();
24
+ }
25
+ }
26
+
27
+ #define CHECK (CONDITION ) check(CONDITION, #CONDITION, __FILE__, __LINE__)
28
+
29
+ int main () {
30
+ queue q;
31
+
32
+ buffer<int , 1 > buf (range<1 >(1 ));
33
+ program prg (q.get_context ());
34
+
35
+ prg.build_with_kernel_type <class SingleTask >();
36
+ kernel krn = prg.get_kernel <class SingleTask >();
37
+
38
+ q.submit ([&](handler &cgh) {
39
+ auto acc = buf.get_access <access ::mode::read_write>(cgh);
40
+ cgh.single_task <class SingleTask >(krn, [=]() { acc[0 ] = acc[0 ] + 1 ; });
41
+ });
42
+
43
+ const string_class krnName = krn.get_info <info::kernel::function_name>();
44
+ CHECK (!krnName.empty ());
45
+ const cl_uint krnArgCount = krn.get_info <info::kernel::num_args>();
46
+ CHECK (krnArgCount > 0 );
47
+ const context krnCtx = krn.get_info <info::kernel::context>();
48
+ CHECK (krnCtx == q.get_context ());
49
+ const program krnPrg = krn.get_info <info::kernel::program>();
50
+ CHECK (krnPrg == prg);
51
+ const cl_uint krnRefCount = krn.get_info <info::kernel::reference_count>();
52
+ CHECK (krnRefCount > 0 );
53
+ const string_class krnAttr = krn.get_info <info::kernel::attributes>();
54
+ CHECK (krnAttr.empty ());
55
+
56
+ device dev = q.get_device ();
57
+ const size_t wgSize =
58
+ krn.get_work_group_info <info::kernel_work_group::work_group_size>(dev);
59
+ CHECK (wgSize > 0 );
60
+ const size_t prefWGSizeMult = krn.get_work_group_info <
61
+ info::kernel_work_group::preferred_work_group_size_multiple>(dev);
62
+ CHECK (prefWGSizeMult > 0 );
63
+ const cl_ulong prvMemSize =
64
+ krn.get_work_group_info <info::kernel_work_group::private_mem_size>(dev);
65
+ CHECK (prvMemSize == 0 );
66
+ }
0 commit comments