From 48153fb4d402c0182dd612e84ab2c25c87c4e357 Mon Sep 17 00:00:00 2001 From: "Klochkov, Denis" Date: Mon, 24 Feb 2025 11:09:06 +0100 Subject: [PATCH 1/9] [SYCL] logical operation return type is boolean --- sycl/include/sycl/functional.hpp | 18 ++++++++++++++++-- sycl/test/basic_tests/logical_operations.cpp | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 sycl/test/basic_tests/logical_operations.cpp diff --git a/sycl/include/sycl/functional.hpp b/sycl/include/sycl/functional.hpp index 4dae45d392b66..d38071d1ed8ab 100644 --- a/sycl/include/sycl/functional.hpp +++ b/sycl/include/sycl/functional.hpp @@ -24,13 +24,27 @@ template using bit_xor = std::bit_xor; // std:logical_and/std::logical_or with a non-void type returns bool, // sycl requires returning T. template struct logical_and { - T operator()(const T &lhs, const T &rhs) const { return lhs && rhs; } +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + bool +#else + T +#endif + operator()(const T &lhs, const T &rhs) const { + return lhs && rhs; + } }; template <> struct logical_and : std::logical_and {}; template struct logical_or { - T operator()(const T &lhs, const T &rhs) const { return lhs || rhs; } +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + bool +#else + T +#endif + operator()(const T &lhs, const T &rhs) const { + return lhs || rhs; + } }; template <> struct logical_or : std::logical_or {}; diff --git a/sycl/test/basic_tests/logical_operations.cpp b/sycl/test/basic_tests/logical_operations.cpp new file mode 100644 index 0000000000000..4a6f5e8ca406b --- /dev/null +++ b/sycl/test/basic_tests/logical_operations.cpp @@ -0,0 +1,19 @@ +// RUN: %clang -D__INTEL_PREVIEW_BREAKING_CHANGES -fsycl -o - %s +// RUN: %clang -fsycl -o - %s + +#include +#include +#include + +int main() { + const auto logicalAnd = sycl::logical_and(); + const auto logicalOr = sycl::logical_or(); +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + static_assert(std::is_same_v == true); + static_assert(std::is_same_v == true); +#else + static_assert(std::is_same_v == true); + static_assert(std::is_same_v == true); +#endif + return 0; +} From b6df1d91f6c7750abf1fd55beed61b82bbb00aa8 Mon Sep 17 00:00:00 2001 From: "Klochkov, Denis" Date: Thu, 6 Mar 2025 04:21:31 -0800 Subject: [PATCH 2/9] [SYCL] update test to check void types --- sycl/include/sycl/functional.hpp | 37 +++++++++++--------- sycl/test/basic_tests/logical_operations.cpp | 18 +++++++++- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/sycl/include/sycl/functional.hpp b/sycl/include/sycl/functional.hpp index d38071d1ed8ab..d607ad573465e 100644 --- a/sycl/include/sycl/functional.hpp +++ b/sycl/include/sycl/functional.hpp @@ -23,31 +23,34 @@ template using bit_xor = std::bit_xor; // std:logical_and/std::logical_or with a non-void type returns bool, // sycl requires returning T. -template struct logical_and { +template +struct logical_and #ifdef __INTEL_PREVIEW_BREAKING_CHANGES - bool -#else - T + : std::logical_and #endif - operator()(const T &lhs, const T &rhs) const { - return lhs && rhs; - } -}; +{ +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES + T operator()(const T &lhs, const T &rhs) const { return lhs && rhs; } +#endif +}; // namespace _V1 +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES template <> struct logical_and : std::logical_and {}; +#endif -template struct logical_or { +template +struct logical_or #ifdef __INTEL_PREVIEW_BREAKING_CHANGES - bool -#else - T + : std::logical_or #endif - operator()(const T &lhs, const T &rhs) const { - return lhs || rhs; - } -}; - +{ +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES + T operator()(const T &lhs, const T &rhs) const { return lhs || rhs; } +#endif +}; // namespace sycl +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES template <> struct logical_or : std::logical_or {}; +#endif // sycl::minimum definition should be consistent with std::min template struct minimum { diff --git a/sycl/test/basic_tests/logical_operations.cpp b/sycl/test/basic_tests/logical_operations.cpp index 4a6f5e8ca406b..a48d1a4385ff0 100644 --- a/sycl/test/basic_tests/logical_operations.cpp +++ b/sycl/test/basic_tests/logical_operations.cpp @@ -1,5 +1,7 @@ -// RUN: %clang -D__INTEL_PREVIEW_BREAKING_CHANGES -fsycl -o - %s +// RUN: %clang -fpreview-breaking-changes -fsycl -o - %s +// RUN: not %clang -fpreview-breaking-changes -fsycl -DTEST_VOID_TYPES -o - %s // RUN: %clang -fsycl -o - %s +// RUN: not %clang -fsycl -DTEST_VOID_TYPES -o - %s #include #include @@ -14,6 +16,20 @@ int main() { #else static_assert(std::is_same_v == true); static_assert(std::is_same_v == true); +#endif + const auto logicalAndVoid = sycl::logical_and(); + const auto logicalOrVoid = sycl::logical_or(); + + static_assert(std::is_same_v == true); + static_assert(std::is_same_v == true); + +#ifdef TEST_VOID_TYPES + static_assert(std::is_same_v(1), + static_cast(2))), + bool> == true); + static_assert(std::is_same_v(1), + static_cast(2))), + bool> == true); #endif return 0; } From 0c4d35226436cbbe4474c555a22a516e05baf0ed Mon Sep 17 00:00:00 2001 From: "Klochkov, Denis" Date: Mon, 24 Mar 2025 10:00:58 +0100 Subject: [PATCH 3/9] [SYCL] simplify changes --- sycl/include/sycl/functional.hpp | 8 ++++---- sycl/test/basic_tests/logical_operations.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sycl/include/sycl/functional.hpp b/sycl/include/sycl/functional.hpp index d607ad573465e..d357b9173d5af 100644 --- a/sycl/include/sycl/functional.hpp +++ b/sycl/include/sycl/functional.hpp @@ -27,9 +27,9 @@ template struct logical_and #ifdef __INTEL_PREVIEW_BREAKING_CHANGES : std::logical_and -#endif { -#ifndef __INTEL_PREVIEW_BREAKING_CHANGES +#else +{ T operator()(const T &lhs, const T &rhs) const { return lhs && rhs; } #endif }; // namespace _V1 @@ -42,9 +42,9 @@ template struct logical_or #ifdef __INTEL_PREVIEW_BREAKING_CHANGES : std::logical_or -#endif { -#ifndef __INTEL_PREVIEW_BREAKING_CHANGES +#else +{ T operator()(const T &lhs, const T &rhs) const { return lhs || rhs; } #endif }; // namespace sycl diff --git a/sycl/test/basic_tests/logical_operations.cpp b/sycl/test/basic_tests/logical_operations.cpp index a48d1a4385ff0..86f9fdef04939 100644 --- a/sycl/test/basic_tests/logical_operations.cpp +++ b/sycl/test/basic_tests/logical_operations.cpp @@ -1,7 +1,7 @@ // RUN: %clang -fpreview-breaking-changes -fsycl -o - %s // RUN: not %clang -fpreview-breaking-changes -fsycl -DTEST_VOID_TYPES -o - %s // RUN: %clang -fsycl -o - %s -// RUN: not %clang -fsycl -DTEST_VOID_TYPES -o - %s +// RUN: not %clang -fsycl -fsyntax-only -DTEST_VOID_TYPES -o - %s #include #include From b1d3543c76716c9b2e8bde723c685fdbf86b511a Mon Sep 17 00:00:00 2001 From: "Klochkov, Denis" Date: Thu, 27 Mar 2025 12:08:27 +0100 Subject: [PATCH 4/9] [SYCL] crate separate negative test for logical operations with type void --- sycl/include/sycl/functional.hpp | 28 ++++++------------- sycl/test/basic_tests/logical_operations.cpp | 16 ----------- .../logical_operations_void_types.cpp | 16 +++++++++++ 3 files changed, 25 insertions(+), 35 deletions(-) create mode 100644 sycl/test/basic_tests/logical_operations_void_types.cpp diff --git a/sycl/include/sycl/functional.hpp b/sycl/include/sycl/functional.hpp index d357b9173d5af..e0201e0a64a40 100644 --- a/sycl/include/sycl/functional.hpp +++ b/sycl/include/sycl/functional.hpp @@ -23,33 +23,23 @@ template using bit_xor = std::bit_xor; // std:logical_and/std::logical_or with a non-void type returns bool, // sycl requires returning T. -template -struct logical_and #ifdef __INTEL_PREVIEW_BREAKING_CHANGES - : std::logical_and -{ +template struct logical_and : std::logical_and {}; +template struct logical_or : std::logical_or {}; + #else -{ +template struct logical_and { T operator()(const T &lhs, const T &rhs) const { return lhs && rhs; } -#endif -}; // namespace _V1 +}; -#ifndef __INTEL_PREVIEW_BREAKING_CHANGES template <> struct logical_and : std::logical_and {}; -#endif -template -struct logical_or -#ifdef __INTEL_PREVIEW_BREAKING_CHANGES - : std::logical_or -{ -#else -{ +template struct logical_or { T operator()(const T &lhs, const T &rhs) const { return lhs || rhs; } -#endif -}; // namespace sycl -#ifndef __INTEL_PREVIEW_BREAKING_CHANGES +}; + template <> struct logical_or : std::logical_or {}; + #endif // sycl::minimum definition should be consistent with std::min diff --git a/sycl/test/basic_tests/logical_operations.cpp b/sycl/test/basic_tests/logical_operations.cpp index 86f9fdef04939..2cd6f7b2c656e 100644 --- a/sycl/test/basic_tests/logical_operations.cpp +++ b/sycl/test/basic_tests/logical_operations.cpp @@ -1,7 +1,5 @@ // RUN: %clang -fpreview-breaking-changes -fsycl -o - %s -// RUN: not %clang -fpreview-breaking-changes -fsycl -DTEST_VOID_TYPES -o - %s // RUN: %clang -fsycl -o - %s -// RUN: not %clang -fsycl -fsyntax-only -DTEST_VOID_TYPES -o - %s #include #include @@ -16,20 +14,6 @@ int main() { #else static_assert(std::is_same_v == true); static_assert(std::is_same_v == true); -#endif - const auto logicalAndVoid = sycl::logical_and(); - const auto logicalOrVoid = sycl::logical_or(); - - static_assert(std::is_same_v == true); - static_assert(std::is_same_v == true); - -#ifdef TEST_VOID_TYPES - static_assert(std::is_same_v(1), - static_cast(2))), - bool> == true); - static_assert(std::is_same_v(1), - static_cast(2))), - bool> == true); #endif return 0; } diff --git a/sycl/test/basic_tests/logical_operations_void_types.cpp b/sycl/test/basic_tests/logical_operations_void_types.cpp new file mode 100644 index 0000000000000..044abe3c27aea --- /dev/null +++ b/sycl/test/basic_tests/logical_operations_void_types.cpp @@ -0,0 +1,16 @@ + +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s +// RUN: %clangxx -fsycl -fpreview-breaking-changes -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s + +#include +#include +#include + + +const auto logicalAndVoid = sycl::logical_and(); +const auto logicalOrVoid = sycl::logical_or(); + +// expected-error@+1 {{}} +static_assert(std::is_same_v(1), static_cast(2))), bool> == true); +// expected-error@+1 {{}} +static_assert(std::is_same_v(1), static_cast(2))), bool> == true); From df2fcb2076ed3baf2bce22837e88cdd5d61a0bae Mon Sep 17 00:00:00 2001 From: "Klochkov, Denis" Date: Thu, 27 Mar 2025 14:38:18 +0100 Subject: [PATCH 5/9] [SYCL] update formatting --- sycl/test/basic_tests/logical_operations_void_types.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sycl/test/basic_tests/logical_operations_void_types.cpp b/sycl/test/basic_tests/logical_operations_void_types.cpp index 044abe3c27aea..4d182bae38413 100644 --- a/sycl/test/basic_tests/logical_operations_void_types.cpp +++ b/sycl/test/basic_tests/logical_operations_void_types.cpp @@ -6,11 +6,14 @@ #include #include - const auto logicalAndVoid = sycl::logical_and(); const auto logicalOrVoid = sycl::logical_or(); // expected-error@+1 {{}} -static_assert(std::is_same_v(1), static_cast(2))), bool> == true); +static_assert(std::is_same_v(1), + static_cast(2))), + bool> == true); // expected-error@+1 {{}} -static_assert(std::is_same_v(1), static_cast(2))), bool> == true); +static_assert(std::is_same_v(1), + static_cast(2))), + bool> == true); From fe3b943eb8a5f3c0af277cf0ffb5ec0d8ab3c33c Mon Sep 17 00:00:00 2001 From: "Klochkov, Denis" Date: Mon, 14 Apr 2025 11:02:00 +0200 Subject: [PATCH 6/9] [SYCL] simplify expression to test logfical operations with void types --- sycl/test/basic_tests/logical_operations_void_types.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sycl/test/basic_tests/logical_operations_void_types.cpp b/sycl/test/basic_tests/logical_operations_void_types.cpp index 4d182bae38413..92142673d3d91 100644 --- a/sycl/test/basic_tests/logical_operations_void_types.cpp +++ b/sycl/test/basic_tests/logical_operations_void_types.cpp @@ -2,7 +2,6 @@ // RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s // RUN: %clangxx -fsycl -fpreview-breaking-changes -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s -#include #include #include @@ -10,10 +9,6 @@ const auto logicalAndVoid = sycl::logical_and(); const auto logicalOrVoid = sycl::logical_or(); // expected-error@+1 {{}} -static_assert(std::is_same_v(1), - static_cast(2))), - bool> == true); +logicalAndVoid(static_cast(1), static_cast(2)); // expected-error@+1 {{}} -static_assert(std::is_same_v(1), - static_cast(2))), - bool> == true); +logicalOrVoid(static_cast(1), static_cast(2)); From 89462dffc292ab476707e4e85d2813701955470a Mon Sep 17 00:00:00 2001 From: dklochkov-intel Date: Mon, 14 Apr 2025 11:54:46 +0200 Subject: [PATCH 7/9] [SYCL] avoid true in test expressions Co-authored-by: Steffen Larsen --- sycl/test/basic_tests/logical_operations.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sycl/test/basic_tests/logical_operations.cpp b/sycl/test/basic_tests/logical_operations.cpp index 2cd6f7b2c656e..994e7ff0d7e36 100644 --- a/sycl/test/basic_tests/logical_operations.cpp +++ b/sycl/test/basic_tests/logical_operations.cpp @@ -9,11 +9,11 @@ int main() { const auto logicalAnd = sycl::logical_and(); const auto logicalOr = sycl::logical_or(); #ifdef __INTEL_PREVIEW_BREAKING_CHANGES - static_assert(std::is_same_v == true); - static_assert(std::is_same_v == true); + static_assert(std::is_same_v); + static_assert(std::is_same_v); #else - static_assert(std::is_same_v == true); - static_assert(std::is_same_v == true); + static_assert(std::is_same_v); + static_assert(std::is_same_v); #endif return 0; } From 025456a1fad14095578cc6cf49ea800e2c3b7014 Mon Sep 17 00:00:00 2001 From: "Klochkov, Denis" Date: Mon, 14 Apr 2025 18:10:51 +0200 Subject: [PATCH 8/9] [SYCL] do not create separate test for void types --- sycl/test/basic_tests/logical_operations.cpp | 6 ++++++ .../basic_tests/logical_operations_void_types.cpp | 14 -------------- 2 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 sycl/test/basic_tests/logical_operations_void_types.cpp diff --git a/sycl/test/basic_tests/logical_operations.cpp b/sycl/test/basic_tests/logical_operations.cpp index 994e7ff0d7e36..e59377e7f184e 100644 --- a/sycl/test/basic_tests/logical_operations.cpp +++ b/sycl/test/basic_tests/logical_operations.cpp @@ -8,12 +8,18 @@ int main() { const auto logicalAnd = sycl::logical_and(); const auto logicalOr = sycl::logical_or(); + const auto logicalAndVoid = sycl::logical_and(); + const auto logicalOrVoid = sycl::logical_or(); #ifdef __INTEL_PREVIEW_BREAKING_CHANGES static_assert(std::is_same_v); static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); #else static_assert(std::is_same_v); static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); #endif return 0; } diff --git a/sycl/test/basic_tests/logical_operations_void_types.cpp b/sycl/test/basic_tests/logical_operations_void_types.cpp deleted file mode 100644 index 92142673d3d91..0000000000000 --- a/sycl/test/basic_tests/logical_operations_void_types.cpp +++ /dev/null @@ -1,14 +0,0 @@ - -// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s -// RUN: %clangxx -fsycl -fpreview-breaking-changes -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s - -#include -#include - -const auto logicalAndVoid = sycl::logical_and(); -const auto logicalOrVoid = sycl::logical_or(); - -// expected-error@+1 {{}} -logicalAndVoid(static_cast(1), static_cast(2)); -// expected-error@+1 {{}} -logicalOrVoid(static_cast(1), static_cast(2)); From b800256a8a1af944e9815b032a34436c2581f7a6 Mon Sep 17 00:00:00 2001 From: "Klochkov, Denis" Date: Mon, 14 Apr 2025 18:17:13 +0200 Subject: [PATCH 9/9] [SYCL] use -fsynatx-only --- sycl/test/basic_tests/logical_operations.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/test/basic_tests/logical_operations.cpp b/sycl/test/basic_tests/logical_operations.cpp index e59377e7f184e..e040470cecd04 100644 --- a/sycl/test/basic_tests/logical_operations.cpp +++ b/sycl/test/basic_tests/logical_operations.cpp @@ -1,5 +1,5 @@ -// RUN: %clang -fpreview-breaking-changes -fsycl -o - %s -// RUN: %clang -fsycl -o - %s +// RUN: %clang -fpreview-breaking-changes -fsycl -fsyntax-only %s +// RUN: %clang -fsycl -fsyntax-only %s #include #include