From c403cdbb55e07f01220956cab753c157ef388964 Mon Sep 17 00:00:00 2001 From: Bjoern Knafla Date: Wed, 11 Mar 2020 19:20:00 +0000 Subject: [PATCH 1/2] [SYCL][CUDA] LIT cleanup exceptions Do not catch unexpected exceptions to return an error code but allow the exception to terminate the tested program. This will result in useful exception-related error output that is otherwise lost. Do not catch and then ignore an unexpected exception but re-throw it. Explicitly returning error codes. Abort when catching asynchronous exceptions. Signed-off-by: Bjoern Knafla --- sycl/test/aot/accelerator.cpp | 1 + sycl/test/aot/cpu.cpp | 1 + sycl/test/aot/gpu.cpp | 1 + sycl/test/aot/multiple-devices.cpp | 1 + sycl/test/aot/with-llvm-bc.cpp | 1 + sycl/test/basic_tests/accessor/accessor.cpp | 12 +++--- .../basic_tests/buffer/buffer_full_copy.cpp | 17 ++++---- .../basic_tests/buffer/subbuffer_interop.cpp | 3 ++ sycl/test/basic_tests/context.cpp | 1 + sycl/test/basic_tests/device_event.cpp | 3 +- sycl/test/basic_tests/event.cpp | 6 ++- .../basic_tests/event_async_exception.cpp | 2 +- sycl/test/basic_tests/image_api.cpp | 1 + sycl/test/basic_tests/info.cpp | 2 + sycl/test/basic_tests/queue.cpp | 1 + sycl/test/built-ins/nan.cpp | 1 + sycl/test/devicelib/assert-windows.cpp | 1 + sycl/test/devicelib/assert.cpp | 1 + sycl/test/fpga_tests/fpga_queue.cpp | 17 ++++---- sycl/test/hier_par/hier_par_wgscope.cpp | 1 + .../regression/copy-with-unnamed-lambda.cpp | 2 +- .../regression/fp16-with-unnamed-lambda.cpp | 3 +- sycl/test/regression/image_access.cpp | 40 +++++++++---------- sycl/test/scheduler/BasicSchedulerTests.cpp | 2 +- 24 files changed, 70 insertions(+), 51 deletions(-) diff --git a/sycl/test/aot/accelerator.cpp b/sycl/test/aot/accelerator.cpp index c08d4998ff817..e9c42b506b157 100644 --- a/sycl/test/aot/accelerator.cpp +++ b/sycl/test/aot/accelerator.cpp @@ -36,6 +36,7 @@ void simple_vadd(const std::array& VA, const std::array& VB, std::cerr << "Unknown async exception was caught." << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }); cl::sycl::range<1> numOfItems{N}; diff --git a/sycl/test/aot/cpu.cpp b/sycl/test/aot/cpu.cpp index ab1e91de94bda..a043cc391ccc5 100644 --- a/sycl/test/aot/cpu.cpp +++ b/sycl/test/aot/cpu.cpp @@ -36,6 +36,7 @@ void simple_vadd(const std::array& VA, const std::array& VB, std::cerr << "Unknown async exception was caught." << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }); cl::sycl::range<1> numOfItems{N}; diff --git a/sycl/test/aot/gpu.cpp b/sycl/test/aot/gpu.cpp index ee81bba768143..545dda2f560f9 100644 --- a/sycl/test/aot/gpu.cpp +++ b/sycl/test/aot/gpu.cpp @@ -36,6 +36,7 @@ void simple_vadd(const std::array& VA, const std::array& VB, std::cerr << "Unknown async exception was caught." << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }); cl::sycl::range<1> numOfItems{N}; diff --git a/sycl/test/aot/multiple-devices.cpp b/sycl/test/aot/multiple-devices.cpp index d516c5cd443b5..766b3f48a3a7d 100644 --- a/sycl/test/aot/multiple-devices.cpp +++ b/sycl/test/aot/multiple-devices.cpp @@ -88,6 +88,7 @@ void simple_vadd(const std::array& VA, const std::array& VB, std::cerr << "Unknown async exception was caught." << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }); cl::sycl::range<1> numOfItems{N}; diff --git a/sycl/test/aot/with-llvm-bc.cpp b/sycl/test/aot/with-llvm-bc.cpp index afff5546dac3e..cfb29f28b38ce 100644 --- a/sycl/test/aot/with-llvm-bc.cpp +++ b/sycl/test/aot/with-llvm-bc.cpp @@ -40,6 +40,7 @@ void simple_vadd(const std::array& VA, const std::array& VB, std::cerr << "Unknown async exception was caught." << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }); cl::sycl::range<1> numOfItems{N}; diff --git a/sycl/test/basic_tests/accessor/accessor.cpp b/sycl/test/basic_tests/accessor/accessor.cpp index a769df2f63003..e836fad462dea 100644 --- a/sycl/test/basic_tests/accessor/accessor.cpp +++ b/sycl/test/basic_tests/accessor/accessor.cpp @@ -215,7 +215,7 @@ int main() { } catch (cl::sycl::exception e) { std::cout << "SYCL exception caught: " << e.what(); - return 1; + throw; } } @@ -237,7 +237,7 @@ int main() { buf.get_access(); } catch (cl::sycl::exception e) { std::cout << "SYCL exception caught: " << e.what(); - return 1; + throw; } } @@ -349,11 +349,11 @@ int main() { auto host_acc = buf.get_access(); for (int i = 0; i != 3; ++i) - assert(host_acc[i] == 42); + CHECK(host_acc[i] == 42); } catch (cl::sycl::exception e) { std::cout << "SYCL exception caught: " << e.what(); - return 1; + throw; } } @@ -376,8 +376,8 @@ int main() { } assert(data == 399); } catch (sycl::exception e) { - std::cout << "SYCL exception caught: " << e.what(); - return 1; + std::cerr << "SYCL exception caught: " << e.what(); + throw; } } diff --git a/sycl/test/basic_tests/buffer/buffer_full_copy.cpp b/sycl/test/basic_tests/buffer/buffer_full_copy.cpp index f729f8d6d96a4..99f7a2d235dc9 100644 --- a/sycl/test/basic_tests/buffer/buffer_full_copy.cpp +++ b/sycl/test/basic_tests/buffer/buffer_full_copy.cpp @@ -164,24 +164,21 @@ void check_copy_host_to_device(cl::sycl::queue &Queue) { // check that there was no data corruption/loss for (int i = 0; i < size; ++i) { for (int j = 0; j < size; ++j) - assert(expected_res_3[i * size + j] == acc_1[i][j]); + CHECK(expected_res_3[i * size + j] == acc_1[i][j]); } for (int i = 0; i < size / 2; ++i) for (int j = 0; j < size / 2; ++j) - assert(expected_res_4[i * size / 2 + j] == acc_2[i][j]); + CHECK(expected_res_4[i * size / 2 + j] == acc_2[i][j]); } } int main() { - try { - cl::sycl::queue Queue; - check_copy_host_to_device(Queue); - check_copy_device_to_host(Queue); - check_fill(Queue); - } catch (cl::sycl::exception &ex) { - std::cerr << ex.what() << std::endl; - } + // Not catching exceptions to make test fail instead. + cl::sycl::queue Queue; + check_copy_host_to_device(Queue); + check_copy_device_to_host(Queue); + check_fill(Queue); return 0; } diff --git a/sycl/test/basic_tests/buffer/subbuffer_interop.cpp b/sycl/test/basic_tests/buffer/subbuffer_interop.cpp index 092eda64f7df6..93bc45f564b78 100644 --- a/sycl/test/basic_tests/buffer/subbuffer_interop.cpp +++ b/sycl/test/basic_tests/buffer/subbuffer_interop.cpp @@ -105,6 +105,7 @@ int main() { clReleaseProgram(clProgram); } catch (exception &ex) { std::cout << ex.what() << std::endl; + throw; } for (int i = 0; i < NSize; ++i) { @@ -173,6 +174,7 @@ int main() { clReleaseProgram(clProgram); } catch (exception &ex) { std::cout << ex.what() << std::endl; + throw; } for (int i = 0; i < NSize; ++i) { @@ -263,6 +265,7 @@ int main() { clReleaseProgram(clProgram); } catch (exception &ex) { std::cout << ex.what() << std::endl; + throw; } for (int i = 0; i < NSize; ++i) { diff --git a/sycl/test/basic_tests/context.cpp b/sycl/test/basic_tests/context.cpp index 8f40ee2be2845..72bb0eb9c4515 100644 --- a/sycl/test/basic_tests/context.cpp +++ b/sycl/test/basic_tests/context.cpp @@ -19,6 +19,7 @@ int main() { context c; } catch (device_error e) { std::cout << "Failed to create device for context" << std::endl; + throw; } auto devices = device::get_devices(); diff --git a/sycl/test/basic_tests/device_event.cpp b/sycl/test/basic_tests/device_event.cpp index 79231031d8e50..cc49f460ab583 100644 --- a/sycl/test/basic_tests/device_event.cpp +++ b/sycl/test/basic_tests/device_event.cpp @@ -66,6 +66,7 @@ int test_strideN(size_t stride) { std::cout << e.what(); } } + throw "ERROR: Asynchronous exception(s)"; }); buffer out_buf(out_data, range<1>(nElems)); @@ -109,7 +110,7 @@ int test_strideN(size_t stride) { } catch (exception e) { std::cout << "SYCL exception caught: " << e.what(); - return 2; + throw; } return check_results(out_data, stride); diff --git a/sycl/test/basic_tests/event.cpp b/sycl/test/basic_tests/event.cpp index af4f8b1bbaaf3..248562b1c262e 100644 --- a/sycl/test/basic_tests/event.cpp +++ b/sycl/test/basic_tests/event.cpp @@ -16,6 +16,7 @@ int main() { cl::sycl::event e; } catch (cl::sycl::device_error e) { std::cout << "Failed to create device for event" << std::endl; + throw; } try { std::cout << "Try create OpenCL event" << std::endl; @@ -28,11 +29,10 @@ int main() { << ((cl_e.get() == u_e) ? " matches " : " does not match ") << u_e << std::endl; - } else { - std::cout << "Failed to create OpenCL context" << std::endl; } } catch (cl::sycl::device_error e) { std::cout << "Failed to create device for context" << std::endl; + throw; } { @@ -106,4 +106,6 @@ int main() { } } } + + return 0; } diff --git a/sycl/test/basic_tests/event_async_exception.cpp b/sycl/test/basic_tests/event_async_exception.cpp index 0dd803dc5d105..dd8a5ac5e7f3e 100644 --- a/sycl/test/basic_tests/event_async_exception.cpp +++ b/sycl/test/basic_tests/event_async_exception.cpp @@ -33,7 +33,7 @@ int main() { e.wait_and_throw(); return 1; - } catch (runtime_error e) { + } catch (runtime_error expectedException) { return 0; } } diff --git a/sycl/test/basic_tests/image_api.cpp b/sycl/test/basic_tests/image_api.cpp index 4e7976311416d..22fb135897892 100644 --- a/sycl/test/basic_tests/image_api.cpp +++ b/sycl/test/basic_tests/image_api.cpp @@ -145,6 +145,7 @@ int main() { EventRet.wait(); } catch (const s::exception &E) { std::cout << "SYCL exception caught: " << E.what() << std::endl; + throw; } s::float4 Expected{10.f, 20.f, 30.f, 40.f}; diff --git a/sycl/test/basic_tests/info.cpp b/sycl/test/basic_tests/info.cpp index 761c7c52a5cac..303baa897dd70 100644 --- a/sycl/test/basic_tests/info.cpp +++ b/sycl/test/basic_tests/info.cpp @@ -361,4 +361,6 @@ int main() { std::cout << separator << "Platform from context information\n" << separator; auto cplt = ctx.get_info(); print_info(cplt, "Name"); + + return 0; } diff --git a/sycl/test/basic_tests/queue.cpp b/sycl/test/basic_tests/queue.cpp index 50ba658576ee6..005f1e37b09cb 100644 --- a/sycl/test/basic_tests/queue.cpp +++ b/sycl/test/basic_tests/queue.cpp @@ -32,6 +32,7 @@ int main() { } catch (device_error e) { std::cout << "Failed to create device for context" << std::endl; + throw; } auto devices = device::get_devices(); diff --git a/sycl/test/built-ins/nan.cpp b/sycl/test/built-ins/nan.cpp index de1d406c0369d..8d2bf9feb7473 100644 --- a/sycl/test/built-ins/nan.cpp +++ b/sycl/test/built-ins/nan.cpp @@ -58,6 +58,7 @@ int main() { std::cerr << "Unknown async exception was caught." << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }); #ifdef HALF_IS_SUPPORTED if (Queue.get_device().has_extension("cl_khr_fp16")) diff --git a/sycl/test/devicelib/assert-windows.cpp b/sycl/test/devicelib/assert-windows.cpp index fb38520601d98..2fd6c3b2064fa 100644 --- a/sycl/test/devicelib/assert-windows.cpp +++ b/sycl/test/devicelib/assert-windows.cpp @@ -45,6 +45,7 @@ void simple_vadd(const std::array &VA, const std::array &VB, std::cerr << "Unknown async exception was caught." << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }); int shouldCrash = getenv("SHOULD_CRASH") ? 1 : 0; diff --git a/sycl/test/devicelib/assert.cpp b/sycl/test/devicelib/assert.cpp index 9170d2557e283..76e153752facd 100644 --- a/sycl/test/devicelib/assert.cpp +++ b/sycl/test/devicelib/assert.cpp @@ -127,6 +127,7 @@ void simple_vadd(const std::array &VA, const std::array &VB, std::cerr << "Unknown async exception was caught." << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }); device dev = deviceQueue.get_device(); bool unsupported = true; diff --git a/sycl/test/fpga_tests/fpga_queue.cpp b/sycl/test/fpga_tests/fpga_queue.cpp index f9f4a3a72b98b..530e7444dfb25 100644 --- a/sycl/test/fpga_tests/fpga_queue.cpp +++ b/sycl/test/fpga_tests/fpga_queue.cpp @@ -22,16 +22,19 @@ const int maxNumQueues = 256; void GetCLQueue(event sycl_event, std::set& cl_queues) { try { - cl_command_queue cl_queue; - cl_event cl_event = sycl_event.get(); - cl_int error = clGetEventInfo(cl_event, CL_EVENT_COMMAND_QUEUE, - sizeof(cl_queue), &cl_queue, nullptr); - assert(CL_SUCCESS == error && "Failed to obtain queue from OpenCL event"); - - cl_queues.insert(cl_queue); + if (!sycl_event.is_host()) { + cl_command_queue cl_queue; + cl_event cl_event = sycl_event.get(); + cl_int error = clGetEventInfo(cl_event, CL_EVENT_COMMAND_QUEUE, + sizeof(cl_queue), &cl_queue, nullptr); + CHECK(CL_SUCCESS == error && "Failed to obtain queue from OpenCL event"); + + cl_queues.insert(cl_queue); + } } catch (invalid_object_error e) { std::cout << "Failed to get OpenCL queue from SYCL event: " << e.what() << std::endl; + throw; } } diff --git a/sycl/test/hier_par/hier_par_wgscope.cpp b/sycl/test/hier_par/hier_par_wgscope.cpp index ae346a1789547..6369c212cb9bd 100644 --- a/sycl/test/hier_par/hier_par_wgscope.cpp +++ b/sycl/test/hier_par/hier_par_wgscope.cpp @@ -267,6 +267,7 @@ int main() { std::cout << E1.what(); } } + throw "ERROR: Asynchronous exception(s)"; }); std::cout << "Using device: " << Q.get_device().get_info() << "\n"; diff --git a/sycl/test/regression/copy-with-unnamed-lambda.cpp b/sycl/test/regression/copy-with-unnamed-lambda.cpp index 07f427eb6ff03..4ccc7b2b9ba8e 100644 --- a/sycl/test/regression/copy-with-unnamed-lambda.cpp +++ b/sycl/test/regression/copy-with-unnamed-lambda.cpp @@ -2,7 +2,6 @@ // The purpose of this test is to check that the following code can be // successfully compiled #include - #include int main() { @@ -14,6 +13,7 @@ int main() { std::cerr << "Caught async SYCL exception: " << E.what() << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }; cl::sycl::queue Q(AsyncHandler); diff --git a/sycl/test/regression/fp16-with-unnamed-lambda.cpp b/sycl/test/regression/fp16-with-unnamed-lambda.cpp index ead806dcce68a..0ce336b1de39b 100644 --- a/sycl/test/regression/fp16-with-unnamed-lambda.cpp +++ b/sycl/test/regression/fp16-with-unnamed-lambda.cpp @@ -1,7 +1,7 @@ // RUN: %clangxx -fsycl -fsycl-unnamed-lambda %s -o %t.out // RUN: %GPU_RUN_PLACEHOLDER %t.out #include - +#include #include int main() { @@ -13,6 +13,7 @@ int main() { std::cerr << "Caught async SYCL exception: " << E.what() << std::endl; } } + std::abort(); }; cl::sycl::queue Q(AsyncHandler); diff --git a/sycl/test/regression/image_access.cpp b/sycl/test/regression/image_access.cpp index 9c11b787c78f8..1e6b309b15d97 100644 --- a/sycl/test/regression/image_access.cpp +++ b/sycl/test/regression/image_access.cpp @@ -22,29 +22,27 @@ #include int main() { - try { - cl::sycl::range<1> Range(32); - std::vector Data(Range.size() * 4, 0.0f); - cl::sycl::image<1> Image(Data.data(), cl::sycl::image_channel_order::rgba, - cl::sycl::image_channel_type::fp32, Range); - cl::sycl::queue Queue; - - Queue.submit([&](cl::sycl::handler &CGH) { - cl::sycl::accessor - A(Image, CGH); - CGH.single_task([=]() {}); - }); - Queue.wait_and_throw(); - + // Not catching exceptions to make test fail instead. + cl::sycl::range<1> Range(32); + std::vector Data(Range.size() * 4, 0.0f); + cl::sycl::image<1> Image(Data.data(), cl::sycl::image_channel_order::rgba, + cl::sycl::image_channel_type::fp32, Range); + cl::sycl::queue Queue; + + Queue.submit([&](cl::sycl::handler &CGH) { cl::sycl::accessor - A(Image); - } catch (cl::sycl::exception &E) { - std::cout << E.what(); - } + A(Image, CGH); + CGH.single_task([=]() {}); + }); + Queue.wait_and_throw(); + + cl::sycl::accessor + A(Image); + return 0; } diff --git a/sycl/test/scheduler/BasicSchedulerTests.cpp b/sycl/test/scheduler/BasicSchedulerTests.cpp index 1db0529978113..d736705654107 100644 --- a/sycl/test/scheduler/BasicSchedulerTests.cpp +++ b/sycl/test/scheduler/BasicSchedulerTests.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include - #include using namespace cl; @@ -36,6 +35,7 @@ template void runTest(TestFuncT TestFunc) { std::cerr << "Unknown async exception was caught." << std::endl; } } + throw "ERROR: Asynchronous exception(s)"; }); TestFunc(Queue); From 1b78429ca0d27a491411d6d82fd81e999560d312 Mon Sep 17 00:00:00 2001 From: Bjoern Knafla Date: Wed, 11 Mar 2020 20:26:24 +0000 Subject: [PATCH 2/2] [SYCL][CUDA] LIT remove exception catch Allow unexpected exceptions to terminate the LIT test as this outputs extra information. Signed-off-by: Bjoern Knafla --- sycl/test/basic_tests/subdevice.cpp | 239 ++++++++++++++-------------- 1 file changed, 118 insertions(+), 121 deletions(-) diff --git a/sycl/test/basic_tests/subdevice.cpp b/sycl/test/basic_tests/subdevice.cpp index bd4e237f80347..3997db5c436fe 100644 --- a/sycl/test/basic_tests/subdevice.cpp +++ b/sycl/test/basic_tests/subdevice.cpp @@ -12,138 +12,135 @@ // //===----------------------------------------------------------------------===// +#include "../helpers.hpp" #include #include -#include #include #include using namespace cl::sycl; int main() { - try { - auto devices = device::get_devices(); - for (const auto &dev : devices) { - // TODO: implement subdevices creation for host device - if (dev.is_host()) - continue; - - assert(dev.get_info() == - info::partition_property::no_partition); - - size_t MaxSubDevices = - dev.get_info(); - if (MaxSubDevices == 0) - continue; - - try { - auto SubDevicesEq = - dev.create_sub_devices( - 1); - assert(SubDevicesEq.size() == MaxSubDevices && - "Requested 1 compute unit in each subdevice, expected maximum " - "number of subdevices in output"); - std::cout << "Created " << SubDevicesEq.size() - << " subdevices using equal partition scheme" << std::endl; - - assert( - SubDevicesEq[0].get_info() == + // Not catching exceptions to make test fail instead. + + auto devices = device::get_devices(); + for (const auto &dev : devices) { + // TODO: implement subdevices creation for host device + if (dev.is_host()) + continue; + + CHECK(dev.get_info() == + info::partition_property::no_partition); + + size_t MaxSubDevices = + dev.get_info(); + if (MaxSubDevices == 0) + continue; + + try { + auto SubDevicesEq = + dev.create_sub_devices( + 1); + CHECK(SubDevicesEq.size() == MaxSubDevices && + "Requested 1 compute unit in each subdevice, expected maximum " + "number of subdevices in output"); + std::cout << "Created " << SubDevicesEq.size() + << " subdevices using equal partition scheme" << std::endl; + + CHECK(SubDevicesEq[0].get_info() == info::partition_property::partition_equally); - assert(SubDevicesEq[0].get_info().get() == - dev.get()); - } catch (feature_not_supported) { - // okay skip it - } - - try { - vector_class Counts(MaxSubDevices, 1); - auto SubDevicesByCount = dev.create_sub_devices< - info::partition_property::partition_by_counts>(Counts); - assert(SubDevicesByCount.size() == MaxSubDevices && - "Maximum number of subdevices was requested with 1 compute unit " - "on each"); - std::cout << "Created " << SubDevicesByCount.size() - << " subdevices using partition by counts scheme." - << std::endl; - assert(SubDevicesByCount[0] - .get_info() == - info::partition_property::partition_by_counts); - } catch (feature_not_supported) { - // okay skip it - } - - try { - auto SubDevicesDomainNuma = dev.create_sub_devices< - info::partition_property::partition_by_affinity_domain>( - info::partition_affinity_domain::numa); - std::cout - << "Created " << SubDevicesDomainNuma.size() - << " subdevices using partition by numa affinity domain scheme." - << std::endl; - } catch (feature_not_supported) { - // okay skip it - } - - try { - auto SubDevicesDomainL4 = dev.create_sub_devices< - info::partition_property::partition_by_affinity_domain>( - info::partition_affinity_domain::L4_cache); - std::cout << "Created " << SubDevicesDomainL4.size() - << " subdevices using partition by L4 cache domain scheme." - << std::endl; - } catch (feature_not_supported) { - // okay skip it - } - - try { - auto SubDevicesDomainL3 = dev.create_sub_devices< - info::partition_property::partition_by_affinity_domain>( - info::partition_affinity_domain::L3_cache); - std::cout << "Created " << SubDevicesDomainL3.size() - << " subdevices using partition by L3 cache domain scheme." - << std::endl; - } catch (feature_not_supported) { - // okay skip it - } - - try { - auto SubDevicesDomainL2 = dev.create_sub_devices< - info::partition_property::partition_by_affinity_domain>( - info::partition_affinity_domain::L2_cache); - std::cout << "Created " << SubDevicesDomainL2.size() - << " subdevices using partition by L2 cache domain scheme." - << std::endl; - } catch (feature_not_supported) { - // okay skip it - } - - try { - auto SubDevicesDomainL1 = dev.create_sub_devices< - info::partition_property::partition_by_affinity_domain>( - info::partition_affinity_domain::L1_cache); - std::cout << "Created " << SubDevicesDomainL1.size() - << " subdevices using partition by L1 cache domain scheme." - << std::endl; - } catch (feature_not_supported) { - // okay skip it - } - - try { - auto SubDevicesDomainNextPart = dev.create_sub_devices< - info::partition_property::partition_by_affinity_domain>( - info::partition_affinity_domain::next_partitionable); - std::cout << "Created " << SubDevicesDomainNextPart.size() - << " subdevices using partition by next partitionable " - "domain scheme." - << std::endl; - } catch (feature_not_supported) { - // okay skip it - } + CHECK(SubDevicesEq[0].get_info().get() == + dev.get()); + } catch (feature_not_supported) { + // okay skip it + } + + try { + vector_class Counts(MaxSubDevices, 1); + auto SubDevicesByCount = dev.create_sub_devices< + info::partition_property::partition_by_counts>(Counts); + CHECK(SubDevicesByCount.size() == MaxSubDevices && + "Maximum number of subdevices was requested with 1 compute unit " + "on each"); + std::cout << "Created " << SubDevicesByCount.size() + << " subdevices using partition by counts scheme." + << std::endl; + CHECK(SubDevicesByCount[0] + .get_info() == + info::partition_property::partition_by_counts); + } catch (feature_not_supported) { + // okay skip it + } + + try { + auto SubDevicesDomainNuma = dev.create_sub_devices< + info::partition_property::partition_by_affinity_domain>( + info::partition_affinity_domain::numa); + std::cout + << "Created " << SubDevicesDomainNuma.size() + << " subdevices using partition by numa affinity domain scheme." + << std::endl; + } catch (feature_not_supported) { + // okay skip it + } + + try { + auto SubDevicesDomainL4 = dev.create_sub_devices< + info::partition_property::partition_by_affinity_domain>( + info::partition_affinity_domain::L4_cache); + std::cout << "Created " << SubDevicesDomainL4.size() + << " subdevices using partition by L4 cache domain scheme." + << std::endl; + } catch (feature_not_supported) { + // okay skip it + } + + try { + auto SubDevicesDomainL3 = dev.create_sub_devices< + info::partition_property::partition_by_affinity_domain>( + info::partition_affinity_domain::L3_cache); + std::cout << "Created " << SubDevicesDomainL3.size() + << " subdevices using partition by L3 cache domain scheme." + << std::endl; + } catch (feature_not_supported) { + // okay skip it + } + + try { + auto SubDevicesDomainL2 = dev.create_sub_devices< + info::partition_property::partition_by_affinity_domain>( + info::partition_affinity_domain::L2_cache); + std::cout << "Created " << SubDevicesDomainL2.size() + << " subdevices using partition by L2 cache domain scheme." + << std::endl; + } catch (feature_not_supported) { + // okay skip it + } + + try { + auto SubDevicesDomainL1 = dev.create_sub_devices< + info::partition_property::partition_by_affinity_domain>( + info::partition_affinity_domain::L1_cache); + std::cout << "Created " << SubDevicesDomainL1.size() + << " subdevices using partition by L1 cache domain scheme." + << std::endl; + } catch (feature_not_supported) { + // okay skip it + } + + try { + auto SubDevicesDomainNextPart = dev.create_sub_devices< + info::partition_property::partition_by_affinity_domain>( + info::partition_affinity_domain::next_partitionable); + std::cout << "Created " << SubDevicesDomainNextPart.size() + << " subdevices using partition by next partitionable " + "domain scheme." + << std::endl; + } catch (feature_not_supported) { + // okay skip it } - } catch (exception e) { - std::cout << "SYCL exception caught: " << e.what() << std::endl; - return 1; } + return 0; }