From b1f4cf7689488d3ff23b227d1dc200cf78ceb0f9 Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Tue, 12 Nov 2024 18:07:27 +0100 Subject: [PATCH] [SYCL] Make `core.hpp` independent from `sub_group.hpp` (#16044) This PR will also allow us to remove `sub_group.hpp` from `sycl.hpp` to make the former an opt-in header (for better compile-times). --- sycl/include/sycl/group_algorithm.hpp | 2 +- sycl/include/sycl/nd_item.hpp | 5 +++-- sycl/include/sycl/stream.hpp | 12 ++++++------ sycl/include/sycl/sub_group.hpp | 8 +++++++- sycl/test-e2e/AOT/reqd-sg-size.cpp | 1 + sycl/test-e2e/Basic/linear-sub_group.cpp | 1 + sycl/test-e2e/Basic/sub_group_size_prop.cpp | 1 + sycl/test-e2e/Graph/Inputs/sub_group_prop.cpp | 1 + .../GroupAlgorithm/SYCL2020/group_sort/common.hpp | 1 + .../GroupAlgorithm/SYCL2020/permute_select.hpp | 1 + .../GroupAlgorithm/SYCL2020/shift_left_right.hpp | 1 + sycl/test-e2e/GroupAlgorithm/different_types.cpp | 1 + .../GroupAlgorithm/load_store/partial_sg.cpp | 1 + sycl/test-e2e/GroupAlgorithm/reduce_sycl2020.cpp | 3 +++ sycl/test-e2e/GroupAlgorithm/shuffle_marray.cpp | 1 + .../Reduction/reduce_over_sub_group.cpp | 1 + sycl/test-e2e/SubGroup/helper.hpp | 1 + sycl/test-e2e/SubGroup/sub_group_as.cpp | 1 + .../SubGroup/sub_group_by_value_semantics.cpp | 1 + sycl/test-e2e/SubGroup/sub_groups_sycl2020.cpp | 1 + sycl/test-e2e/SubGroupMask/Basic.cpp | 1 + sycl/test-e2e/SubGroupMask/GroupSize.cpp | 1 + sycl/test-e2e/SubGroupMask/sub_group_mask_ver2.cpp | 1 + sycl/test-e2e/XPTI/kernel/content.cpp | 1 + sycl/test/include_deps/sycl_detail_core.hpp.cpp | 1 - 25 files changed, 39 insertions(+), 11 deletions(-) diff --git a/sycl/include/sycl/group_algorithm.hpp b/sycl/include/sycl/group_algorithm.hpp index 14eb2ea011587..ed373a95eef41 100644 --- a/sycl/include/sycl/group_algorithm.hpp +++ b/sycl/include/sycl/group_algorithm.hpp @@ -21,7 +21,6 @@ #include // for known_identity_v #include // for nd_item #include // for range -#include // for sub_group #include // for vec #ifdef __SYCL_DEVICE_ONLY__ @@ -37,6 +36,7 @@ namespace sycl { inline namespace _V1 { +struct sub_group; namespace detail { // ---- linear_id_to_id diff --git a/sycl/include/sycl/nd_item.hpp b/sycl/include/sycl/nd_item.hpp index 3abd919a2a09a..f1a5bfc63c917 100644 --- a/sycl/include/sycl/nd_item.hpp +++ b/sycl/include/sycl/nd_item.hpp @@ -25,7 +25,6 @@ #include // for nd_range #include // for decorated_global_ptr, decor... #include // for range -#include // for sub_group #include // for size_t #include // for uint32_t @@ -33,6 +32,7 @@ namespace sycl { inline namespace _V1 { +struct sub_group; namespace detail { class Builder; } @@ -117,7 +117,8 @@ template class nd_item { get_group_range(), get_group_id()); } - sub_group get_sub_group() const { return sub_group(); } + // Out-of-class definition in sub_group.hpp + sub_group get_sub_group() const; size_t __SYCL_ALWAYS_INLINE get_group(int Dimension) const { size_t Id = get_group_id()[Dimension]; diff --git a/sycl/include/sycl/stream.hpp b/sycl/include/sycl/stream.hpp index 2b18a8ef4b423..9b8483679197f 100644 --- a/sycl/include/sycl/stream.hpp +++ b/sycl/include/sycl/stream.hpp @@ -24,12 +24,12 @@ #include // for half, operator-, operator< #include // for handler #include // for item -#include // for nd_item -#include // for nd_range -#include // for property_list -#include // for range -#include // for multi_ptr -#include // for vec, SwizzleOp +#include +#include // for nd_item +#include // for nd_range +#include // for property_list +#include // for range +#include // for vec, SwizzleOp #include // for size_t, byte #include // for hash, shared_ptr diff --git a/sycl/include/sycl/sub_group.hpp b/sycl/include/sycl/sub_group.hpp index fe79ec461b8a6..379e0cf953975 100644 --- a/sycl/include/sycl/sub_group.hpp +++ b/sycl/include/sycl/sub_group.hpp @@ -16,7 +16,8 @@ #include // for id #include // for memory_scope #include // for multi_ptr -#include // for range +#include +#include // for range #include // for uint32_t #include // for _Swallow_assign, ignore @@ -663,5 +664,10 @@ struct sub_group { friend sub_group ext::oneapi::this_work_item::get_sub_group(); sub_group() = default; }; + +template sub_group nd_item::get_sub_group() const { + return sub_group(); +} + } // namespace _V1 } // namespace sycl diff --git a/sycl/test-e2e/AOT/reqd-sg-size.cpp b/sycl/test-e2e/AOT/reqd-sg-size.cpp index c2ac12de707cf..6f7e425648b26 100644 --- a/sycl/test-e2e/AOT/reqd-sg-size.cpp +++ b/sycl/test-e2e/AOT/reqd-sg-size.cpp @@ -14,6 +14,7 @@ #include #include +#include using namespace sycl; diff --git a/sycl/test-e2e/Basic/linear-sub_group.cpp b/sycl/test-e2e/Basic/linear-sub_group.cpp index a7b5f8c720732..684ff7d7fbdcc 100644 --- a/sycl/test-e2e/Basic/linear-sub_group.cpp +++ b/sycl/test-e2e/Basic/linear-sub_group.cpp @@ -14,6 +14,7 @@ #include #include #include +#include using namespace sycl; diff --git a/sycl/test-e2e/Basic/sub_group_size_prop.cpp b/sycl/test-e2e/Basic/sub_group_size_prop.cpp index 36804dc4a8083..6da86acd09c45 100644 --- a/sycl/test-e2e/Basic/sub_group_size_prop.cpp +++ b/sycl/test-e2e/Basic/sub_group_size_prop.cpp @@ -2,6 +2,7 @@ // RUN: %{run} %t.out #include +#include #include diff --git a/sycl/test-e2e/Graph/Inputs/sub_group_prop.cpp b/sycl/test-e2e/Graph/Inputs/sub_group_prop.cpp index 7d85a28416e92..7c0bfe5161530 100644 --- a/sycl/test-e2e/Graph/Inputs/sub_group_prop.cpp +++ b/sycl/test-e2e/Graph/Inputs/sub_group_prop.cpp @@ -1,6 +1,7 @@ // This test is adapted from "test-e2e/Basic/sub_group_size_prop.cpp" #include "../graph_common.hpp" +#include enum class Variant { Function, Functor, FunctorAndProperty }; diff --git a/sycl/test-e2e/GroupAlgorithm/SYCL2020/group_sort/common.hpp b/sycl/test-e2e/GroupAlgorithm/SYCL2020/group_sort/common.hpp index 4466c23161755..c15a908f42cc9 100644 --- a/sycl/test-e2e/GroupAlgorithm/SYCL2020/group_sort/common.hpp +++ b/sycl/test-e2e/GroupAlgorithm/SYCL2020/group_sort/common.hpp @@ -1,6 +1,7 @@ #include #include +#include #pragma once diff --git a/sycl/test-e2e/GroupAlgorithm/SYCL2020/permute_select.hpp b/sycl/test-e2e/GroupAlgorithm/SYCL2020/permute_select.hpp index c4e99cf414e49..6484a15118b6a 100644 --- a/sycl/test-e2e/GroupAlgorithm/SYCL2020/permute_select.hpp +++ b/sycl/test-e2e/GroupAlgorithm/SYCL2020/permute_select.hpp @@ -10,6 +10,7 @@ #include #include #include +#include template class sycl_subgr; using namespace sycl; diff --git a/sycl/test-e2e/GroupAlgorithm/SYCL2020/shift_left_right.hpp b/sycl/test-e2e/GroupAlgorithm/SYCL2020/shift_left_right.hpp index 2d10f00a0563b..99397ddbded20 100644 --- a/sycl/test-e2e/GroupAlgorithm/SYCL2020/shift_left_right.hpp +++ b/sycl/test-e2e/GroupAlgorithm/SYCL2020/shift_left_right.hpp @@ -9,6 +9,7 @@ #include "helpers.hpp" #include #include +#include template class sycl_subgr; using namespace sycl; diff --git a/sycl/test-e2e/GroupAlgorithm/different_types.cpp b/sycl/test-e2e/GroupAlgorithm/different_types.cpp index abc873a5e21a4..c0f7697825b5f 100644 --- a/sycl/test-e2e/GroupAlgorithm/different_types.cpp +++ b/sycl/test-e2e/GroupAlgorithm/different_types.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include using namespace sycl; diff --git a/sycl/test-e2e/GroupAlgorithm/load_store/partial_sg.cpp b/sycl/test-e2e/GroupAlgorithm/load_store/partial_sg.cpp index d01fbf4e6b7ae..9ca21ae8a2ee9 100644 --- a/sycl/test-e2e/GroupAlgorithm/load_store/partial_sg.cpp +++ b/sycl/test-e2e/GroupAlgorithm/load_store/partial_sg.cpp @@ -3,6 +3,7 @@ #include #include +#include #include diff --git a/sycl/test-e2e/GroupAlgorithm/reduce_sycl2020.cpp b/sycl/test-e2e/GroupAlgorithm/reduce_sycl2020.cpp index ea3cfe89751f8..dce0ee222d864 100644 --- a/sycl/test-e2e/GroupAlgorithm/reduce_sycl2020.cpp +++ b/sycl/test-e2e/GroupAlgorithm/reduce_sycl2020.cpp @@ -6,6 +6,9 @@ // UNSUPPORTED: arch-intel_gpu_pvc && !igc-dev #include "support.h" + +#include + #include #include #include diff --git a/sycl/test-e2e/GroupAlgorithm/shuffle_marray.cpp b/sycl/test-e2e/GroupAlgorithm/shuffle_marray.cpp index ea24b98cf367e..68624868980a4 100644 --- a/sycl/test-e2e/GroupAlgorithm/shuffle_marray.cpp +++ b/sycl/test-e2e/GroupAlgorithm/shuffle_marray.cpp @@ -6,6 +6,7 @@ #include #include #include +#include static constexpr size_t NumElems = 5; static constexpr size_t NumWorkItems = 64; diff --git a/sycl/test-e2e/PerformanceTests/Reduction/reduce_over_sub_group.cpp b/sycl/test-e2e/PerformanceTests/Reduction/reduce_over_sub_group.cpp index d5c1614ed9435..c28a3406b33c0 100644 --- a/sycl/test-e2e/PerformanceTests/Reduction/reduce_over_sub_group.cpp +++ b/sycl/test-e2e/PerformanceTests/Reduction/reduce_over_sub_group.cpp @@ -3,6 +3,7 @@ // RUN: %{run} %t.out #include +#include #include diff --git a/sycl/test-e2e/SubGroup/helper.hpp b/sycl/test-e2e/SubGroup/helper.hpp index 2a88bb0f5652e..a164f70c17ea9 100644 --- a/sycl/test-e2e/SubGroup/helper.hpp +++ b/sycl/test-e2e/SubGroup/helper.hpp @@ -10,6 +10,7 @@ #include #include #include +#include using namespace sycl; diff --git a/sycl/test-e2e/SubGroup/sub_group_as.cpp b/sycl/test-e2e/SubGroup/sub_group_as.cpp index 6924ff8686004..67b6102ff8300 100644 --- a/sycl/test-e2e/SubGroup/sub_group_as.cpp +++ b/sycl/test-e2e/SubGroup/sub_group_as.cpp @@ -9,6 +9,7 @@ #include #include #include +#include int main(int argc, char *argv[]) { sycl::queue queue; diff --git a/sycl/test-e2e/SubGroup/sub_group_by_value_semantics.cpp b/sycl/test-e2e/SubGroup/sub_group_by_value_semantics.cpp index f10b0a9a733a6..e8ddc8eddced3 100644 --- a/sycl/test-e2e/SubGroup/sub_group_by_value_semantics.cpp +++ b/sycl/test-e2e/SubGroup/sub_group_by_value_semantics.cpp @@ -2,6 +2,7 @@ // RUN: %{run} %t.out #include +#include int main() { bool result = true; diff --git a/sycl/test-e2e/SubGroup/sub_groups_sycl2020.cpp b/sycl/test-e2e/SubGroup/sub_groups_sycl2020.cpp index a7d4c6493b8b5..904555e9f5e86 100644 --- a/sycl/test-e2e/SubGroup/sub_groups_sycl2020.cpp +++ b/sycl/test-e2e/SubGroup/sub_groups_sycl2020.cpp @@ -2,6 +2,7 @@ // RUN: %{run} %t.out #include +#include int main() { sycl::queue Q; diff --git a/sycl/test-e2e/SubGroupMask/Basic.cpp b/sycl/test-e2e/SubGroupMask/Basic.cpp index 40526c7ccad7e..627db85c082d1 100644 --- a/sycl/test-e2e/SubGroupMask/Basic.cpp +++ b/sycl/test-e2e/SubGroupMask/Basic.cpp @@ -16,6 +16,7 @@ #include #include +#include #include using namespace sycl; diff --git a/sycl/test-e2e/SubGroupMask/GroupSize.cpp b/sycl/test-e2e/SubGroupMask/GroupSize.cpp index 827dd6d351274..ca5ad344fea5c 100644 --- a/sycl/test-e2e/SubGroupMask/GroupSize.cpp +++ b/sycl/test-e2e/SubGroupMask/GroupSize.cpp @@ -15,6 +15,7 @@ #include #include +#include #include diff --git a/sycl/test-e2e/SubGroupMask/sub_group_mask_ver2.cpp b/sycl/test-e2e/SubGroupMask/sub_group_mask_ver2.cpp index b3d2d0be1ea66..5b151623f840c 100644 --- a/sycl/test-e2e/SubGroupMask/sub_group_mask_ver2.cpp +++ b/sycl/test-e2e/SubGroupMask/sub_group_mask_ver2.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #define TEST_ON_DEVICE(TEST_BODY) \ { \ diff --git a/sycl/test-e2e/XPTI/kernel/content.cpp b/sycl/test-e2e/XPTI/kernel/content.cpp index 0e68788100a2a..54a52e8dd892c 100644 --- a/sycl/test-e2e/XPTI/kernel/content.cpp +++ b/sycl/test-e2e/XPTI/kernel/content.cpp @@ -14,6 +14,7 @@ #include #include #include +#include using namespace sycl; int main() { diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index 00497b2ea0974..c7f905b222dd9 100644 --- a/sycl/test/include_deps/sycl_detail_core.hpp.cpp +++ b/sycl/test/include_deps/sycl_detail_core.hpp.cpp @@ -128,7 +128,6 @@ // CHECK-NEXT: kernel_handler.hpp // CHECK-NEXT: nd_item.hpp // CHECK-NEXT: nd_range.hpp -// CHECK-NEXT: sub_group.hpp // CHECK-NEXT: device.hpp // CHECK-NEXT: kernel_bundle_enums.hpp // CHECK-NEXT: event.hpp