Skip to content

Commit 514d8ed

Browse files
[NFC][SYCL] Drop RepeatValue helper (#19183)
`vec_base` ctor already uses a private helper to pass `std::index_sequence`, no reason to go through another such helper.
1 parent 7189d82 commit 514d8ed

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

sycl/include/sycl/detail/common.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,19 +364,6 @@ struct ArrayCreator<DataT, FlattenF> {
364364
static constexpr auto Create() { return std::array<DataT, 0>{}; }
365365
};
366366

367-
// Helper function for creating an arbitrary sized array with the same value
368-
// repeating.
369-
template <typename T, size_t... Is>
370-
static constexpr std::array<T, sizeof...(Is)>
371-
RepeatValueHelper(const T &Arg, std::index_sequence<Is...>) {
372-
auto ReturnArg = [&](size_t) { return Arg; };
373-
return {ReturnArg(Is)...};
374-
}
375-
template <size_t N, typename T>
376-
static constexpr std::array<T, N> RepeatValue(const T &Arg) {
377-
return RepeatValueHelper(Arg, std::make_index_sequence<N>());
378-
}
379-
380367
// to output exceptions caught in ~destructors
381368
#ifndef NDEBUG
382369
#define __SYCL_REPORT_EXCEPTION_TO_STREAM(str, e) \

sycl/include/sycl/vector.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#include <sycl/access/access.hpp> // for decorated, address_space
3535
#include <sycl/aliases.hpp> // for half, cl_char, cl_int
36-
#include <sycl/detail/common.hpp> // for ArrayCreator, RepeatV...
36+
#include <sycl/detail/common.hpp> // for ArrayCreator
3737
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
3838
#include <sycl/detail/generic_type_traits.hpp> // for is_sigeninteger, is_s...
3939
#include <sycl/detail/memcpy.hpp> // for memcpy
@@ -194,6 +194,10 @@ template <typename DataT, int NumElements> class vec_base {
194194
static constexpr int alignment = (std::min)((size_t)64, sizeof(DataType));
195195
alignas(alignment) DataType m_Data;
196196

197+
template <size_t... Is>
198+
constexpr vec_base(const DataT &Val, std::index_sequence<Is...>)
199+
: m_Data{((void)Is, Val)...} {}
200+
197201
template <size_t... Is>
198202
constexpr vec_base(const std::array<DataT, NumElements> &Arr,
199203
std::index_sequence<Is...>)
@@ -262,8 +266,7 @@ template <typename DataT, int NumElements> class vec_base {
262266
constexpr vec_base &operator=(vec_base &&) = default;
263267

264268
explicit constexpr vec_base(const DataT &arg)
265-
: vec_base(RepeatValue<NumElements>(arg),
266-
std::make_index_sequence<NumElements>()) {}
269+
: vec_base(arg, std::make_index_sequence<NumElements>()) {}
267270

268271
template <typename... argTN,
269272
typename = std::enable_if_t<

0 commit comments

Comments
 (0)