77
88#include < sycl/detail/core.hpp>
99#include < sycl/ext/oneapi/free_function_queries.hpp>
10- #include < sycl/usm.hpp>
1110#include < sycl/kernel_bundle.hpp>
11+ #include < sycl/usm.hpp>
1212
1313namespace syclext = sycl::ext::oneapi;
1414namespace syclexp = sycl::ext::oneapi::experimental;
@@ -23,34 +23,32 @@ void func_without_ns(float start, float *ptr) {
2323}
2424
2525namespace free_functions ::tests {
26- SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((syclexp::nd_range_kernel<1 >))
27- void function_in_ns (float start, float *ptr) {
28- size_t id = syclext::this_work_item::get_nd_item<1 >().get_global_linear_id ();
29- ptr[id] = start + static_cast <float >(id + 1 );
30- }
26+ SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((syclexp::nd_range_kernel<1 >))
27+ void function_in_ns (float start, float *ptr) {
28+ size_t id = syclext::this_work_item::get_nd_item<1 >().get_global_linear_id ();
29+ ptr[id] = start + static_cast <float >(id + 1 );
30+ }
3131} // namespace free_functions::tests
3232
3333namespace free_functions ::tests {
3434inline namespace V1 {
35- SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((syclexp::nd_range_kernel<1 >))
36- void function_in_inline_ns (float start, float *ptr)
37- {
38- size_t id = syclext::this_work_item::get_nd_item<1 >().get_global_linear_id ();
39- ptr[id] = start + static_cast <float >(id + 2 );
40- }
41- } // V1
35+ SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((syclexp::nd_range_kernel<1 >))
36+ void function_in_inline_ns (float start, float *ptr) {
37+ size_t id = syclext::this_work_item::get_nd_item<1 >().get_global_linear_id ();
38+ ptr[id] = start + static_cast <float >(id + 2 );
39+ }
40+ } // namespace V1
4241} // namespace free_functions::tests
4342
44-
4543namespace {
46- SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((syclexp::nd_range_kernel<1 >))
47- void function_in_anonymous_ns (float start, float *ptr) {
48- size_t id = syclext::this_work_item::get_nd_item<1 >().get_global_linear_id ();
49- ptr[id] = start + static_cast <float >(id + 3 );
50- }
44+ SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((syclexp::nd_range_kernel<1 >))
45+ void function_in_anonymous_ns (float start, float *ptr) {
46+ size_t id = syclext::this_work_item::get_nd_item<1 >().get_global_linear_id ();
47+ ptr[id] = start + static_cast <float >(id + 3 );
5148}
49+ } // namespace
5250
53- static void call_kernel_code (sycl::queue& q, sycl::kernel& kernel) {
51+ static void call_kernel_code (sycl::queue & q, sycl::kernel & kernel) {
5452 float *ptr = sycl::malloc_shared<float >(NUM, q);
5553 q.submit ([&](sycl::handler &cgh) {
5654 cgh.set_args (3 .14f , ptr);
@@ -59,48 +57,56 @@ static void call_kernel_code(sycl::queue& q, sycl::kernel& kernel) {
5957 }).wait ();
6058}
6159
62- void test_function_without_ns (sycl::queue& q, sycl::context& ctxt)
63- {
64- // Get a kernel bundle that contains the free function kernel "func_without_ns".
60+ void test_function_without_ns (sycl::queue & q, sycl::context & ctxt) {
61+ // Get a kernel bundle that contains the free function kernel
62+ // "func_without_ns".
6563 auto exe_bndl =
66- syclexp::get_kernel_bundle<func_without_ns, sycl::bundle_state::executable>(ctxt);
64+ syclexp::get_kernel_bundle<func_without_ns,
65+ sycl::bundle_state::executable>(ctxt);
6766 // Get a kernel object for the "func_without_ns" function from that bundle.
68- sycl::kernel k_func_without_ns = exe_bndl.ext_oneapi_get_kernel <func_without_ns>();
67+ sycl::kernel k_func_without_ns =
68+ exe_bndl.ext_oneapi_get_kernel <func_without_ns>();
6969 call_kernel_code (q, k_func_without_ns);
7070}
7171
72- void test_function_in_ns (sycl::queue& q, sycl::context& ctxt)
73- {
74- // Get a kernel bundle that contains the free function kernel "function_in_ns".
72+ void test_function_in_ns (sycl::queue & q, sycl::context & ctxt) {
73+ // Get a kernel bundle that contains the free function kernel
74+ // "function_in_ns".
7575 auto exe_bndl =
76- syclexp::get_kernel_bundle<free_functions::tests::function_in_ns,
76+ syclexp::get_kernel_bundle<free_functions::tests::function_in_ns,
7777 sycl::bundle_state::executable>(ctxt);
7878
7979 // Get a kernel object for the "function_in_ns" function from that bundle.
80- sycl::kernel k_function_in_ns = exe_bndl.ext_oneapi_get_kernel <free_functions::tests::function_in_ns>();
80+ sycl::kernel k_function_in_ns =
81+ exe_bndl.ext_oneapi_get_kernel <free_functions::tests::function_in_ns>();
8182 call_kernel_code (q, k_function_in_ns);
8283}
8384
84- void test_function_in_inline_ns (sycl::queue& q, sycl::context& ctxt)
85- {
86- // Get a kernel bundle that contains the free function kernel "function_in_inline_ns".
85+ void test_function_in_inline_ns (sycl::queue & q, sycl::context & ctxt) {
86+ // Get a kernel bundle that contains the free function kernel
87+ // "function_in_inline_ns".
8788 auto exe_bndl =
88- syclexp::get_kernel_bundle<free_functions::tests::function_in_inline_ns,
89+ syclexp::get_kernel_bundle<free_functions::tests::function_in_inline_ns,
8990 sycl::bundle_state::executable>(ctxt);
9091
91- // Get a kernel object for the "function_in_inline_ns" function from that bundle.
92- sycl::kernel k_function_in_inline_ns = exe_bndl.ext_oneapi_get_kernel <free_functions::tests::function_in_inline_ns>();
92+ // Get a kernel object for the "function_in_inline_ns" function from that
93+ // bundle.
94+ sycl::kernel k_function_in_inline_ns = exe_bndl.ext_oneapi_get_kernel <
95+ free_functions::tests::function_in_inline_ns>();
9396 call_kernel_code (q, k_function_in_inline_ns);
9497}
9598
96- void test_function_in_anonymous_ns (sycl::queue& q, sycl::context& ctxt) {
97- // Get a kernel bundle that contains the free function kernel "function_in_anonymous_ns".
99+ void test_function_in_anonymous_ns (sycl::queue &q, sycl::context &ctxt) {
100+ // Get a kernel bundle that contains the free function kernel
101+ // "function_in_anonymous_ns".
98102 auto exe_bndl =
99- syclexp::get_kernel_bundle<function_in_anonymous_ns,
103+ syclexp::get_kernel_bundle<function_in_anonymous_ns,
100104 sycl::bundle_state::executable>(ctxt);
101105
102- // Get a kernel object for the "function_in_anonymous_ns" function from that bundle.
103- sycl::kernel k_function_in_anonymous_ns = exe_bndl.ext_oneapi_get_kernel <function_in_anonymous_ns>();
106+ // Get a kernel object for the "function_in_anonymous_ns" function from that
107+ // bundle.
108+ sycl::kernel k_function_in_anonymous_ns =
109+ exe_bndl.ext_oneapi_get_kernel <function_in_anonymous_ns>();
104110 call_kernel_code (q, k_function_in_anonymous_ns);
105111}
106112
0 commit comments