diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 3db9df8b52337..d14d039d32ae9 100755 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -146,11 +146,8 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, } if (Kind == alloc::shared && !DevImpl->has(sycl::aspect::usm_shared_allocations)) { - // TODO:: Throw an exception to conform with the specification. - // Note that many tests will have to be changed to conform with the spec - // before completing this. That is, the tests will now have to expect - // exceptions as a result of failed allocations in addition to nullptr - // being returned depending on the reason why allocation failed. + throw sycl::exception(sycl::errc::feature_not_supported, + "Device does not support USM shared allocations!"); } void *RetVal = nullptr; if (Size == 0) diff --git a/sycl/test-e2e/Annotated_arg_ptr/annotated_arg.cpp b/sycl/test-e2e/Annotated_arg_ptr/annotated_arg.cpp index 8fad623752873..e387080c0b052 100644 --- a/sycl/test-e2e/Annotated_arg_ptr/annotated_arg.cpp +++ b/sycl/test-e2e/Annotated_arg_ptr/annotated_arg.cpp @@ -75,6 +75,9 @@ MyStruct operator<<(const MyStruct &lhs, const MyStruct &rhs) { int main() { queue Q; + if (!Q.get_device().has(aspect::usm_shared_allocations)) { + return 0; + } auto *a = malloc_shared(8, Q); auto a_ptr = annotated_arg{a}; diff --git a/sycl/test-e2e/Annotated_arg_ptr/annotated_ptr.cpp b/sycl/test-e2e/Annotated_arg_ptr/annotated_ptr.cpp index 7e4a35d09b994..81a1442d23829 100644 --- a/sycl/test-e2e/Annotated_arg_ptr/annotated_ptr.cpp +++ b/sycl/test-e2e/Annotated_arg_ptr/annotated_ptr.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out // diff --git a/sycl/test-e2e/Annotated_usm/annotated_usm_kind.cpp b/sycl/test-e2e/Annotated_usm/annotated_usm_kind.cpp index 812a0bb115737..bccd8b9cf072c 100644 --- a/sycl/test-e2e/Annotated_usm/annotated_usm_kind.cpp +++ b/sycl/test-e2e/Annotated_usm/annotated_usm_kind.cpp @@ -125,25 +125,27 @@ template void testUsmKind(sycl::queue &q) { [&]() { return ATHost(1, q); }, [&]() { return ATHost(1, Ctx); }, [&]() { return ATAnnotated(1, dev, Ctx, alloc::host); }}); - CheckUsmKindAll( - alloc::shared, - std::tuple{ - [&]() { return MShared(q); }, [&]() { return MShared(dev, Ctx); }, - [&]() { return MAnnotated(dev, Ctx, alloc::shared); }, - [&]() { return MAnnotated(dev, Ctx, properties{usm_kind_shared}); }, - [&]() { return AShared(1, q); }, - [&]() { return AShared(1, dev, Ctx); }, - [&]() { return AAnnotated(1, dev, Ctx, alloc::shared); }, - [&]() { return TShared(q); }, [&]() { return TShared(dev, Ctx); }, - [&]() { return TAnnotated(dev, Ctx, alloc::shared); }, - [&]() { return TAnnotated(dev, Ctx, properties{usm_kind_shared}); }, - [&]() { return ATShared(1, q); }, - [&]() { return ATShared(1, dev, Ctx); }, - [&]() { return ATAnnotated(1, dev, Ctx, alloc::shared); }}); + if (q.get_device().has(sycl::aspect::usm_shared_allocations)) { + CheckUsmKindAll( + alloc::shared, + std::tuple{ + [&]() { return MShared(q); }, [&]() { return MShared(dev, Ctx); }, + [&]() { return MAnnotated(dev, Ctx, alloc::shared); }, + [&]() { return MAnnotated(dev, Ctx, properties{usm_kind_shared}); }, + [&]() { return AShared(1, q); }, + [&]() { return AShared(1, dev, Ctx); }, + [&]() { return AAnnotated(1, dev, Ctx, alloc::shared); }, + [&]() { return TShared(q); }, [&]() { return TShared(dev, Ctx); }, + [&]() { return TAnnotated(dev, Ctx, alloc::shared); }, + [&]() { return TAnnotated(dev, Ctx, properties{usm_kind_shared}); }, + [&]() { return ATShared(1, q); }, + [&]() { return ATShared(1, dev, Ctx); }, + [&]() { return ATAnnotated(1, dev, Ctx, alloc::shared); }}); + } } int main() { sycl::queue q; testUsmKind(q); return 0; -} \ No newline at end of file +} diff --git a/sycl/test-e2e/Basic/group_local_memory.cpp b/sycl/test-e2e/Basic/group_local_memory.cpp index 8185378071c75..52243b7f780f3 100644 --- a/sycl/test-e2e/Basic/group_local_memory.cpp +++ b/sycl/test-e2e/Basic/group_local_memory.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Basic/large-range.cpp b/sycl/test-e2e/Basic/large-range.cpp index 354276065a739..7e320b89c2dc9 100644 --- a/sycl/test-e2e/Basic/large-range.cpp +++ b/sycl/test-e2e/Basic/large-range.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocation // Temporarily add explicit '-O2' to avoid GPU hang issue with O0 optimization. // RUN: %{build} -fno-sycl-id-queries-fit-in-int -O2 -o %t.out // RUN: env SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE=1 %{run} %t.out diff --git a/sycl/test-e2e/Basic/span.cpp b/sycl/test-e2e/Basic/span.cpp index 43d16ff4d16d6..c90c9b7631854 100644 --- a/sycl/test-e2e/Basic/span.cpp +++ b/sycl/test-e2e/Basic/span.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out // diff --git a/sycl/test-e2e/Basic/wrapped_usm_pointers.cpp b/sycl/test-e2e/Basic/wrapped_usm_pointers.cpp index 7b81493db6dce..14f2414ab8461 100644 --- a/sycl/test-e2e/Basic/wrapped_usm_pointers.cpp +++ b/sycl/test-e2e/Basic/wrapped_usm_pointers.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Complex/sycl_complex_math_test.cpp b/sycl/test-e2e/Complex/sycl_complex_math_test.cpp index 9bb5122ffc7f7..ff5d6714c9704 100644 --- a/sycl/test-e2e/Complex/sycl_complex_math_test.cpp +++ b/sycl/test-e2e/Complex/sycl_complex_math_test.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // DEFINE: %{mathflags} = %if cl_options %{/clang:-fno-fast-math%} %else %{-fno-fast-math%} // RUN: %{build} -fsycl-device-code-split=per_kernel %{mathflags} -o %t.out diff --git a/sycl/test-e2e/Complex/sycl_complex_operator_test.cpp b/sycl/test-e2e/Complex/sycl_complex_operator_test.cpp index ed68332f60bdd..fb4df0db745af 100644 --- a/sycl/test-e2e/Complex/sycl_complex_operator_test.cpp +++ b/sycl/test-e2e/Complex/sycl_complex_operator_test.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -fsycl-device-code-split=per_kernel -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Complex/sycl_complex_pow_test.cpp b/sycl/test-e2e/Complex/sycl_complex_pow_test.cpp index c8555687eb49b..41764342d3c98 100644 --- a/sycl/test-e2e/Complex/sycl_complex_pow_test.cpp +++ b/sycl/test-e2e/Complex/sycl_complex_pow_test.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // DEFINE: %{mathflags} = %if cl_options %{/clang:-fno-fast-math%} %else %{-fno-fast-math%} // RUN: %{build} -fsycl-device-code-split=per_kernel %{mathflags} -o %t.out diff --git a/sycl/test-e2e/Complex/sycl_complex_stream_test.cpp b/sycl/test-e2e/Complex/sycl_complex_stream_test.cpp index b9cb8c519366d..c4a45ba4e5884 100644 --- a/sycl/test-e2e/Complex/sycl_complex_stream_test.cpp +++ b/sycl/test-e2e/Complex/sycl_complex_stream_test.cpp @@ -7,6 +7,8 @@ template struct test_sycl_stream_operator { bool operator()(sycl::queue &Q, cmplx init) { + if (!Q.get_device().has(sycl::aspect::usm_shared_allocations)) + return true; auto *cplx_out = sycl::malloc_shared>(1, Q); cplx_out[0] = experimental::complex(init.re, init.im); diff --git a/sycl/test-e2e/DiscardEvents/discard_events_mixed_calls.cpp b/sycl/test-e2e/DiscardEvents/discard_events_mixed_calls.cpp index 8206ea5b449c3..9d8b8f1935c2e 100644 --- a/sycl/test-e2e/DiscardEvents/discard_events_mixed_calls.cpp +++ b/sycl/test-e2e/DiscardEvents/discard_events_mixed_calls.cpp @@ -37,6 +37,8 @@ static constexpr int MAX_ITER_NUM2 = 10; void TestHelper(sycl::queue Q, const std::function Range, int *Harray, sycl::buffer Buf)> &Function) { + if (!Q.get_device().has(aspect::usm_shared_allocations)) + return; int *Harray = sycl::malloc_shared(BUFFER_SIZE, Q); assert(Harray != nullptr); for (size_t i = 0; i < BUFFER_SIZE; ++i) { @@ -113,36 +115,36 @@ void RunTest_USM_Accessor(sycl::queue Q) { } void RunTest_Accessor_USM(sycl::queue Q) { - TestHelper( - Q, [&](sycl::range<1> Range, int *Harray, sycl::buffer Buf) { - { - sycl::host_accessor HostAcc(Buf); - for (size_t i = 0; i < BUFFER_SIZE; ++i) { - HostAcc[i] = 0; - } - } - - for (int i = 0; i < MAX_ITER_NUM1; ++i) - IfTrueIncrementBufferAndUSM(Q, Range, Harray, Buf, (i)); - - for (int i = 0; i < MAX_ITER_NUM2; ++i) - IfTrueIncrementUSM(Q, Range, Harray, (MAX_ITER_NUM1 + i)); - - Q.wait(); - - // check results - for (size_t i = 0; i < BUFFER_SIZE; ++i) { - int expected = MAX_ITER_NUM1 + MAX_ITER_NUM2; - assert(Harray[i] == expected); - } - { - sycl::host_accessor HostAcc(Buf, sycl::read_only); - for (size_t i = 0; i < BUFFER_SIZE; ++i) { - int expected = MAX_ITER_NUM1; - assert(HostAcc[i] == expected); - } - } - }); + TestHelper(Q, + [&](sycl::range<1> Range, int *Harray, sycl::buffer Buf) { + { + sycl::host_accessor HostAcc(Buf); + for (size_t i = 0; i < BUFFER_SIZE; ++i) { + HostAcc[i] = 0; + } + } + + for (int i = 0; i < MAX_ITER_NUM1; ++i) + IfTrueIncrementBufferAndUSM(Q, Range, Harray, Buf, (i)); + + for (int i = 0; i < MAX_ITER_NUM2; ++i) + IfTrueIncrementUSM(Q, Range, Harray, (MAX_ITER_NUM1 + i)); + + Q.wait(); + + // check results + for (size_t i = 0; i < BUFFER_SIZE; ++i) { + int expected = MAX_ITER_NUM1 + MAX_ITER_NUM2; + assert(Harray[i] == expected); + } + { + sycl::host_accessor HostAcc(Buf, sycl::read_only); + for (size_t i = 0; i < BUFFER_SIZE; ++i) { + int expected = MAX_ITER_NUM1; + assert(HostAcc[i] == expected); + } + } + }); } void RunTest_Mixed(sycl::queue Q) { diff --git a/sycl/test-e2e/DiscardEvents/discard_events_usm.cpp b/sycl/test-e2e/DiscardEvents/discard_events_usm.cpp index 11288d6620bfd..d85cc5ab4e2c8 100644 --- a/sycl/test-e2e/DiscardEvents/discard_events_usm.cpp +++ b/sycl/test-e2e/DiscardEvents/discard_events_usm.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: env SYCL_PI_TRACE=2 %{run} %t.out &> %t.txt ; FileCheck %s --input-file %t.txt diff --git a/sycl/test-e2e/DiscardEvents/discard_events_usm_ooo_queue.cpp b/sycl/test-e2e/DiscardEvents/discard_events_usm_ooo_queue.cpp index cfe72db0c1232..98f1c1f256986 100644 --- a/sycl/test-e2e/DiscardEvents/discard_events_usm_ooo_queue.cpp +++ b/sycl/test-e2e/DiscardEvents/discard_events_usm_ooo_queue.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: env SYCL_PI_TRACE=2 %{run} %t.out &> %t.txt ; FileCheck %s --input-file %t.txt diff --git a/sycl/test-e2e/DiscardEvents/invalid_event.cpp b/sycl/test-e2e/DiscardEvents/invalid_event.cpp index 273e74afb6c25..6c883e9a9274b 100644 --- a/sycl/test-e2e/DiscardEvents/invalid_event.cpp +++ b/sycl/test-e2e/DiscardEvents/invalid_event.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // Same hang as on Basic/barrier_order.cpp tracked in // https://github.com/intel/llvm/issues/7330. // UNSUPPORTED: opencl && gpu diff --git a/sycl/test-e2e/GroupAlgorithm/exclusive_scan_over_group.cpp b/sycl/test-e2e/GroupAlgorithm/exclusive_scan_over_group.cpp index 6411131ef33ff..6e8e540a58d54 100644 --- a/sycl/test-e2e/GroupAlgorithm/exclusive_scan_over_group.cpp +++ b/sycl/test-e2e/GroupAlgorithm/exclusive_scan_over_group.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // CPU and ACC not yet supported: // Unsupported SPIR-V module SPIRV module requires unsupported capability 6400 // REQUIRES: gpu diff --git a/sycl/test-e2e/GroupAlgorithm/root_group.cpp b/sycl/test-e2e/GroupAlgorithm/root_group.cpp index ba0c49fa68bf7..81c196a6d16e0 100644 --- a/sycl/test-e2e/GroupAlgorithm/root_group.cpp +++ b/sycl/test-e2e/GroupAlgorithm/root_group.cpp @@ -33,6 +33,8 @@ void testQueriesAndProperties() { void testRootGroup() { sycl::queue q; + if (!q.get_device().has(sycl::aspect::usm_shared_allocations)) + return; const auto bundle = sycl::get_kernel_bundle(q.get_context()); const auto kernel = bundle.get_kernel(); @@ -66,6 +68,8 @@ void testRootGroup() { void testRootGroupFunctions() { sycl::queue q; + if (!q.get_device().has(sycl::aspect::usm_shared_allocations)) + return; const auto bundle = sycl::get_kernel_bundle(q.get_context()); const auto kernel = bundle.get_kernel(); diff --git a/sycl/test-e2e/InOrderEventsExt/get_last_event.cpp b/sycl/test-e2e/InOrderEventsExt/get_last_event.cpp index 3393202b5a370..aeb4ab44acb49 100644 --- a/sycl/test-e2e/InOrderEventsExt/get_last_event.cpp +++ b/sycl/test-e2e/InOrderEventsExt/get_last_event.cpp @@ -34,7 +34,8 @@ int main() { Failed += Check(Q, "host_task", [&]() { return Q.submit([&](sycl::handler &CGH) { CGH.host_task([]() {}); }); }); - + if (!Q.get_device().has(sycl::aspect::usm_shared_allocations)) + return Failed; constexpr size_t N = 64; int *Data1 = sycl::malloc_shared(N, Q); int *Data2 = sycl::malloc_shared(N, Q); diff --git a/sycl/test-e2e/InOrderEventsExt/set_external_event.cpp b/sycl/test-e2e/InOrderEventsExt/set_external_event.cpp index 45e5815606dbe..927a7d43ca05b 100644 --- a/sycl/test-e2e/InOrderEventsExt/set_external_event.cpp +++ b/sycl/test-e2e/InOrderEventsExt/set_external_event.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/KernelAndProgram/disable-caching.cpp b/sycl/test-e2e/KernelAndProgram/disable-caching.cpp index 4276efe36366f..4a5851b989d25 100644 --- a/sycl/test-e2e/KernelAndProgram/disable-caching.cpp +++ b/sycl/test-e2e/KernelAndProgram/disable-caching.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // This test ensures created program/kernels are not retained // if and only if caching is disabled. diff --git a/sycl/test-e2e/KernelFusion/sync_two_queues_event_dep.cpp b/sycl/test-e2e/KernelFusion/sync_two_queues_event_dep.cpp index 38286c48b8a0f..eb14704700aac 100644 --- a/sycl/test-e2e/KernelFusion/sync_two_queues_event_dep.cpp +++ b/sycl/test-e2e/KernelFusion/sync_two_queues_event_dep.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // For this test, complete_fusion must be supported. // RUN: %{build} -o %t.out // RUN: env SYCL_RT_WARNING_LEVEL=1 %{run} %t.out 2>&1 | FileCheck %s diff --git a/sycl/test-e2e/KernelFusion/sync_usm_mem_op.cpp b/sycl/test-e2e/KernelFusion/sync_usm_mem_op.cpp index 0e6bc288812fd..3be21c7345447 100644 --- a/sycl/test-e2e/KernelFusion/sync_usm_mem_op.cpp +++ b/sycl/test-e2e/KernelFusion/sync_usm_mem_op.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -fsycl-embed-ir -o %t.out // RUN: env SYCL_RT_WARNING_LEVEL=1 %{run} %t.out 2>&1 | FileCheck %s diff --git a/sycl/test-e2e/Reduction/reduction_internal.cpp b/sycl/test-e2e/Reduction/reduction_internal.cpp index 57947a25176e1..a9de7021a4879 100644 --- a/sycl/test-e2e/Reduction/reduction_internal.cpp +++ b/sycl/test-e2e/Reduction/reduction_internal.cpp @@ -80,7 +80,8 @@ static void test(RedStorage &Storage, RangeTy Range) { cgh, Range, ext::oneapi::experimental::empty_properties_t{}, RedSycl, [=](auto Item, auto &Red) { Red.combine(T{1}); }); }).wait(); - + if (!q.get_device().has(aspect::usm_shared_allocations)) + return; auto *Result = malloc_shared(1, q); q.submit([&](handler &cgh) { auto RedAcc = GetRedAcc(cgh); diff --git a/sycl/test-e2e/Reduction/reduction_range_item.cpp b/sycl/test-e2e/Reduction/reduction_range_item.cpp index ed9806e4753b5..2afe55ef45f6e 100644 --- a/sycl/test-e2e/Reduction/reduction_range_item.cpp +++ b/sycl/test-e2e/Reduction/reduction_range_item.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Reduction/reduction_span.cpp b/sycl/test-e2e/Reduction/reduction_span.cpp index 6c06d377eabe2..86ceadb97a77b 100644 --- a/sycl/test-e2e/Reduction/reduction_span.cpp +++ b/sycl/test-e2e/Reduction/reduction_span.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Reduction/reduction_span_pack.cpp b/sycl/test-e2e/Reduction/reduction_span_pack.cpp index 46862ffe45cf9..e6f39ebc1af19 100644 --- a/sycl/test-e2e/Reduction/reduction_span_pack.cpp +++ b/sycl/test-e2e/Reduction/reduction_span_pack.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out // diff --git a/sycl/test-e2e/Regression/exclusive-scan-char-short.cpp b/sycl/test-e2e/Regression/exclusive-scan-char-short.cpp index a7d3601210fa8..cdb273d051d10 100644 --- a/sycl/test-e2e/Regression/exclusive-scan-char-short.cpp +++ b/sycl/test-e2e/Regression/exclusive-scan-char-short.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Regression/group_local_linear_id.cpp b/sycl/test-e2e/Regression/group_local_linear_id.cpp index d3562c2b25cbf..02170a2991068 100644 --- a/sycl/test-e2e/Regression/group_local_linear_id.cpp +++ b/sycl/test-e2e/Regression/group_local_linear_id.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Regression/half_operators.cpp b/sycl/test-e2e/Regression/half_operators.cpp index b227806a02bc0..64f81affdfcc9 100644 --- a/sycl/test-e2e/Regression/half_operators.cpp +++ b/sycl/test-e2e/Regression/half_operators.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // REQUIRES: gpu // RUN: %{build} -fsycl-device-code-split=per_kernel -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Regression/pf-wg-atomic64.cpp b/sycl/test-e2e/Regression/pf-wg-atomic64.cpp index f2985b5a33b1d..754f867a9f6a8 100644 --- a/sycl/test-e2e/Regression/pf-wg-atomic64.cpp +++ b/sycl/test-e2e/Regression/pf-wg-atomic64.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // DISABLED: aspect-atomic64 // RUN: %{build} -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/Regression/range-rounding-this-id.cpp b/sycl/test-e2e/Regression/range-rounding-this-id.cpp index 33fa41c60cc68..1296dbf557f0c 100644 --- a/sycl/test-e2e/Regression/range-rounding-this-id.cpp +++ b/sycl/test-e2e/Regression/range-rounding-this-id.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // This test ensures that this_id returns the correct value // even when a kernel is wrapped in a range rounding kernel. // RUN: %{build} -o %t.out diff --git a/sycl/test-e2e/Regression/reduction_64bit_atomic64.cpp b/sycl/test-e2e/Regression/reduction_64bit_atomic64.cpp index dc138d9b79da8..a9e3382ce1617 100644 --- a/sycl/test-e2e/Regression/reduction_64bit_atomic64.cpp +++ b/sycl/test-e2e/Regression/reduction_64bit_atomic64.cpp @@ -1,3 +1,4 @@ +// REQUIRES: usm_shared_allocations // REQUIRES: aspect-atomic64 // RUN: %{build} -o %t.out // diff --git a/sycl/test-e2e/USM/alloc_functions.cpp b/sycl/test-e2e/USM/alloc_functions.cpp index 9a7744e046725..123d7a0e5206f 100644 --- a/sycl/test-e2e/USM/alloc_functions.cpp +++ b/sycl/test-e2e/USM/alloc_functions.cpp @@ -84,14 +84,18 @@ int main() { [&]() { return MHost(q, property_list{}); }, [&]() { return MHost(ctx, property_list{}); }}); - auto MShared = [&](auto... args) { - return malloc_shared(sizeof(std::max_align_t), args...); - }; - CheckAll(FAlign, - std::tuple{[&]() { return MShared(q); }, - [&]() { return MShared(d, ctx); }, - [&]() { return MShared(q, property_list{}); }, - [&]() { return MShared(d, ctx, property_list{}); }}); + if (d.has(aspect::usm_shared_allocations) && + q.get_device().has(aspect::usm_shared_allocations)) { + auto MShared = [&](auto... args) { + return malloc_shared(sizeof(std::max_align_t), args...); + }; + + CheckAll(FAlign, + std::tuple{[&]() { return MShared(q); }, + [&]() { return MShared(d, ctx); }, + [&]() { return MShared(q, property_list{}); }, + [&]() { return MShared(d, ctx, property_list{}); }}); + } auto ADevice = [&](size_t Align, auto... args) { return aligned_alloc_device(Align, sizeof(std::max_align_t), args...); @@ -124,21 +128,25 @@ int main() { [&]() { return AHost(Align, q, property_list{}); }, [&]() { return AHost(Align, ctx, property_list{}); }}); - auto AShared = [&](size_t Align, auto... args) { - return aligned_alloc_shared(Align, sizeof(std::max_align_t), args...); - }; - CheckAll(FAlign, - std::tuple{ - [&]() { return AShared(FAlign / 2, q); }, - [&]() { return AShared(FAlign / 2, d, ctx); }, - [&]() { return AShared(FAlign / 2, q, property_list{}); }, - [&]() { return AShared(FAlign / 2, d, ctx, property_list{}); }}); - CheckAll( - Align, - std::tuple{[&]() { return AShared(Align, q); }, - [&]() { return AShared(Align, d, ctx); }, - [&]() { return AShared(Align, q, property_list{}); }, - [&]() { return AShared(Align, d, ctx, property_list{}); }}); + if (q.get_device().has(aspect::usm_shared_allocations) && + d.has(aspect::usm_shared_allocations)) { + auto AShared = [&](size_t Align, auto... args) { + return aligned_alloc_shared(Align, sizeof(std::max_align_t), args...); + }; + CheckAll( + FAlign, + std::tuple{ + [&]() { return AShared(FAlign / 2, q); }, + [&]() { return AShared(FAlign / 2, d, ctx); }, + [&]() { return AShared(FAlign / 2, q, property_list{}); }, + [&]() { return AShared(FAlign / 2, d, ctx, property_list{}); }}); + CheckAll( + Align, + std::tuple{[&]() { return AShared(Align, q); }, + [&]() { return AShared(Align, d, ctx); }, + [&]() { return AShared(Align, q, property_list{}); }, + [&]() { return AShared(Align, d, ctx, property_list{}); }}); + } auto TDevice = [&](auto... args) { return malloc_device(1, args...); @@ -150,11 +158,14 @@ int main() { CheckAll(Align, std::tuple{[&]() { return THost(q); }, [&]() { return THost(ctx); }}); - auto TShared = [&](auto... args) { - return malloc_shared(1, args...); - }; - CheckAll(Align, std::tuple{[&]() { return TShared(q); }, - [&]() { return TShared(d, ctx); }}); + if (d.has(aspect::usm_shared_allocations) && + q.get_device().has(aspect::usm_shared_allocations)) { + auto TShared = [&](auto... args) { + return malloc_shared(1, args...); + }; + CheckAll(Align, std::tuple{[&]() { return TShared(q); }, + [&]() { return TShared(d, ctx); }}); + } auto ATDevice = [&](size_t Align, auto... args) { return aligned_alloc_device(Align, 1, args...); @@ -172,15 +183,17 @@ int main() { [&]() { return ATHost(Align / 2, ctx); }}); CheckAll(Align * 2, std::tuple{[&]() { return ATHost(Align * 2, q); }, [&]() { return ATHost(Align * 2, ctx); }}); - - auto ATShared = [&](size_t Align, auto... args) { - return aligned_alloc_shared(Align, 1, args...); - }; - CheckAll(Align, std::tuple{[&]() { return ATShared(Align / 2, q); }, - [&]() { return ATShared(Align / 2, d, ctx); }}); - CheckAll(Align * 2, - std::tuple{[&]() { return ATShared(Align * 2, q); }, - [&]() { return ATShared(Align * 2, d, ctx); }}); + if (q.get_device().has(aspect::usm_shared_allocations) && + d.has(aspect::usm_shared_allocations)) { + auto ATShared = [&](size_t Align, auto... args) { + return aligned_alloc_shared(Align, 1, args...); + }; + CheckAll(Align, std::tuple{[&]() { return ATShared(Align / 2, q); }, + [&]() { return ATShared(Align / 2, d, ctx); }}); + CheckAll(Align * 2, + std::tuple{[&]() { return ATShared(Align * 2, q); }, + [&]() { return ATShared(Align * 2, d, ctx); }}); + } auto Malloc = [&](auto... args) { return malloc(sizeof(std::max_align_t), args...); diff --git a/sycl/test-e2e/USM/badmalloc.cpp b/sycl/test-e2e/USM/badmalloc.cpp index f670cb4e6b441..16e30779dc3c4 100644 --- a/sycl/test-e2e/USM/badmalloc.cpp +++ b/sycl/test-e2e/USM/badmalloc.cpp @@ -36,10 +36,12 @@ int main(int argc, char *argv[]) { std::cout << "p = " << p << std::endl; if (p != nullptr) return 3; - p = malloc(-1, q, usm::alloc::shared); - std::cout << "p = " << p << std::endl; - if (p != nullptr) - return 4; + if (q.get_device().has(aspect::usm_shared_allocations)) { + p = malloc(-1, q, usm::alloc::shared); + std::cout << "p = " << p << std::endl; + if (p != nullptr) + return 4; + } p = malloc(-1, q, usm::alloc::unknown); std::cout << "p = " << p << std::endl; if (p != nullptr) @@ -54,10 +56,12 @@ int main(int argc, char *argv[]) { std::cout << "p = " << p << std::endl; if (p != nullptr) return 7; - p = aligned_alloc(0, -1, q, usm::alloc::shared); - std::cout << "p = " << p << std::endl; - if (p != nullptr) - return 8; + if (q.get_device().has(aspect::usm_shared_allocations)) { + p = aligned_alloc(0, -1, q, usm::alloc::shared); + std::cout << "p = " << p << std::endl; + if (p != nullptr) + return 8; + } p = aligned_alloc(0, -1, q, usm::alloc::unknown); std::cout << "p = " << p << std::endl; if (p != nullptr) diff --git a/sycl/test-e2e/USM/dep_events.cpp b/sycl/test-e2e/USM/dep_events.cpp index b70dd99f5400f..ea48a6cd20202 100644 --- a/sycl/test-e2e/USM/dep_events.cpp +++ b/sycl/test-e2e/USM/dep_events.cpp @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// - +// REQUIRES: usm_shared_allocations // RUN: %{build} -o %t1.out // RUN: %{run} %t1.out diff --git a/sycl/test-e2e/USM/memcpy.cpp b/sycl/test-e2e/USM/memcpy.cpp index c7ae134258dc1..c2c5e9023beb1 100644 --- a/sycl/test-e2e/USM/memcpy.cpp +++ b/sycl/test-e2e/USM/memcpy.cpp @@ -175,7 +175,7 @@ int main() { TEST_MEMCPY(inArray, init_on_device, outArray, check_on_device) // Test device to aligned device - USM_MALLOC(inArray, shared) + USM_MALLOC(inArray, device) USM_ALIGNED_ALLOC_DEVICE(outArray) TEST_MEMCPY(inArray, init_on_device, outArray, check_on_device) @@ -279,7 +279,7 @@ int main() { TEST_MEMCPY(inArray, init_on_host, outArray, check_on_device) } - if (dev.get_info() && + if (dev.get_info() && dev.get_info()) { // Test shared to device USM_MALLOC(inArray, shared) diff --git a/sycl/test-e2e/syclcompat/kernel/Inputs/kernel_function.cpp b/sycl/test-e2e/syclcompat/kernel/Inputs/kernel_function.cpp index 1a54c0acdc0c8..409bb8603adba 100644 --- a/sycl/test-e2e/syclcompat/kernel/Inputs/kernel_function.cpp +++ b/sycl/test-e2e/syclcompat/kernel/Inputs/kernel_function.cpp @@ -29,7 +29,6 @@ // // // ===---------------------------------------------------------------------===// - #ifdef _WIN32 #include #else @@ -110,7 +109,8 @@ void test_kernel_functor_ptr() { int sharedSize = 10; void **param = nullptr, **extra = nullptr; - + if (!q_ct1->get_device().has(sycl::aspect::usm_shared_allocations)) + return; int *dev = sycl::malloc_shared(16, *q_ct1); for (int i = 0; i < 16; i++) { dev[i] = 0; diff --git a/sycl/test-e2e/syclcompat/memory/memory_management_test2.cpp b/sycl/test-e2e/syclcompat/memory/memory_management_test2.cpp index c60d22402971f..9774faa8e8ba7 100644 --- a/sycl/test-e2e/syclcompat/memory/memory_management_test2.cpp +++ b/sycl/test-e2e/syclcompat/memory/memory_management_test2.cpp @@ -30,6 +30,7 @@ // // ===----------------------------------------------------------------------===// +// REQUIRES: usm_shared_allocations // RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/syclcompat/memory/usm_allocations.cpp b/sycl/test-e2e/syclcompat/memory/usm_allocations.cpp index 6feed8f705c2e..fb8a8a52da101 100644 --- a/sycl/test-e2e/syclcompat/memory/usm_allocations.cpp +++ b/sycl/test-e2e/syclcompat/memory/usm_allocations.cpp @@ -20,6 +20,7 @@ * USM allocation tests **************************************************************************/ +// REQUIRES: usm_shared_allocations // RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/syclcompat/util/util_complex.cpp b/sycl/test-e2e/syclcompat/util/util_complex.cpp index cd4e7150317b3..0e680dbdd17e4 100644 --- a/sycl/test-e2e/syclcompat/util/util_complex.cpp +++ b/sycl/test-e2e/syclcompat/util/util_complex.cpp @@ -30,7 +30,7 @@ //===---------------------------------------------------------------===// // REQUIRES: aspect-fp64 - +// REQUIRES: usm_shared_allocations // RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/syclcompat/util/util_find_first_set.cpp b/sycl/test-e2e/syclcompat/util/util_find_first_set.cpp index c350049ff1d72..d4aa398546c3c 100644 --- a/sycl/test-e2e/syclcompat/util/util_find_first_set.cpp +++ b/sycl/test-e2e/syclcompat/util/util_find_first_set.cpp @@ -30,6 +30,7 @@ // // ===----------------------------------------------------------------------===// +// REQUIRES: usm_shared_allocations // RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/syclcompat/util/util_permute_sub_group_by_xor.cpp b/sycl/test-e2e/syclcompat/util/util_permute_sub_group_by_xor.cpp index a5736c24e104f..c79668b698c55 100644 --- a/sycl/test-e2e/syclcompat/util/util_permute_sub_group_by_xor.cpp +++ b/sycl/test-e2e/syclcompat/util/util_permute_sub_group_by_xor.cpp @@ -30,6 +30,7 @@ // // ===----------------------------------------------------------------------===// +// REQUIRES: usm_shared_allocations // REQUIRES: sg-32 // RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/syclcompat/util/util_select_from_sub_group.cpp b/sycl/test-e2e/syclcompat/util/util_select_from_sub_group.cpp index 78579ebc085ad..b2798cf6be6b8 100644 --- a/sycl/test-e2e/syclcompat/util/util_select_from_sub_group.cpp +++ b/sycl/test-e2e/syclcompat/util/util_select_from_sub_group.cpp @@ -30,6 +30,7 @@ // // ===----------------------------------------------------------------------===// +// REQUIRES: usm_shared_allocations // REQUIRES: sg-32 // RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/syclcompat/util/util_shift_sub_group_left.cpp b/sycl/test-e2e/syclcompat/util/util_shift_sub_group_left.cpp index c09b8aac444ee..a688a59647228 100644 --- a/sycl/test-e2e/syclcompat/util/util_shift_sub_group_left.cpp +++ b/sycl/test-e2e/syclcompat/util/util_shift_sub_group_left.cpp @@ -30,6 +30,7 @@ // // ===----------------------------------------------------------------------===// +// REQUIRES: usm_shared_allocations // REQUIRES: sg-32 // RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/syclcompat/util/util_shift_sub_group_right.cpp b/sycl/test-e2e/syclcompat/util/util_shift_sub_group_right.cpp index c38b232911a3d..65b24a6c24051 100644 --- a/sycl/test-e2e/syclcompat/util/util_shift_sub_group_right.cpp +++ b/sycl/test-e2e/syclcompat/util/util_shift_sub_group_right.cpp @@ -30,6 +30,7 @@ // // ===----------------------------------------------------------------------===// +// REQUIRES: usm_shared_allocations // REQUIRES: sg-32 // RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out // RUN: %{run} %t.out diff --git a/sycl/unittests/scheduler/InOrderQueueHostTaskDeps.cpp b/sycl/unittests/scheduler/InOrderQueueHostTaskDeps.cpp index 298a71788b155..ce2782d7f3f26 100644 --- a/sycl/unittests/scheduler/InOrderQueueHostTaskDeps.cpp +++ b/sycl/unittests/scheduler/InOrderQueueHostTaskDeps.cpp @@ -40,7 +40,8 @@ TEST_F(SchedulerTest, InOrderQueueHostTaskDeps) { context Ctx{Plt}; queue InOrderQueue{Ctx, default_selector_v, property::queue::in_order()}; - + if (!InOrderQueue.get_device().has(aspect::usm_shared_allocations)) + return; auto buf = sycl::malloc_shared(1, InOrderQueue); event Evt = InOrderQueue.submit( [&](sycl::handler &CGH) { CGH.memset(buf, 0, sizeof(buf[0])); }); @@ -80,7 +81,8 @@ TEST_F(SchedulerTest, InOrderQueueCrossDeps) { context Ctx{Plt}; queue InOrderQueue{Ctx, default_selector_v, property::queue::in_order()}; - + if (!InOrderQueue.get_device().has(aspect::usm_shared_allocations)) + return; kernel_bundle KernelBundle = sycl::get_kernel_bundle(Ctx); auto ExecBundle = sycl::build(KernelBundle); @@ -95,7 +97,6 @@ TEST_F(SchedulerTest, InOrderQueueCrossDeps) { Cv.wait(lk, [&ready] { return ready; }); }); }); - auto buf = sycl::malloc_shared(1, InOrderQueue); event Ev1 = InOrderQueue.submit( @@ -137,7 +138,8 @@ TEST_F(SchedulerTest, InOrderQueueCrossDepsShortcutFuncs) { context Ctx{Plt}; queue InOrderQueue{Ctx, default_selector_v, property::queue::in_order()}; - + if (!InOrderQueue.get_device().has(aspect::usm_shared_allocations)) + return; std::mutex CvMutex; std::condition_variable Cv; bool ready = false; @@ -148,7 +150,6 @@ TEST_F(SchedulerTest, InOrderQueueCrossDepsShortcutFuncs) { Cv.wait(lk, [&ready] { return ready; }); }); }); - auto buf = sycl::malloc_shared(1, InOrderQueue); event Ev1 = InOrderQueue.memset(buf, 0, sizeof(buf[0])); diff --git a/sycl/unittests/xpti_trace/QueueIDCheck.cpp b/sycl/unittests/xpti_trace/QueueIDCheck.cpp index 43d113c2eea3c..74f85b8c9dbc7 100644 --- a/sycl/unittests/xpti_trace/QueueIDCheck.cpp +++ b/sycl/unittests/xpti_trace/QueueIDCheck.cpp @@ -140,7 +140,8 @@ TEST_F(QueueID, QueueCreationUSMOperations) { sycl::queue Q0; auto Queue0ImplPtr = sycl::detail::getSyclObjImpl(Q0); auto QueueIDSTr = std::to_string(Queue0ImplPtr->getQueueID()); - + if (!Q0.get_device().has(aspect::usm_shared_allocations)) + return; unsigned char *AllocSrc = (unsigned char *)sycl::malloc_shared(1, Q0); unsigned char *AllocDst = (unsigned char *)sycl::malloc_shared(1, Q0); Q0.memset(AllocSrc, 42, 1).wait();