Skip to content

Commit 25f9bb6

Browse files
committed
Replace ptrdiff_t by size_t in memory.h
1 parent b372b29 commit 25f9bb6

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

include/kernel_float/memory.h

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ struct load_impl;
1414
template<typename T, size_t N, size_t... Is>
1515
struct load_impl<T, N, index_sequence<Is...>> {
1616
KERNEL_FLOAT_INLINE
17-
static vector_storage<T, N> call(const T* input, const ptrdiff_t* offsets) {
17+
static vector_storage<T, N> call(const T* input, const size_t* offsets) {
1818
return {input[offsets[Is]]...};
1919
}
2020

2121
KERNEL_FLOAT_INLINE
22-
static vector_storage<T, N> call(const T* input, const ptrdiff_t* offsets, const bool* mask) {
22+
static vector_storage<T, N> call(const T* input, const size_t* offsets, const bool* mask) {
2323
bool all_valid = true;
2424
for (size_t i = 0; i < N; i++) {
2525
all_valid &= mask[i];
@@ -44,7 +44,7 @@ struct load_impl<T, N, index_sequence<Is...>> {
4444
*/
4545
template<typename T, typename I>
4646
KERNEL_FLOAT_INLINE vector<T, vector_extent_type<I>> load(const T* ptr, const I& indices) {
47-
return detail::load_impl<T, vector_extent<I>>::call(ptr, cast<ptrdiff_t>(indices).data());
47+
return detail::load_impl<T, vector_extent<I>>::call(ptr, cast<size_t>(indices).data());
4848
}
4949

5050
/**
@@ -65,7 +65,7 @@ KERNEL_FLOAT_INLINE vector<T, E> load(const T* ptr, const I& indices, const M& m
6565

6666
return detail::load_impl<T, E::value>::call(
6767
ptr,
68-
convert_storage<ptrdiff_t>(indices, new_size).data(),
68+
convert_storage<size_t>(indices, new_size).data(),
6969
convert_storage<bool>(mask, new_size).data());
7070
}
7171

@@ -82,8 +82,8 @@ KERNEL_FLOAT_INLINE vector<T, E> load(const T* ptr, const I& indices, const M& m
8282
* ```
8383
*/
8484
template<size_t N, typename T>
85-
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(const T* ptr, ptrdiff_t offset = 0) {
86-
return load(ptr, offset + range<ptrdiff_t, N>());
85+
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(const T* ptr, size_t offset = 0) {
86+
return load(ptr, offset + range<size_t, N>());
8787
}
8888

8989
/**
@@ -97,9 +97,8 @@ KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(const T* ptr, ptrdiff_t offset =
9797
* ```
9898
*/
9999
template<size_t N, typename T>
100-
KERNEL_FLOAT_INLINE vector<T, extent<N>>
101-
loadn(const T* ptr, ptrdiff_t offset, ptrdiff_t max_length) {
102-
auto indices = offset + range<ptrdiff_t, N>();
100+
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(const T* ptr, size_t offset, size_t max_length) {
101+
auto indices = offset + range<size_t, N>();
103102
return load(ptr, indices, indices < max_length);
104103
}
105104

@@ -110,12 +109,12 @@ struct store_impl;
110109
template<typename T, size_t N, size_t... Is>
111110
struct store_impl<T, N, index_sequence<Is...>> {
112111
KERNEL_FLOAT_INLINE
113-
static void call(T* outputs, const T* inputs, const ptrdiff_t* offsets) {
112+
static void call(T* outputs, const T* inputs, const size_t* offsets) {
114113
((outputs[offsets[Is]] = inputs[Is]), ...);
115114
}
116115

117116
KERNEL_FLOAT_INLINE
118-
static void call(T* outputs, const T* inputs, const ptrdiff_t* offsets, const bool* mask) {
117+
static void call(T* outputs, const T* inputs, const size_t* offsets, const bool* mask) {
119118
bool all_valid = true;
120119
for (size_t i = 0; i < N; i++) {
121120
all_valid &= mask[i];
@@ -154,7 +153,7 @@ KERNEL_FLOAT_INLINE void store(const V& values, T* ptr, const I& indices, const
154153
return detail::store_impl<T, E::value>::call(
155154
ptr,
156155
convert_storage<T>(values, E()).data(),
157-
convert_storage<ptrdiff_t>(indices, E()).data(),
156+
convert_storage<size_t>(indices, E()).data(),
158157
convert_storage<bool>(mask, E()).data());
159158
}
160159

@@ -177,7 +176,7 @@ KERNEL_FLOAT_INLINE void store(const V& values, T* ptr, const I& indices) {
177176
return detail::store_impl<T, E::value>::call(
178177
ptr,
179178
convert_storage<T>(values, E()).data(),
180-
convert_storage<ptrdiff_t>(indices, E()).data());
179+
convert_storage<size_t>(indices, E()).data());
181180
}
182181

183182
/**
@@ -194,8 +193,8 @@ KERNEL_FLOAT_INLINE void store(const V& values, T* ptr, const I& indices) {
194193
* ```
195194
*/
196195
template<typename T, typename V, size_t N = vector_extent<V>>
197-
KERNEL_FLOAT_INLINE void storen(const V& values, T* ptr, ptrdiff_t offset = 0) {
198-
auto indices = offset + range<ptrdiff_t, N>();
196+
KERNEL_FLOAT_INLINE void storen(const V& values, T* ptr, size_t offset = 0) {
197+
auto indices = offset + range<size_t, N>();
199198
return store(values, ptr, indices);
200199
}
201200

@@ -211,8 +210,8 @@ KERNEL_FLOAT_INLINE void storen(const V& values, T* ptr, ptrdiff_t offset = 0) {
211210
* ```
212211
*/
213212
template<typename T, typename V, size_t N = vector_extent<V>>
214-
KERNEL_FLOAT_INLINE void storen(const V& values, T* ptr, ptrdiff_t offset, ptrdiff_t max_length) {
215-
auto indices = offset + range<ptrdiff_t, N>();
213+
KERNEL_FLOAT_INLINE void storen(const V& values, T* ptr, size_t offset, size_t max_length) {
214+
auto indices = offset + range<size_t, N>();
216215
return store(values, ptr, indices, indices < max_length);
217216
}
218217

@@ -230,7 +229,7 @@ struct AssignConversionProxy {
230229

231230
template<typename U>
232231
KERNEL_FLOAT_INLINE AssignConversionProxy& operator=(U&& values) {
233-
auto indices = range<ptrdiff_t, N>();
232+
auto indices = range<size_t, N>();
234233
detail::store_impl<T, N>::call(
235234
ptr_,
236235
convert_storage<T, N>(std::forward<U>(values)).data(),
@@ -307,15 +306,15 @@ struct aligned_ptr {
307306
* See ``kernel_float::loadn``
308307
*/
309308
template<size_t N>
310-
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(ptrdiff_t offset = 0) const {
309+
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(size_t offset = 0) const {
311310
return ::kernel_float::loadn<N>(get(), offset);
312311
}
313312

314313
/**
315314
* See ``kernel_float::loadn``
316315
*/
317316
template<size_t N>
318-
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(ptrdiff_t offset, ptrdiff_t max_length) const {
317+
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(size_t offset, size_t max_length) const {
319318
return ::kernel_float::loadn<N>(get(), offset, max_length);
320319
}
321320

@@ -330,14 +329,14 @@ struct aligned_ptr {
330329
* See ``kernel_float::storen``
331330
*/
332331
template<typename V, size_t N = vector_extent<V>>
333-
KERNEL_FLOAT_INLINE void storen(const V& values, ptrdiff_t offset = 0) const {
332+
KERNEL_FLOAT_INLINE void storen(const V& values, size_t offset = 0) const {
334333
::kernel_float::storen(values, get(), offset);
335334
}
336335
/**
337336
* See ``kernel_float::storen``
338337
*/
339338
template<typename V, size_t N = vector_extent<V>>
340-
KERNEL_FLOAT_INLINE void storen(const V& values, ptrdiff_t offset, ptrdiff_t max_length) const {
339+
KERNEL_FLOAT_INLINE void storen(const V& values, size_t offset, size_t max_length) const {
341340
::kernel_float::storen(values, get(), offset, max_length);
342341
}
343342

@@ -391,15 +390,15 @@ struct aligned_ptr<const T, alignment> {
391390
* See ``kernel_float::loadn``
392391
*/
393392
template<size_t N>
394-
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(ptrdiff_t offset = 0) const {
393+
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(size_t offset = 0) const {
395394
return ::kernel_float::loadn<N>(get(), offset);
396395
}
397396

398397
/**
399398
* See ``kernel_float::loadn``
400399
*/
401400
template<size_t N>
402-
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(ptrdiff_t offset, ptrdiff_t max_length) const {
401+
KERNEL_FLOAT_INLINE vector<T, extent<N>> loadn(size_t offset, size_t max_length) const {
403402
return ::kernel_float::loadn<N>(get(), offset, max_length);
404403
}
405404

0 commit comments

Comments
 (0)