11// REQUIRES: aspect-usm_shared_allocations
2- // RUN: %{build} -o %t.out
2+ // RUN: %{build} --save-temps - o %t.out
33// RUN: %{run} %t.out
44
55#include < iostream>
@@ -21,6 +21,11 @@ void ff_2(int *ptr, int start) {
2121 ptr2D[GId.get (0 )][GId.get (1 )] = LId.get (0 ) + LId.get (1 ) + start;
2222}
2323
24+ SYCL_EXT_ONEAPI_FUNCTION_PROPERTY (
25+ (ext::oneapi::experimental::nd_range_kernel<2 >))
26+ void ff_b(int *ptr, int start) {
27+ }
28+
2429// Templated free function definition.
2530template <typename T>
2631SYCL_EXT_ONEAPI_FUNCTION_PROPERTY (
@@ -96,6 +101,21 @@ bool test_kernel_apis(queue Queue) {
96101 return Pass;
97102}
98103
104+ template <auto *Func>
105+ bool check_kernel_id (const sycl::kernel k, const sycl::context &ctx) {
106+ namespace exp = ext::oneapi::experimental;
107+ const auto id = exp::get_kernel_id<Func>();
108+ auto exe_bndl =
109+ exp::get_kernel_bundle<Func, sycl::bundle_state::executable>(ctx);
110+ if (!exe_bndl.has_kernel (id))
111+ return false ;
112+ const auto kb = sycl::get_kernel_bundle<sycl::bundle_state::executable>(ctx);
113+ const auto kernel_ids = kb.get_kernel_ids ();
114+ bool ret =
115+ std::find (kernel_ids.begin (), kernel_ids.end (), id) != kernel_ids.end ();
116+ return ret;
117+ }
118+
99119bool test_bundle_apis (queue Queue) {
100120 bool Pass = true ;
101121
@@ -133,6 +153,10 @@ bool test_bundle_apis(queue Queue) {
133153 std::cout << " PassE=" << PassE << std::endl;
134154 Pass &= PassE;
135155
156+ bool PassE2 = ext::oneapi::experimental::is_compatible<ff_2>(Device);
157+ std::cout << " PassE2=" << PassE2 << std::endl;
158+ Pass &= PassE2;
159+
136160 // Check that ff_2 is found in bundle.
137161 kernel_bundle Bundle2 = ext::oneapi::experimental::get_kernel_bundle<
138162 ff_2, bundle_state::executable>(Context);
@@ -144,7 +168,7 @@ bool test_bundle_apis(queue Queue) {
144168 std::cout << " PassG=" << PassG << std::endl;
145169 Pass &= PassG;
146170 kernel Kernel2 = Bundle2.ext_oneapi_get_kernel <ff_2>();
147- bool PassH = true ;
171+ bool PassH = check_kernel_id<ff_2>(Kernel2, Context) ;
148172 std::cout << " PassH=" << PassH << std::endl;
149173 Pass &= PassH;
150174
@@ -161,7 +185,8 @@ bool test_bundle_apis(queue Queue) {
161185 Pass &= PassJ;
162186 kernel Kernel3 =
163187 Bundle3.ext_oneapi_get_kernel <(void (*)(int *, int ))ff_3<int >>();
164- bool PassK = true ;
188+ bool PassK =
189+ check_kernel_id<(void (*)(int *, int ))ff_3<int >>(Kernel3, Context);
165190 std::cout << " PassK=" << PassK << std::endl;
166191 Pass &= PassK;
167192
@@ -196,6 +221,18 @@ bool test_bundle_apis(queue Queue) {
196221 std::cout << " PassP=" << PassP << std::endl;
197222 Pass &= PassP;
198223
224+ bool PassO1 = false ;
225+ try
226+ {
227+ kernel Kernel51 = Bundle5.ext_oneapi_get_kernel <ff_b>();
228+ std::cout <<" Wrong PATH" << std::endl;
229+ } catch (const sycl::exception &e) {
230+ PassO1 = e.code () == sycl::errc::invalid;
231+ }
232+ std::cout << " PassO1=" << PassO1 << std::endl;
233+ Pass &= PassO1;
234+
235+
199236 bool PassQ =
200237 Bundle6.ext_oneapi_has_kernel <(void (*)(int *, int ))ff_3<int >>(Device);
201238 std::cout << " PassQ=" << PassQ << std::endl;
0 commit comments