Skip to content

Commit 28c0cfa

Browse files
[SYCL] Use aligned_allocator<T> as the default one
Use the type-specific aligned_allocator<T> for buffer host memory allocation instead of the non-template buffer_allocator (which is aligned_allocator<char>). Signed-off-by: Sergey Semenov <[email protected]>
1 parent 45a0703 commit 28c0cfa

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

sycl/include/CL/sycl/accessor.hpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ class accessor :
336336
using reference = DataT &;
337337
using const_reference = const DataT &;
338338

339-
template <int Dims = Dimensions>
339+
template <typename AllocatorT, int Dims = Dimensions>
340340
accessor(
341341
enable_if_t<Dims == 0 && ((!IsPlaceH && IsHostBuf) ||
342342
(IsPlaceH && (IsGlobalBuf || IsConstantBuf))),
343-
buffer<DataT, 1>> &BufferRef)
343+
buffer<DataT, 1, AllocatorT>> &BufferRef)
344344
#ifdef __SYCL_DEVICE_ONLY__
345345
: impl(id<AdjustedDim>(), BufferRef.get_range(), BufferRef.MemRange) {
346346
#else
@@ -357,9 +357,9 @@ class accessor :
357357
#endif
358358
}
359359

360-
template <int Dims = Dimensions>
360+
template <typename AllocatorT, int Dims = Dimensions>
361361
accessor(
362-
buffer<DataT, 1> &BufferRef,
362+
buffer<DataT, 1, AllocatorT> &BufferRef,
363363
enable_if_t<Dims == 0 && (!IsPlaceH && (IsGlobalBuf || IsConstantBuf)),
364364
handler> &CommandGroupHandler)
365365
#ifdef __SYCL_DEVICE_ONLY__
@@ -376,11 +376,11 @@ class accessor :
376376
}
377377
#endif
378378

379-
template <int Dims = Dimensions,
379+
template <typename AllocatorT, int Dims = Dimensions,
380380
typename = enable_if_t<
381381
(Dims > 0) && ((!IsPlaceH && IsHostBuf) ||
382382
(IsPlaceH && (IsGlobalBuf || IsConstantBuf)))>>
383-
accessor(buffer<DataT, Dimensions> &BufferRef)
383+
accessor(buffer<DataT, Dimensions, AllocatorT> &BufferRef)
384384
#ifdef __SYCL_DEVICE_ONLY__
385385
: impl(id<Dimensions>(), BufferRef.get_range(), BufferRef.MemRange) {
386386
}
@@ -398,10 +398,11 @@ class accessor :
398398
}
399399
#endif
400400

401-
template <int Dims = Dimensions,
401+
template <typename AllocatorT, int Dims = Dimensions,
402402
typename = enable_if_t<
403403
(Dims > 0) && (!IsPlaceH && (IsGlobalBuf || IsConstantBuf))>>
404-
accessor(buffer<DataT, Dimensions> &BufferRef, handler &CommandGroupHandler)
404+
accessor(buffer<DataT, Dimensions, AllocatorT> &BufferRef,
405+
handler &CommandGroupHandler)
405406
#ifdef __SYCL_DEVICE_ONLY__
406407
: impl(id<AdjustedDim>(), BufferRef.get_range(), BufferRef.MemRange) {
407408
}
@@ -416,12 +417,12 @@ class accessor :
416417
}
417418
#endif
418419

419-
template <int Dims = Dimensions,
420+
template <typename AllocatorT, int Dims = Dimensions,
420421
typename = enable_if_t<
421422
(Dims > 0) && ((!IsPlaceH && IsHostBuf) ||
422423
(IsPlaceH && (IsGlobalBuf || IsConstantBuf)))>>
423-
accessor(buffer<DataT, Dimensions> &BufferRef, range<Dimensions> AccessRange,
424-
id<Dimensions> AccessOffset = {})
424+
accessor(buffer<DataT, Dimensions, AllocatorT> &BufferRef,
425+
range<Dimensions> AccessRange, id<Dimensions> AccessOffset = {})
425426
#ifdef __SYCL_DEVICE_ONLY__
426427
: impl(AccessOffset, AccessRange, BufferRef.MemRange) {
427428
}
@@ -438,11 +439,12 @@ class accessor :
438439
}
439440
#endif
440441

441-
template <int Dims = Dimensions,
442+
template <typename AllocatorT, int Dims = Dimensions,
442443
typename = enable_if_t<
443444
(Dims > 0) && (!IsPlaceH && (IsGlobalBuf || IsConstantBuf))>>
444-
accessor(buffer<DataT, Dimensions> &BufferRef, handler &CommandGroupHandler,
445-
range<Dimensions> AccessRange, id<Dimensions> AccessOffset = {})
445+
accessor(buffer<DataT, Dimensions, AllocatorT> &BufferRef,
446+
handler &CommandGroupHandler, range<Dimensions> AccessRange,
447+
id<Dimensions> AccessOffset = {})
446448
#ifdef __SYCL_DEVICE_ONLY__
447449
: impl(AccessOffset, AccessRange, BufferRef.MemRange) {
448450
}

sycl/include/CL/sycl/buffer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class queue;
2121
template <int dimensions> class range;
2222

2323
template <typename T, int dimensions = 1,
24-
typename AllocatorT = cl::sycl::buffer_allocator>
24+
typename AllocatorT = cl::sycl::detail::aligned_allocator<T>>
2525
class buffer {
2626
public:
2727
using value_type = T;

0 commit comments

Comments
 (0)