Skip to content

Commit 5229089

Browse files
authored
[ESIMD] Add 'const' specifier to non-modifier methods (#4781)
This patch also included some NFC changes removing the old sycl::detail utilities that temporarily substituted c++14 type-trait utilities. Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent 64f5e70 commit 5229089

File tree

4 files changed

+280
-300
lines changed

4 files changed

+280
-300
lines changed

sycl/include/sycl/ext/intel/experimental/esimd/detail/simd_mask_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class simd_mask_impl
112112

113113
template <class T1 = simd_mask_impl,
114114
class = std::enable_if_t<T1::length == 1>>
115-
operator bool() {
115+
operator bool() const {
116116
return base_type::data()[0] != 0;
117117
}
118118
};

sycl/include/sycl/ext/intel/experimental/esimd/detail/simd_obj_impl.hpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
317317

318318
/// \tparam Rep is number of times region has to be replicated.
319319
/// \return replicated simd_obj_impl instance.
320-
template <int Rep> resize_a_simd_type_t<Derived, Rep * N> replicate() {
320+
template <int Rep> resize_a_simd_type_t<Derived, Rep * N> replicate() const {
321321
return replicate<Rep, N>(0);
322322
}
323323

@@ -327,7 +327,7 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
327327
/// \return replicated simd_obj_impl instance.
328328
template <int Rep, int W>
329329
__SYCL_DEPRECATED("use simd_obj_impl::replicate_w")
330-
resize_a_simd_type_t<Derived, Rep * W> replicate(uint16_t Offset) {
330+
resize_a_simd_type_t<Derived, Rep * W> replicate(uint16_t Offset) const {
331331
return replicate_w<Rep, W>(Offset);
332332
}
333333

@@ -336,7 +336,7 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
336336
/// \param Offset is offset in number of elements in src region.
337337
/// \return replicated simd_obj_impl instance.
338338
template <int Rep, int W>
339-
resize_a_simd_type_t<Derived, Rep * W> replicate_w(uint16_t Offset) {
339+
resize_a_simd_type_t<Derived, Rep * W> replicate_w(uint16_t Offset) const {
340340
return replicate_vs_w_hs<Rep, 0, W, 1>(Offset);
341341
}
342342

@@ -347,7 +347,7 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
347347
/// \return replicated simd_obj_impl instance.
348348
template <int Rep, int VS, int W>
349349
__SYCL_DEPRECATED("use simd_obj_impl::replicate_vs_w")
350-
resize_a_simd_type_t<Derived, Rep * W> replicate(uint16_t Offset) {
350+
resize_a_simd_type_t<Derived, Rep * W> replicate(uint16_t Offset) const {
351351
return replicate_vs_w<Rep, VS, W>(Offset);
352352
}
353353

@@ -357,7 +357,7 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
357357
/// \param Offset offset in number of elements in src region.
358358
/// \return replicated simd_obj_impl instance.
359359
template <int Rep, int VS, int W>
360-
resize_a_simd_type_t<Derived, Rep * W> replicate_vs_w(uint16_t Offset) {
360+
resize_a_simd_type_t<Derived, Rep * W> replicate_vs_w(uint16_t Offset) const {
361361
return replicate_vs_w_hs<Rep, VS, W, 1>(Offset);
362362
}
363363

@@ -369,7 +369,7 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
369369
/// \return replicated simd_obj_impl instance.
370370
template <int Rep, int VS, int W, int HS>
371371
__SYCL_DEPRECATED("use simd_obj_impl::replicate_vs_w_hs")
372-
resize_a_simd_type_t<Derived, Rep * W> replicate(uint16_t Offset) {
372+
resize_a_simd_type_t<Derived, Rep * W> replicate(uint16_t Offset) const {
373373
return replicate_vs_w_hs<Rep, VS, W, HS>(Offset);
374374
}
375375

@@ -380,7 +380,8 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
380380
/// \param Offset is offset in number of elements in src region.
381381
/// \return replicated simd_obj_impl instance.
382382
template <int Rep, int VS, int W, int HS>
383-
resize_a_simd_type_t<Derived, Rep * W> replicate_vs_w_hs(uint16_t Offset) {
383+
resize_a_simd_type_t<Derived, Rep * W>
384+
replicate_vs_w_hs(uint16_t Offset) const {
384385
return __esimd_rdregion<Ty, N, Rep * W, VS, W, HS, N>(data(),
385386
Offset * sizeof(Ty));
386387
}
@@ -390,17 +391,17 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
390391
///
391392
/// \return 1 if any element is set, 0 otherwise.
392393
template <typename T1 = Ty,
393-
typename = sycl::detail::enable_if_t<std::is_integral<T1>::value>>
394-
uint16_t any() {
394+
typename = std::enable_if_t<std::is_integral<T1>::value>>
395+
uint16_t any() const {
395396
return __esimd_any<Ty, N>(data());
396397
}
397398

398399
/// All operation.
399400
///
400401
/// \return 1 if all elements are set, 0 otherwise.
401402
template <typename T1 = Ty,
402-
typename = sycl::detail::enable_if_t<std::is_integral<T1>::value>>
403-
uint16_t all() {
403+
typename = std::enable_if_t<std::is_integral<T1>::value>>
404+
uint16_t all() const {
404405
return __esimd_all<Ty, N>(data());
405406
}
406407

@@ -499,7 +500,7 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
499500
/// elements in this object.
500501
/// @param addr the memory address to copy from. Must be a pointer to the
501502
/// global address space, otherwise behavior is undefined.
502-
ESIMD_INLINE void copy_from(const Ty *const addr) SYCL_ESIMD_FUNCTION;
503+
ESIMD_INLINE void copy_from(const Ty *addr) SYCL_ESIMD_FUNCTION;
503504

504505
/// Copy a contiguous block of data from memory into this simd_obj_impl
505506
/// object. The amount of memory copied equals the total size of vector
@@ -515,7 +516,7 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
515516
/// Copy all vector elements of this object into a contiguous block in memory.
516517
/// @param addr the memory address to copy to. Must be a pointer to the
517518
/// global address space, otherwise behavior is undefined.
518-
ESIMD_INLINE void copy_to(Ty *addr) SYCL_ESIMD_FUNCTION;
519+
ESIMD_INLINE void copy_to(Ty *addr) const SYCL_ESIMD_FUNCTION;
519520

520521
/// Copy all vector elements of this object into a contiguous block in memory.
521522
/// Destination memory location is represented via a global accessor and
@@ -525,7 +526,7 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
525526
template <typename AccessorT>
526527
ESIMD_INLINE EnableIfAccessor<AccessorT, accessor_mode_cap::can_write,
527528
sycl::access::target::global_buffer, void>
528-
copy_to(AccessorT acc, uint32_t offset) SYCL_ESIMD_FUNCTION;
529+
copy_to(AccessorT acc, uint32_t offset) const SYCL_ESIMD_FUNCTION;
529530

530531
/// @} // Memory operations
531532

@@ -634,7 +635,8 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
634635
// ----------- Outlined implementations of simd_obj_impl class APIs.
635636

636637
template <typename T, int N, class T1, class SFINAE>
637-
void simd_obj_impl<T, N, T1, SFINAE>::copy_from(const T *const Addr) {
638+
void simd_obj_impl<T, N, T1, SFINAE>::copy_from(const T *Addr)
639+
SYCL_ESIMD_FUNCTION {
638640
constexpr unsigned Sz = sizeof(T) * N;
639641
static_assert(Sz >= OperandSize::OWORD,
640642
"block size must be at least 1 oword");
@@ -655,7 +657,8 @@ template <typename T, int N, class T1, class SFINAE>
655657
template <typename AccessorT>
656658
ESIMD_INLINE EnableIfAccessor<AccessorT, accessor_mode_cap::can_read,
657659
sycl::access::target::global_buffer, void>
658-
simd_obj_impl<T, N, T1, SFINAE>::copy_from(AccessorT acc, uint32_t offset) {
660+
simd_obj_impl<T, N, T1, SFINAE>::copy_from(AccessorT acc, uint32_t offset)
661+
SYCL_ESIMD_FUNCTION {
659662
constexpr unsigned Sz = sizeof(T) * N;
660663
static_assert(Sz >= OperandSize::OWORD,
661664
"block size must be at least 1 oword");
@@ -675,7 +678,8 @@ simd_obj_impl<T, N, T1, SFINAE>::copy_from(AccessorT acc, uint32_t offset) {
675678
}
676679

677680
template <typename T, int N, class T1, class SFINAE>
678-
void simd_obj_impl<T, N, T1, SFINAE>::copy_to(T *addr) {
681+
void simd_obj_impl<T, N, T1, SFINAE>::copy_to(T *addr) const
682+
SYCL_ESIMD_FUNCTION {
679683
constexpr unsigned Sz = sizeof(T) * N;
680684
static_assert(Sz >= OperandSize::OWORD,
681685
"block size must be at least 1 oword");
@@ -694,7 +698,8 @@ template <typename T, int N, class T1, class SFINAE>
694698
template <typename AccessorT>
695699
ESIMD_INLINE EnableIfAccessor<AccessorT, accessor_mode_cap::can_write,
696700
sycl::access::target::global_buffer, void>
697-
simd_obj_impl<T, N, T1, SFINAE>::copy_to(AccessorT acc, uint32_t offset) {
701+
simd_obj_impl<T, N, T1, SFINAE>::copy_to(AccessorT acc, uint32_t offset) const
702+
SYCL_ESIMD_FUNCTION {
698703
constexpr unsigned Sz = sizeof(T) * N;
699704
static_assert(Sz >= OperandSize::OWORD,
700705
"block size must be at least 1 oword");

0 commit comments

Comments
 (0)