Skip to content

Commit b1f4cf7

Browse files
[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).
1 parent 98d86d0 commit b1f4cf7

25 files changed

+39
-11
lines changed

sycl/include/sycl/group_algorithm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <sycl/known_identity.hpp> // for known_identity_v
2222
#include <sycl/nd_item.hpp> // for nd_item
2323
#include <sycl/range.hpp> // for range
24-
#include <sycl/sub_group.hpp> // for sub_group
2524
#include <sycl/types.hpp> // for vec
2625

2726
#ifdef __SYCL_DEVICE_ONLY__
@@ -37,6 +36,7 @@
3736

3837
namespace sycl {
3938
inline namespace _V1 {
39+
struct sub_group;
4040
namespace detail {
4141

4242
// ---- linear_id_to_id

sycl/include/sycl/nd_item.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
#include <sycl/nd_range.hpp> // for nd_range
2626
#include <sycl/pointers.hpp> // for decorated_global_ptr, decor...
2727
#include <sycl/range.hpp> // for range
28-
#include <sycl/sub_group.hpp> // for sub_group
2928

3029
#include <cstddef> // for size_t
3130
#include <stdint.h> // for uint32_t
3231
#include <type_traits> // for enable_if_t, remove_const_t
3332

3433
namespace sycl {
3534
inline namespace _V1 {
35+
struct sub_group;
3636
namespace detail {
3737
class Builder;
3838
}
@@ -117,7 +117,8 @@ template <int Dimensions = 1> class nd_item {
117117
get_group_range(), get_group_id());
118118
}
119119

120-
sub_group get_sub_group() const { return sub_group(); }
120+
// Out-of-class definition in sub_group.hpp
121+
sub_group get_sub_group() const;
121122

122123
size_t __SYCL_ALWAYS_INLINE get_group(int Dimension) const {
123124
size_t Id = get_group_id()[Dimension];

sycl/include/sycl/stream.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
#include <sycl/half_type.hpp> // for half, operator-, operator<
2525
#include <sycl/handler.hpp> // for handler
2626
#include <sycl/item.hpp> // for item
27-
#include <sycl/nd_item.hpp> // for nd_item
28-
#include <sycl/nd_range.hpp> // for nd_range
29-
#include <sycl/property_list.hpp> // for property_list
30-
#include <sycl/range.hpp> // for range
31-
#include <sycl/sub_group.hpp> // for multi_ptr
32-
#include <sycl/types.hpp> // for vec, SwizzleOp
27+
#include <sycl/multi_ptr.hpp>
28+
#include <sycl/nd_item.hpp> // for nd_item
29+
#include <sycl/nd_range.hpp> // for nd_range
30+
#include <sycl/property_list.hpp> // for property_list
31+
#include <sycl/range.hpp> // for range
32+
#include <sycl/types.hpp> // for vec, SwizzleOp
3333

3434
#include <cstddef> // for size_t, byte
3535
#include <memory> // for hash, shared_ptr

sycl/include/sycl/sub_group.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#include <sycl/id.hpp> // for id
1717
#include <sycl/memory_enums.hpp> // for memory_scope
1818
#include <sycl/multi_ptr.hpp> // for multi_ptr
19-
#include <sycl/range.hpp> // for range
19+
#include <sycl/nd_item.hpp>
20+
#include <sycl/range.hpp> // for range
2021

2122
#include <stdint.h> // for uint32_t
2223
#include <tuple> // for _Swallow_assign, ignore
@@ -663,5 +664,10 @@ struct sub_group {
663664
friend sub_group ext::oneapi::this_work_item::get_sub_group();
664665
sub_group() = default;
665666
};
667+
668+
template <int Dimensions> sub_group nd_item<Dimensions>::get_sub_group() const {
669+
return sub_group();
670+
}
671+
666672
} // namespace _V1
667673
} // namespace sycl

sycl/test-e2e/AOT/reqd-sg-size.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <iostream>
1515

1616
#include <sycl/detail/core.hpp>
17+
#include <sycl/sub_group.hpp>
1718

1819
using namespace sycl;
1920

sycl/test-e2e/Basic/linear-sub_group.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <cstdlib>
1515
#include <iostream>
1616
#include <sycl/detail/core.hpp>
17+
#include <sycl/sub_group.hpp>
1718

1819
using namespace sycl;
1920

sycl/test-e2e/Basic/sub_group_size_prop.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %{run} %t.out
33

44
#include <sycl/detail/core.hpp>
5+
#include <sycl/sub_group.hpp>
56

67
#include <iostream>
78

sycl/test-e2e/Graph/Inputs/sub_group_prop.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This test is adapted from "test-e2e/Basic/sub_group_size_prop.cpp"
22

33
#include "../graph_common.hpp"
4+
#include <sycl/sub_group.hpp>
45

56
enum class Variant { Function, Functor, FunctorAndProperty };
67

sycl/test-e2e/GroupAlgorithm/SYCL2020/group_sort/common.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
#include <sycl/detail/core.hpp>
33
#include <sycl/ext/oneapi/experimental/group_sort.hpp>
4+
#include <sycl/sub_group.hpp>
45

56
#pragma once
67

sycl/test-e2e/GroupAlgorithm/SYCL2020/permute_select.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <iostream>
1111
#include <sycl/detail/core.hpp>
1212
#include <sycl/group_algorithm.hpp>
13+
#include <sycl/sub_group.hpp>
1314
template <typename T, int N> class sycl_subgr;
1415

1516
using namespace sycl;

0 commit comments

Comments
 (0)