1616// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/17255
1717
1818// RUN: %{build} -o %t.out
19- // RUN: %{run} %t.out 1
20- // RUN: %{l0_leak_check} %{run} %t.out 1
19+ // RUN: %{run} %t.out
20+ // RUN: %{l0_leak_check} %{run} %t.out
2121
2222#include < sycl/detail/core.hpp>
2323#include < sycl/kernel_bundle.hpp>
@@ -171,6 +171,8 @@ void ff_cp(int *ptr) {
171171}
172172)===" ;
173173
174+ namespace syclex = sycl::ext::oneapi::experimental;
175+
174176void run_1 (sycl::queue &Queue, sycl::kernel &Kernel, int seed) {
175177 constexpr int Range = 10 ;
176178 int *usmPtr = sycl::malloc_shared<int >(Range, Queue);
@@ -232,24 +234,13 @@ void run_2(sycl::queue &Queue, sycl::kernel &Kernel, bool ESIMD, float seed) {
232234 sycl::free (C, Queue);
233235}
234236
235- int test_build_and_run () {
237+ int test_build_and_run (sycl::queue q ) {
236238 namespace syclex = sycl::ext::oneapi::experimental;
237239 using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
238240 using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
239241
240- sycl::queue q;
241242 sycl::context ctx = q.get_context ();
242243
243- bool ok =
244- q.get_device ().ext_oneapi_can_compile (syclex::source_language::sycl);
245- if (!ok) {
246- std::cout << " Apparently this device does not support `sycl` source kernel "
247- " bundle extension: "
248- << q.get_device ().get_info <sycl::info::device::name>()
249- << std::endl;
250- return -1 ;
251- }
252-
253244 // Create from source.
254245 syclex::include_files incFiles{" intermediate/AddEm.h" , AddEmH};
255246 incFiles.add (" intermediate/PlusEm.h" , PlusEmH);
@@ -316,74 +307,13 @@ int test_build_and_run() {
316307 return 0 ;
317308}
318309
319- int test_lifetimes ( ) {
310+ int test_device_code_split (sycl::queue q ) {
320311 namespace syclex = sycl::ext::oneapi::experimental;
321312 using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
322313 using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
323314
324- sycl::queue q;
325315 sycl::context ctx = q.get_context ();
326316
327- bool ok =
328- q.get_device ().ext_oneapi_can_compile (syclex::source_language::sycl);
329- if (!ok) {
330- std::cout << " Apparently this device does not support `sycl` source kernel "
331- " bundle extension: "
332- << q.get_device ().get_info <sycl::info::device::name>()
333- << std::endl;
334- return -1 ;
335- }
336-
337- source_kb kbSrc = syclex::create_kernel_bundle_from_source (
338- ctx, syclex::source_language::sycl, SYCLSource2);
339-
340- exe_kb kbExe1 = syclex::build (kbSrc);
341- assert (sycl::get_kernel_ids ().size () == 1 );
342-
343- {
344- exe_kb kbExe2 = syclex::build (kbSrc);
345- assert (sycl::get_kernel_ids ().size () == 2 );
346- // kbExe2 goes out of scope; its kernels are removed from program mananager.
347- }
348- assert (sycl::get_kernel_ids ().size () == 1 );
349-
350- {
351- std::unique_ptr<sycl::kernel> kPtr ;
352- {
353- exe_kb kbExe3 = syclex::build (kbSrc);
354- assert (sycl::get_kernel_ids ().size () == 2 );
355-
356- sycl::kernel k = kbExe3.ext_oneapi_get_kernel (" vec_add" );
357- kPtr = std::make_unique<sycl::kernel>(k);
358- // kbExe3 goes out of scope, but the kernel keeps the underlying
359- // impl-object alive
360- }
361- assert (sycl::get_kernel_ids ().size () == 2 );
362- // kPtr goes out of scope, freeing the kernel and its bundle
363- }
364- assert (sycl::get_kernel_ids ().size () == 1 );
365-
366- return 0 ;
367- }
368-
369- int test_device_code_split () {
370- namespace syclex = sycl::ext::oneapi::experimental;
371- using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
372- using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
373-
374- sycl::queue q;
375- sycl::context ctx = q.get_context ();
376-
377- bool ok =
378- q.get_device ().ext_oneapi_can_compile (syclex::source_language::sycl);
379- if (!ok) {
380- std::cout << " Apparently this device does not support `sycl` source kernel "
381- " bundle extension: "
382- << q.get_device ().get_info <sycl::info::device::name>()
383- << std::endl;
384- return -1 ;
385- }
386-
387317 source_kb kbSrc = syclex::create_kernel_bundle_from_source (
388318 ctx, syclex::source_language::sycl, DeviceCodeSplitSource);
389319
@@ -418,24 +348,13 @@ int test_device_code_split() {
418348 return 0 ;
419349}
420350
421- int test_device_libraries () {
351+ int test_device_libraries (sycl::queue q ) {
422352 namespace syclex = sycl::ext::oneapi::experimental;
423353 using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
424354 using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
425355
426- sycl::queue q;
427356 sycl::context ctx = q.get_context ();
428357
429- bool ok =
430- q.get_device ().ext_oneapi_can_compile (syclex::source_language::sycl);
431- if (!ok) {
432- std::cout << " Apparently this device does not support `sycl` source kernel "
433- " bundle extension: "
434- << q.get_device ().get_info <sycl::info::device::name>()
435- << std::endl;
436- return -1 ;
437- }
438-
439358 source_kb kbSrc = syclex::create_kernel_bundle_from_source (
440359 ctx, syclex::source_language::sycl, DeviceLibrariesSource);
441360 exe_kb kbExe = syclex::build (kbSrc);
@@ -465,12 +384,11 @@ int test_device_libraries() {
465384 return 0 ;
466385}
467386
468- int test_esimd () {
387+ int test_esimd (sycl::queue q ) {
469388 namespace syclex = sycl::ext::oneapi::experimental;
470389 using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
471390 using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
472391
473- sycl::queue q;
474392 sycl::context ctx = q.get_context ();
475393
476394 if (!q.get_device ().has (sycl::aspect::ext_intel_esimd)) {
@@ -480,16 +398,6 @@ int test_esimd() {
480398 return 0 ;
481399 }
482400
483- bool ok =
484- q.get_device ().ext_oneapi_can_compile (syclex::source_language::sycl);
485- if (!ok) {
486- std::cout << " Apparently this device does not support `sycl` source kernel "
487- " bundle extension: "
488- << q.get_device ().get_info <sycl::info::device::name>()
489- << std::endl;
490- return -1 ;
491- }
492-
493401 std::string log;
494402
495403 source_kb kbSrc = syclex::create_kernel_bundle_from_source (
@@ -536,23 +444,12 @@ int test_esimd() {
536444 return 0 ;
537445}
538446
539- int test_unsupported_options () {
447+ int test_unsupported_options (sycl::queue q ) {
540448 namespace syclex = sycl::ext::oneapi::experimental;
541449 using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
542450
543- sycl::queue q;
544451 sycl::context ctx = q.get_context ();
545452
546- bool ok =
547- q.get_device ().ext_oneapi_can_compile (syclex::source_language::sycl);
548- if (!ok) {
549- std::cout << " Apparently this device does not support `sycl` source kernel "
550- " bundle extension: "
551- << q.get_device ().get_info <sycl::info::device::name>()
552- << std::endl;
553- return -1 ;
554- }
555-
556453 source_kb kbSrc = syclex::create_kernel_bundle_from_source (
557454 ctx, syclex::source_language::sycl, " " );
558455 std::vector<sycl::device> devs = kbSrc.get_devices ();
@@ -578,20 +475,13 @@ int test_unsupported_options() {
578475 return 0 ;
579476}
580477
581- int test_error () {
478+ int test_error (sycl::queue q ) {
582479 namespace syclex = sycl::ext::oneapi::experimental;
583480 using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
584481 using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
585482
586- sycl::queue q;
587483 sycl::context ctx = q.get_context ();
588484
589- bool ok =
590- q.get_device ().ext_oneapi_can_compile (syclex::source_language::sycl);
591- if (!ok) {
592- return 0 ;
593- }
594-
595485 source_kb kbSrc = syclex::create_kernel_bundle_from_source (
596486 ctx, syclex::source_language::sycl, BadSource);
597487 try {
@@ -607,19 +497,13 @@ int test_error() {
607497 return 0 ;
608498}
609499
610- int test_warning () {
500+ int test_warning (sycl::queue q ) {
611501 namespace syclex = sycl::ext::oneapi::experimental;
612502 using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
613503 using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
614504
615- sycl::queue q;
616505 sycl::context ctx = q.get_context ();
617506
618- bool ok =
619- q.get_device ().ext_oneapi_can_compile (syclex::source_language::sycl);
620- if (!ok) {
621- return 0 ;
622- }
623507 std::string build_log;
624508
625509 source_kb kbSrc = syclex::create_kernel_bundle_from_source (
@@ -633,12 +517,33 @@ int test_warning() {
633517 return 0 ;
634518}
635519
636- int main (int argc, char **) {
520+ int test_no_visible_ids (sycl::queue q) {
521+ using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
522+ using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
523+ sycl::context ctx = q.get_context ();
524+ source_kb kbSrc = syclex::create_kernel_bundle_from_source (
525+ ctx, syclex::source_language::sycl, SYCLSource2);
526+ exe_kb kbExe = syclex::build (kbSrc);
527+ assert (kbExe.get_kernel_ids ().size () == 0 && " Visible RTC kernel ids" );
528+ assert (sycl::get_kernel_ids ().size () == 0 && " Visible RTC kernel ids" );
529+ return 0 ;
530+ }
531+
532+ int main () {
637533#ifdef SYCL_EXT_ONEAPI_KERNEL_COMPILER
638- int optional_tests = (argc > 1 ) ? test_warning () : 0 ;
639- return test_build_and_run () || test_lifetimes () || test_device_code_split () ||
640- test_device_libraries () || test_esimd () ||
641- test_unsupported_options () || test_error () || optional_tests;
534+ sycl::queue q;
535+ sycl::context ctx = q.get_context ();
536+
537+ bool ok =
538+ q.get_device ().ext_oneapi_can_compile (syclex::source_language::sycl);
539+ if (!ok) {
540+ return -1 ;
541+ }
542+
543+ return test_build_and_run (q) || test_device_code_split (q) ||
544+ test_device_libraries (q) || test_esimd (q) ||
545+ test_unsupported_options (q) || test_error (q) ||
546+ test_no_visible_ids (q) || test_warning (q);
642547#else
643548 static_assert (false , " Kernel Compiler feature test macro undefined" );
644549#endif
0 commit comments