Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Deprecate parallel_for and single_task overloads #16145

Open
wants to merge 7 commits into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 48 additions & 23 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2314,9 +2314,12 @@ class __SYCL_EXPORT handler {

template <typename KernelName = detail::auto_name, typename KernelType,
typename PropertiesT>
std::enable_if_t<
ext::oneapi::experimental::is_property_list<PropertiesT>::value>
single_task(PropertiesT Props, _KERNELFUNCPARAM(KernelFunc)) {
__SYCL2020_DEPRECATED(
HPS-1 marked this conversation as resolved.
Show resolved Hide resolved
"Use sycl::ext::oneapi::experimental::single_task (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
std::enable_if_t<ext::oneapi::experimental::is_property_list<
PropertiesT>::value> single_task(PropertiesT Props,
_KERNELFUNCPARAM(KernelFunc)) {
single_task_lambda_impl<KernelName, KernelType, PropertiesT>(Props,
KernelFunc);
}
Expand Down Expand Up @@ -2364,11 +2367,15 @@ class __SYCL_EXPORT handler {

template <typename KernelName = detail::auto_name, typename PropertiesT,
typename... RestT>
std::enable_if_t<
(sizeof...(RestT) > 1) &&
detail::AreAllButLastReductions<RestT...>::value &&
ext::oneapi::experimental::is_property_list<PropertiesT>::value>
parallel_for(range<1> Range, PropertiesT Properties, RestT &&...Rest) {
__SYCL2020_DEPRECATED(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new test should be added into sycl/test/warnings/ to check that deprecated message is correct and emitted for all overloads

"Use sycl::ext::oneapi::experimental::parallel_for (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
std::enable_if_t<(sizeof...(RestT) > 1) &&
detail::AreAllButLastReductions<RestT...>::value &&
ext::oneapi::experimental::is_property_list<
PropertiesT>::value> parallel_for(range<1> Range,
PropertiesT Properties,
RestT &&...Rest) {
#ifndef __SYCL_DEVICE_ONLY__
throwIfGraphAssociated<ext::oneapi::experimental::detail::
UnsupportedGraphFeatures::sycl_reductions>();
Expand All @@ -2379,11 +2386,15 @@ class __SYCL_EXPORT handler {

template <typename KernelName = detail::auto_name, typename PropertiesT,
typename... RestT>
std::enable_if_t<
(sizeof...(RestT) > 1) &&
detail::AreAllButLastReductions<RestT...>::value &&
ext::oneapi::experimental::is_property_list<PropertiesT>::value>
parallel_for(range<2> Range, PropertiesT Properties, RestT &&...Rest) {
__SYCL2020_DEPRECATED(
"Use sycl::ext::oneapi::experimental::parallel_for (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
std::enable_if_t<(sizeof...(RestT) > 1) &&
detail::AreAllButLastReductions<RestT...>::value &&
ext::oneapi::experimental::is_property_list<
PropertiesT>::value> parallel_for(range<2> Range,
PropertiesT Properties,
RestT &&...Rest) {
#ifndef __SYCL_DEVICE_ONLY__
throwIfGraphAssociated<ext::oneapi::experimental::detail::
UnsupportedGraphFeatures::sycl_reductions>();
Expand All @@ -2394,11 +2405,15 @@ class __SYCL_EXPORT handler {

template <typename KernelName = detail::auto_name, typename PropertiesT,
typename... RestT>
std::enable_if_t<
(sizeof...(RestT) > 1) &&
detail::AreAllButLastReductions<RestT...>::value &&
ext::oneapi::experimental::is_property_list<PropertiesT>::value>
parallel_for(range<3> Range, PropertiesT Properties, RestT &&...Rest) {
__SYCL2020_DEPRECATED(
"Use sycl::ext::oneapi::experimental::parallel_for (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
std::enable_if_t<(sizeof...(RestT) > 1) &&
detail::AreAllButLastReductions<RestT...>::value &&
ext::oneapi::experimental::is_property_list<
PropertiesT>::value> parallel_for(range<3> Range,
PropertiesT Properties,
RestT &&...Rest) {
#ifndef __SYCL_DEVICE_ONLY__
throwIfGraphAssociated<ext::oneapi::experimental::detail::
UnsupportedGraphFeatures::sycl_reductions>();
Expand Down Expand Up @@ -2433,11 +2448,15 @@ class __SYCL_EXPORT handler {

template <typename KernelName = detail::auto_name, int Dims,
typename PropertiesT, typename... RestT>
std::enable_if_t<
(sizeof...(RestT) > 1) &&
detail::AreAllButLastReductions<RestT...>::value &&
ext::oneapi::experimental::is_property_list<PropertiesT>::value>
parallel_for(nd_range<Dims> Range, PropertiesT Properties, RestT &&...Rest) {
__SYCL2020_DEPRECATED(
"Use sycl::ext::oneapi::experimental::parallel_for (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
std::enable_if_t<(sizeof...(RestT) > 1) &&
detail::AreAllButLastReductions<RestT...>::value &&
ext::oneapi::experimental::is_property_list<
PropertiesT>::value> parallel_for(nd_range<Dims> Range,
PropertiesT Properties,
RestT &&...Rest) {
#ifndef __SYCL_DEVICE_ONLY__
throwIfGraphAssociated<ext::oneapi::experimental::detail::
UnsupportedGraphFeatures::sycl_reductions>();
Expand All @@ -2459,6 +2478,9 @@ class __SYCL_EXPORT handler {

template <typename KernelName = detail::auto_name, typename KernelType,
int Dims, typename PropertiesT>
__SYCL2020_DEPRECATED(
"Use sycl::ext::oneapi::experimental::parallel_for (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
void parallel_for_work_group(range<Dims> NumWorkGroups, PropertiesT Props,
_KERNELFUNCPARAM(KernelFunc)) {
parallel_for_work_group_lambda_impl<KernelName, KernelType, Dims,
Expand All @@ -2468,6 +2490,9 @@ class __SYCL_EXPORT handler {

template <typename KernelName = detail::auto_name, typename KernelType,
int Dims, typename PropertiesT>
__SYCL2020_DEPRECATED(
"Use sycl::ext::oneapi::experimental::parallel_for (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
void parallel_for_work_group(range<Dims> NumWorkGroups,
range<Dims> WorkGroupSize, PropertiesT Props,
_KERNELFUNCPARAM(KernelFunc)) {
Expand Down
43 changes: 28 additions & 15 deletions sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2089,11 +2089,14 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
/// \param CodeLoc contains the code location of user code
template <typename KernelName = detail::auto_name, typename KernelType,
typename PropertiesT>
__SYCL2020_DEPRECATED(
"Use sycl::ext::oneapi::experimental::single_task (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
std::enable_if_t<
ext::oneapi::experimental::is_property_list<PropertiesT>::value, event>
single_task(
PropertiesT Properties, _KERNELFUNCPARAM(KernelFunc),
const detail::code_location &CodeLoc = detail::code_location::current()) {
ext::oneapi::experimental::is_property_list<PropertiesT>::value,
event> single_task(PropertiesT Properties, _KERNELFUNCPARAM(KernelFunc),
const detail::code_location &CodeLoc =
detail::code_location::current()) {
static_assert(
(detail::check_fn_signature<std::remove_reference_t<KernelType>,
void()>::value ||
Expand Down Expand Up @@ -2131,11 +2134,15 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
/// \param CodeLoc contains the code location of user code
template <typename KernelName = detail::auto_name, typename KernelType,
typename PropertiesT>
__SYCL2020_DEPRECATED(
"Use sycl::ext::oneapi::experimental::single_task (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
std::enable_if_t<
ext::oneapi::experimental::is_property_list<PropertiesT>::value, event>
single_task(
event DepEvent, PropertiesT Properties, _KERNELFUNCPARAM(KernelFunc),
const detail::code_location &CodeLoc = detail::code_location::current()) {
ext::oneapi::experimental::is_property_list<PropertiesT>::value,
event> single_task(event DepEvent, PropertiesT Properties,
_KERNELFUNCPARAM(KernelFunc),
const detail::code_location &CodeLoc =
detail::code_location::current()) {
static_assert(
(detail::check_fn_signature<std::remove_reference_t<KernelType>,
void()>::value ||
Expand Down Expand Up @@ -2177,12 +2184,15 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
/// \param CodeLoc contains the code location of user code
template <typename KernelName = detail::auto_name, typename KernelType,
typename PropertiesT>
__SYCL2020_DEPRECATED(
"Use sycl::ext::oneapi::experimental::single_task (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
std::enable_if_t<
ext::oneapi::experimental::is_property_list<PropertiesT>::value, event>
single_task(
const std::vector<event> &DepEvents, PropertiesT Properties,
_KERNELFUNCPARAM(KernelFunc),
const detail::code_location &CodeLoc = detail::code_location::current()) {
ext::oneapi::experimental::is_property_list<PropertiesT>::value,
event> single_task(const std::vector<event> &DepEvents,
PropertiesT Properties, _KERNELFUNCPARAM(KernelFunc),
const detail::code_location &CodeLoc =
detail::code_location::current()) {
static_assert(
(detail::check_fn_signature<std::remove_reference_t<KernelType>,
void()>::value ||
Expand Down Expand Up @@ -2428,11 +2438,14 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
/// const KernelType &KernelFunc".
template <typename KernelName = detail::auto_name, int Dims,
typename PropertiesT, typename... RestT>
__SYCL2020_DEPRECATED(
"Use sycl::ext::oneapi::experimental::parallel_for (provided in the "
"sycl_ext_oneapi_enqueue_functions extension) instead.")
std::enable_if_t<
detail::AreAllButLastReductions<RestT...>::value &&
ext::oneapi::experimental::is_property_list<PropertiesT>::value,
event>
parallel_for(nd_range<Dims> Range, PropertiesT Properties, RestT &&...Rest) {
event> parallel_for(nd_range<Dims> Range, PropertiesT Properties,
RestT &&...Rest) {
constexpr detail::code_location CodeLoc = getCodeLocation<KernelName>();
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
return submit(
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Basic/max_linear_work_group_size_props.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %{build} -o %t.out
// RUN: %{build} -o %t.out -Wno-deprecated-declarations
// RUN: %{run} %t.out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we specifically want to test the old API, we shouldn't add this flag but rewrite the test instead. The reason is fear that we can accidentally use even more deprecated APIs in a test, thus making even more work for ourselves in the future PR which removes deprecated overloads.


// This property is not yet supported by all UR adapters
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Basic/max_work_group_size_props.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %{build} -o %t.out
// RUN: %{build} -o %t.out -Wno-deprecated-declarations
// RUN: %{run} %t.out

// This property is not yet supported by all UR adapters
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Basic/work_group_size_prop.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %{build} -o %t.out
// RUN: %{build} -o %t.out -Wno-deprecated-declarations
// RUN: %{run} %t.out

#include <sycl/detail/core.hpp>
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Explicit/work_group_size_prop.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %{build} -o %t.out
// RUN: %{build} -o %t.out -Wno-deprecated-declarations
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %{build} -o %t.out
// RUN: %{build} -o %t.out -Wno-deprecated-declarations
// RUN: %{run} %t.out
EwanC marked this conversation as resolved.
Show resolved Hide resolved
// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/GroupAlgorithm/root_group.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Fails with opencl non-cpu, enable when fixed.
// XFAIL: (opencl && !cpu && !accelerator)
// RUN: %{build} -I . -o %t.out %if any-device-is-cuda %{ -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_70 %}
// RUN: %{build} -I . -o %t.out %if any-device-is-cuda %{ -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_70 %} -Wno-deprecated-declarations
// RUN: %{run} %t.out

// Disabled temporarily while investigation into the failure is ongoing.
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Properties/cache_config.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// REQUIRES: gpu, level_zero

// RUN: %{build} -o %t.out
// RUN: %{build} -o %t.out -Wno-deprecated-declarations
// RUN: env UR_L0_DEBUG=1 %{run} %t.out 2>&1 | FileCheck %s

#include <numeric>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %{build} -o %t.out %helper-includes
// RUN: %{build} -o %t.out %helper-includes -Wno-deprecated-declarations
// RUN: %{run} %t.out

#include <sycl/detail/core.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %{build} -o %t.out %helper-includes
// RUN: %{build} -o %t.out %helper-includes -Wno-deprecated-declarations
// RUN: %{run} %t.out

#include <sycl/detail/core.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %{build} -o %t.out %helper-includes
// RUN: %{build} -o %t.out %helper-includes -Wno-deprecated-declarations
// RUN: %{run} %t.out

#include <sycl/detail/core.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %{build} -o %t.out %helper-includes
// RUN: %{build} -o %t.out %helper-includes -Wno-deprecated-declarations
// RUN: %{run} %t.out

#include <sycl/detail/core.hpp>
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/VirtualFunctions/misc/math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This test checks that SYCL math built-in functions work correctly
// inside virtual functions.
//
// RUN: %{build} -o %t.out %helper-includes
// RUN: %{build} -o %t.out %helper-includes -Wno-deprecated-declarations
// RUN: %{run} %t.out

#include <sycl/builtins.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{build} -o %t.out -Wno-deprecated-declarations
// RUN: %{run} %t.out

// The purpose of this test is to check that the forward_progress_guarantee
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// REQUIRES: opencl, cpu
// RUN: %{build} -o %t.out
// RUN: %{build} -o %t.out -Wno-deprecated-declarations
// RUN: %{run} %t.out

// The purpose of this test is to check that the forward_progress_guarantee
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx -fsycl-device-only -S -Xclang -emit-llvm -Xclang -disable-llvm-passes %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
// RUN: %clangxx -fsycl-device-only -S -Wno-deprecated-declarations -Xclang -emit-llvm -Xclang -disable-llvm-passes %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Wno-deprecated-declarations -Xclang -verify %s
// expected-no-diagnostics

#include <sycl/sycl.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx -fsycl-device-only -S -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
// RUN: %clangxx -fsycl-device-only -S -Wno-deprecated-declarations -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Wno-deprecated-declarations -Xclang -verify %s
// expected-no-diagnostics

#include <sycl/sycl.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx -fsycl-device-only -S -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
// RUN: %clangxx -fsycl-device-only -S -Wno-deprecated-declarations -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Wno-deprecated-declarations -Xclang -verify %s
// expected-no-diagnostics

#include <sycl/sycl.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx -fsycl-device-only -S -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
// RUN: %clangxx -fsycl-device-only -S -Wno-deprecated-declarations -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Wno-deprecated-declarations -Xclang -verify %s
// expected-no-diagnostics

#include <sycl/sycl.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx -fsycl-device-only -S -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
// RUN: %clangxx -fsycl-device-only -S -Wno-deprecated-declarations -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Wno-deprecated-declarations -Xclang -verify %s
// expected-no-diagnostics

#include <sycl/sycl.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx -fsycl-device-only -S -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
// RUN: %clangxx -fsycl-device-only -S -Wno-deprecated-declarations -Xclang -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-IR
// RUN: %clangxx -fsycl -fsyntax-only -Wno-deprecated-declarations -Xclang -verify %s
// expected-no-diagnostics

#include <sycl/sycl.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl-device-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s
// RUN: %clangxx -fsycl-device-only -Wno-deprecated-declarations -Xclang -verify -Xclang -verify-ignore-unexpected=note %s

// Tests for warnings when propagated aspects do not match the aspects available
// in a function, as specified through the 'sycl::device_has' property.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-is-device -ferror-limit=0 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s
// RUN: %clangxx -fsycl-device-only -Wno-deprecated-declarations -Xclang -fsycl-is-device -ferror-limit=0 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s

#include <sycl/sycl.hpp>

Expand Down
2 changes: 1 addition & 1 deletion sycl/test/virtual-functions/diagnostics-positive.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl -c -Xclang -verify %s -o %t.ignored
// RUN: %clangxx -fsycl -c -Wno-deprecated-declarations -Xclang -verify %s -o %t.ignored
//
// This test is intended to check that no diagnostics are emitted when a kernel
// performing virtual function calls is submitted with the right properties.
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/virtual-functions/properties-positive.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
// RUN: %clangxx -fsycl -fsyntax-only -Wno-deprecated-declarations -Xclang -verify %s
//
// This test is intended to check that we can successfully compile code that
// uses new properties from the virtual functions extension.
Expand Down
Loading