Skip to content

Commit e4c82cc

Browse files
authored
Signed-off-by: kbobrovs <[email protected]> (#3557)
[ESIMD] Make all simd_view constructors non-public. This addresses long due ESIMD library review comments: // TODO @rolandschulz // {quote} // Why is this and the next constructor public ? Those should only be called // internally by e.g.select, correct ? // {/quote} // TODO @rolandschulz // {quote} // Is this intentional not a correct copy constructor (would need to be const // for that)? I believe we agreed that simd_view would have a deleted copy and // move constructor.Why are they suddenly back ? // {/quote}
1 parent 229c176 commit e4c82cc

File tree

3 files changed

+11
-32
lines changed

3 files changed

+11
-32
lines changed

sycl/include/CL/sycl/INTEL/esimd/esimd.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ using namespace sycl::INTEL::gpu::detail;
2929
///
3030
/// \ingroup sycl_esimd
3131
template <typename Ty, int N> class simd {
32+
template <typename, typename> friend class simd_view;
33+
3234
public:
3335
/// The underlying builtin data type.
3436
using vector_type = detail::vector_type_t<Ty, N>;

sycl/include/CL/sycl/INTEL/esimd/esimd_view.hpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ namespace gpu {
2424
///
2525
/// \ingroup sycl_esimd
2626
template <typename BaseTy, typename RegionTy> class simd_view {
27+
template <typename, int> friend class simd;
28+
template <typename, typename> friend class simd_view;
29+
2730
public:
2831
static_assert(!is_simd_view_v<BaseTy>::value);
2932
// Deduce the corresponding value type from its region type.
@@ -44,31 +47,17 @@ template <typename BaseTy, typename RegionTy> class simd_view {
4447
/// type of the base object type.
4548
using element_type = typename ShapeTy::element_type;
4649

47-
// TODO @rolandschulz
48-
// {quote}
49-
// Why is this and the next constructor public ? Those should only be called
50-
// internally by e.g.select, correct ?
51-
// {/quote}
52-
//
5350
/// @{
5451
/// Constructors.
52+
53+
private:
5554
simd_view(BaseTy &Base, RegionTy Region) : M_base(Base), M_region(Region) {}
5655
simd_view(BaseTy &&Base, RegionTy Region) : M_base(Base), M_region(Region) {}
5756

58-
// TODO @rolandschulz
59-
// {quote}
60-
// Is this intentional not a correct copy constructor (would need to be const
61-
// for that)? I believe we agreed that simd_view would have a deleted copy and
62-
// move constructor.Why are they suddenly back ?
63-
// {/quote}
64-
// TODO @kbobrovs
65-
// copy constructor is still incorrect (no 'const'), move constructor is still
66-
// present.
67-
//
68-
// Disallow copy constructor for simd_view.
69-
simd_view(simd_view &Other) = delete;
70-
simd_view(simd_view &&Other)
71-
: M_base(Other.M_base), M_region(Other.M_region) {}
57+
public:
58+
// Disallow copy and move constructors for simd_view.
59+
simd_view(const simd_view &Other) = delete;
60+
simd_view(simd_view &&Other) = delete;
7261
/// @}
7362

7463
/// Conversion to simd type.

sycl/test/esimd/simd_view.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77

88
using namespace sycl::INTEL::gpu;
99

10-
bool test_simd_view_ctors() __attribute__((sycl_device)) {
11-
simd<int, 16> v0(0, 1);
12-
13-
region1d_t<int, 4, 1> r0(4);
14-
simd_view<simd<int, 16>, region1d_t<int, 4, 1>> ref0(v0, r0);
15-
simd_view<simd<int, 16>, region1d_t<int, 4, 1>> ref1(std::move(ref0));
16-
simd_view<simd<int, 16>, region1d_t<int, 4, 1>> ref2(
17-
std::move(v0.select<4, 1>(8)));
18-
19-
return (ref0[0] == 4) && (ref1[1] == 5) && (ref2[0] == 8);
20-
}
21-
2210
bool test_simd_view_bin_ops() __attribute__((sycl_device)) {
2311
simd<int, 16> v0 = 1;
2412
simd<int, 16> v1 = 2;

0 commit comments

Comments
 (0)