Skip to content

Commit

Permalink
[SYCL][E2E] Rewrite Tests Containing Deprecated Overloads #2 (#16386)
Browse files Browse the repository at this point in the history
The overloads for single_task and parallel_for in the
sycl_ext_oneapi_kernel_properties extension are being deprecated as
mentioned in #14785. So I'm rewriting
tests containg such overloads so that they can still run after the
deprecation.

---------

Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
  • Loading branch information
HPS-1 authored Jan 15, 2025
1 parent d4e3e45 commit fa46cbe
Show file tree
Hide file tree
Showing 13 changed files with 265 additions and 255 deletions.
28 changes: 9 additions & 19 deletions sycl/test-e2e/Basic/max_linear_work_group_size_props.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,15 @@ template <size_t I> struct KernelFunctorWithMaxWGSizeProp {
}
};

template <Variant KernelVariant, size_t I, typename PropertiesT,
typename KernelType>
int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
template <Variant KernelVariant, size_t I, typename KernelType>
int test(queue &Q, KernelType KernelFunc) {
constexpr size_t Dims = 1;

// Positive test case: Specify local size that matches required size.
try {
Q.submit([&](handler &CGH) {
CGH.parallel_for<MaxLinearWGSizePositive<KernelVariant, false, I>>(
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(I)), Props,
KernelFunc);
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(I)), KernelFunc);
});
Q.wait_and_throw();
} catch (exception &E) {
Expand All @@ -81,8 +79,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
// Same as above but using the queue shortcuts.
try {
Q.parallel_for<MaxLinearWGSizePositive<KernelVariant, true, I>>(
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(I)), Props,
KernelFunc);
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(I)), KernelFunc);
Q.wait_and_throw();
} catch (exception &E) {
std::cerr
Expand All @@ -97,7 +94,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
try {
Q.submit([&](handler &CGH) {
CGH.parallel_for<MaxLinearWGSizeNoLocalPositive<KernelVariant, false, I>>(
repeatRange<Dims>(16), Props, KernelFunc);
repeatRange<Dims>(16), KernelFunc);
});
Q.wait_and_throw();
} catch (exception &E) {
Expand All @@ -109,7 +106,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {

try {
Q.parallel_for<MaxLinearWGSizeNoLocalPositive<KernelVariant, true, I>>(
repeatRange<Dims>(16), Props, KernelFunc);
repeatRange<Dims>(16), KernelFunc);
Q.wait_and_throw();
} catch (exception &E) {
std::cerr << "Test case MaxLinearWGSizeNoLocalPositive shortcut failed: "
Expand All @@ -122,7 +119,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
try {
Q.submit([&](handler &CGH) {
CGH.parallel_for<MaxLinearWGSizeNegative<KernelVariant, false, I>>(
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
KernelFunc);
});
Q.wait_and_throw();
Expand All @@ -147,7 +144,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
// Same as above but using the queue shortcuts.
try {
Q.parallel_for<MaxLinearWGSizeNegative<KernelVariant, true, I>>(
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
KernelFunc);
Q.wait_and_throw();
std::cerr
Expand All @@ -174,17 +171,10 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
}

template <size_t I> int test_max(queue &Q) {
auto Props = ext::oneapi::experimental::properties{
ext::oneapi::experimental::max_linear_work_group_size<I>};
auto KernelFunction = [](auto) {};

auto EmptyProps = ext::oneapi::experimental::properties{};
KernelFunctorWithMaxWGSizeProp<I> KernelFunctor;

int Res = 0;
Res += test<Variant::Function, I>(Q, Props, KernelFunction);
Res += test<Variant::Functor, I>(Q, EmptyProps, KernelFunctor);
Res += test<Variant::FunctorAndProperty, I>(Q, Props, KernelFunctor);
Res += test<Variant::Functor, I>(Q, KernelFunctor);
return Res;
}

Expand Down
28 changes: 9 additions & 19 deletions sycl/test-e2e/Basic/max_work_group_size_props.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,15 @@ template <size_t... Is> struct KernelFunctorWithMaxWGSizeProp {
}
};

template <Variant KernelVariant, size_t... Is, typename PropertiesT,
typename KernelType>
int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
template <Variant KernelVariant, size_t... Is, typename KernelType>
int test(queue &Q, KernelType KernelFunc) {
constexpr size_t Dims = sizeof...(Is);

// Positive test case: Specify local size that matches required size.
try {
Q.submit([&](handler &CGH) {
CGH.parallel_for<MaxWGSizePositive<KernelVariant, false, Is...>>(
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
KernelFunc);
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
});
Q.wait_and_throw();
} catch (exception &E) {
Expand All @@ -71,8 +69,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
// Same as above but using the queue shortcuts.
try {
Q.parallel_for<MaxWGSizePositive<KernelVariant, true, Is...>>(
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
KernelFunc);
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
Q.wait_and_throw();
} catch (exception &E) {
std::cerr << "Test case MaxWGSizePositive shortcut failed: unexpected "
Expand All @@ -86,7 +83,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
try {
Q.submit([&](handler &CGH) {
CGH.parallel_for<MaxWGSizeNoLocalPositive<KernelVariant, false, Is...>>(
repeatRange<Dims>(16), Props, KernelFunc);
repeatRange<Dims>(16), KernelFunc);
});
Q.wait_and_throw();
} catch (exception &E) {
Expand All @@ -98,7 +95,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {

try {
Q.parallel_for<MaxWGSizeNoLocalPositive<KernelVariant, true, Is...>>(
repeatRange<Dims>(16), Props, KernelFunc);
repeatRange<Dims>(16), KernelFunc);
Q.wait_and_throw();
} catch (exception &E) {
std::cerr << "Test case MaxWGSizeNoLocalPositive shortcut failed: "
Expand All @@ -111,7 +108,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
try {
Q.submit([&](handler &CGH) {
CGH.parallel_for<MaxWGSizeNegative<KernelVariant, false, Is...>>(
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
KernelFunc);
});
Q.wait_and_throw();
Expand All @@ -134,7 +131,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
// Same as above but using the queue shortcuts.
try {
Q.parallel_for<MaxWGSizeNegative<KernelVariant, true, Is...>>(
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
KernelFunc);
Q.wait_and_throw();
std::cerr << "Test case MaxWGSizeNegative shortcut failed: no exception "
Expand All @@ -159,17 +156,10 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
}

template <size_t... Is> int test_max(queue &Q) {
auto Props = ext::oneapi::experimental::properties{
ext::oneapi::experimental::max_work_group_size<Is...>};
auto KernelFunction = [](auto) {};

auto EmptyProps = ext::oneapi::experimental::properties{};
KernelFunctorWithMaxWGSizeProp<Is...> KernelFunctor;

int Res = 0;
Res += test<Variant::Function, Is...>(Q, Props, KernelFunction);
Res += test<Variant::Functor, Is...>(Q, EmptyProps, KernelFunctor);
Res += test<Variant::FunctorAndProperty, Is...>(Q, Props, KernelFunctor);
Res += test<Variant::Functor, Is...>(Q, KernelFunctor);
return Res;
}

Expand Down
28 changes: 9 additions & 19 deletions sycl/test-e2e/Basic/work_group_size_prop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ template <size_t... Is> struct KernelFunctorWithWGSizeProp {
}
};

template <Variant KernelVariant, size_t... Is, typename PropertiesT,
typename KernelType>
int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
template <Variant KernelVariant, size_t... Is, typename KernelType>
int test(queue &Q, KernelType KernelFunc) {
constexpr size_t Dims = sizeof...(Is);

bool IsOpenCL = (Q.get_backend() == backend::opencl);
Expand All @@ -56,8 +55,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
try {
Q.submit([&](handler &CGH) {
CGH.parallel_for<ReqdWGSizePositiveA<KernelVariant, false, Is...>>(
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
KernelFunc);
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
});
Q.wait_and_throw();
} catch (exception &E) {
Expand All @@ -69,8 +67,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
// Same as above but using the queue shortcuts.
try {
Q.parallel_for<ReqdWGSizePositiveA<KernelVariant, true, Is...>>(
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
KernelFunc);
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
Q.wait_and_throw();
} catch (exception &E) {
std::cerr << "Test case ReqdWGSizePositiveA shortcut failed: unexpected "
Expand All @@ -87,7 +84,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
Q.submit([&](handler &CGH) {
CGH.parallel_for<
ReqdWGSizeNoLocalPositive<KernelVariant, false, Is...>>(
repeatRange<Dims>(16), Props, KernelFunc);
repeatRange<Dims>(16), KernelFunc);
});
Q.wait_and_throw();
} catch (exception &E) {
Expand All @@ -99,7 +96,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {

try {
Q.parallel_for<ReqdWGSizeNoLocalPositive<KernelVariant, true, Is...>>(
repeatRange<Dims>(16), Props, KernelFunc);
repeatRange<Dims>(16), KernelFunc);
Q.wait_and_throw();
} catch (exception &E) {
std::cerr << "Test case ReqdWGSizeNoLocalPositive shortcut failed: "
Expand All @@ -113,7 +110,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
try {
Q.submit([&](handler &CGH) {
CGH.parallel_for<ReqdWGSizeNegativeA<KernelVariant, false, Is...>>(
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
KernelFunc);
});
Q.wait_and_throw();
Expand All @@ -137,7 +134,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
// Same as above but using the queue shortcuts.
try {
Q.parallel_for<ReqdWGSizeNegativeA<KernelVariant, true, Is...>>(
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
KernelFunc);
Q.wait_and_throw();
std::cerr << "Test case ReqdWGSizeNegativeA shortcut failed: no exception "
Expand All @@ -162,17 +159,10 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
}

template <size_t... Is> int test(queue &Q) {
auto Props = ext::oneapi::experimental::properties{
ext::oneapi::experimental::work_group_size<Is...>};
auto KernelFunction = [](auto) {};

auto EmptyProps = ext::oneapi::experimental::properties{};
KernelFunctorWithWGSizeProp<Is...> KernelFunctor;

int Res = 0;
Res += test<Variant::Function, Is...>(Q, Props, KernelFunction);
Res += test<Variant::Functor, Is...>(Q, EmptyProps, KernelFunctor);
Res += test<Variant::FunctorAndProperty, Is...>(Q, Props, KernelFunctor);
Res += test<Variant::Functor, Is...>(Q, KernelFunctor);
return Res;
}

Expand Down
24 changes: 7 additions & 17 deletions sycl/test-e2e/Graph/Inputs/work_group_size_prop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ template <size_t... Is> struct KernelFunctorWithWGSizeProp {
}
};

template <Variant KernelVariant, size_t... Is, typename PropertiesT,
typename KernelType>
int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {
template <Variant KernelVariant, size_t... Is, typename KernelType>
int test(queue &Queue, KernelType KernelFunc) {
constexpr size_t Dims = sizeof...(Is);

// Positive test case: Specify local size that matches required size.
Expand All @@ -52,15 +51,13 @@ int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {

add_node(Graph, Queue, [&](handler &CGH) {
CGH.parallel_for<ReqdWGSizePositiveA<KernelVariant, false, Is...>>(
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
KernelFunc);
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
});

#ifdef GRAPH_E2E_RECORD_REPLAY
Graph.begin_recording(Queue);
Queue.parallel_for<ReqdWGSizePositiveA<KernelVariant, true, Is...>>(
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
KernelFunc);
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
Graph.end_recording(Queue);
#endif

Expand All @@ -83,7 +80,7 @@ int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {
try {
add_node(GraphN, Queue, [&](handler &CGH) {
CGH.parallel_for<ReqdWGSizeNegativeA<KernelVariant, false, Is...>>(
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
KernelFunc);
});
auto ExecGraph = GraphN.finalize();
Expand Down Expand Up @@ -119,7 +116,7 @@ int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {
GraphN.begin_recording(Queue);

Queue.parallel_for<ReqdWGSizeNegativeA<KernelVariant, true, Is...>>(
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
KernelFunc);

GraphN.end_recording(Queue);
Expand Down Expand Up @@ -156,17 +153,10 @@ int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {
}

template <size_t... Is> int test(queue &Queue) {
auto Props = sycl::ext::oneapi::experimental::properties{
sycl::ext::oneapi::experimental::work_group_size<Is...>};
auto KernelFunction = [](auto) {};

auto EmptyProps = sycl::ext::oneapi::experimental::properties{};
KernelFunctorWithWGSizeProp<Is...> KernelFunctor;

int Res = 0;
Res += test<Variant::Function, Is...>(Queue, Props, KernelFunction);
Res += test<Variant::Functor, Is...>(Queue, EmptyProps, KernelFunctor);
Res += test<Variant::FunctorAndProperty, Is...>(Queue, Props, KernelFunctor);
Res += test<Variant::Functor, Is...>(Queue, KernelFunctor);
return Res;
}

Expand Down
Loading

0 comments on commit fa46cbe

Please sign in to comment.