@@ -64,6 +64,17 @@ void ff_cp(int *ptr) {
6464 sycl::id<1> GId = Item.get_global_id();
6565 ptr[GId.get(0)] = AddEm(GId.get(0), 37);
6666}
67+
68+ // this name will be mangled
69+ template <typename T>
70+ SYCL_EXTERNAL SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((sycl::ext::oneapi::experimental::nd_range_kernel<1>))
71+ void ff_templated(T *ptr) {
72+
73+ sycl::nd_item<1> Item = sycl::ext::oneapi::this_work_item::get_nd_item<1>();
74+
75+ sycl::id<1> GId = Item.get_global_id();
76+ ptr[GId.get(0)] = PlusEm(GId.get(0), 38);
77+ }
6778)===" ;
6879
6980void test_1 (sycl::queue &Queue, sycl::kernel &Kernel, int seed) {
@@ -125,19 +136,32 @@ int test_build_and_run() {
125136 // Compilation of empty prop list, no devices.
126137 exe_kb kbExe1 = syclex::build (kbSrc);
127138
128- // // Compilation with props and devices
139+ // Compilation with props and devices
129140 std::string log;
130141 std::vector<std::string> flags{" -g" , " -fno-fast-math" ,
131142 " -fsycl-instrument-device-code" };
132143 std::vector<sycl::device> devs = kbSrc.get_devices ();
133144 exe_kb kbExe2 = syclex::build (
134- kbSrc, devs, syclex::properties{syclex::build_options{flags}});
145+ kbSrc, devs,
146+ syclex::properties{syclex::build_options{flags}, syclex::save_log{&log},
147+ syclex::registered_kernel_names{" ff_templated<int>" }});
135148
136- // extern "C" was used, so the name "ff_cp" is not mangled.
149+ // extern "C" was used, so the name "ff_cp" is not mangled and can be used
150+ // directly.
137151 sycl::kernel k = kbExe2.ext_oneapi_get_kernel (" ff_cp" );
138152
153+ // The templated function name will have been mangled. Mapping from original
154+ // name to mangled is not yet supported. So we cannot yet do this:
155+ // sycl::kernel k2 = kbExe2.ext_oneapi_get_kernel("ff_templated<int>");
156+
157+ // Instead, we can TEMPORARILY use the mangled name. Once demangling is
158+ // supported this might no longer work.
159+ sycl::kernel k2 =
160+ kbExe2.ext_oneapi_get_kernel (" _Z26__sycl_kernel_ff_templatedIiEvPT_" );
161+
139162 // Test the kernels.
140- test_1 (q, k, 37 + 5 ); // ff_cp seeds 37. AddEm will add 5 more.
163+ test_1 (q, k, 37 + 5 ); // ff_cp seeds 37. AddEm will add 5 more.
164+ test_1 (q, k2, 38 + 6 ); // ff_templated seeds 38. PlusEm adds 6 more.
141165
142166 return 0 ;
143167}
0 commit comments