Skip to content

Commit 06837a8

Browse files
author
Alexander Batashev
committed
Run clang-format
Signed-off-by: Alexander Batashev <[email protected]>
1 parent ff68815 commit 06837a8

File tree

9 files changed

+166
-98
lines changed

9 files changed

+166
-98
lines changed

sycl/include/CL/sycl/buffer.hpp

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,27 @@ class buffer {
6060
: Range(bufferRange) {
6161
impl = std::make_shared<detail::buffer_impl>(
6262
get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)), propList,
63-
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(allocator));
63+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
64+
allocator));
6465
}
6566

6667
buffer(T *hostData, const range<dimensions> &bufferRange,
6768
const property_list &propList = {})
6869
: Range(bufferRange) {
6970
impl = std::make_shared<detail::buffer_impl>(
7071
hostData, get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
71-
propList, make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
72+
propList,
73+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
7274
}
7375

7476
buffer(T *hostData, const range<dimensions> &bufferRange,
7577
AllocatorT allocator, const property_list &propList = {})
7678
: Range(bufferRange) {
7779
impl = std::make_shared<detail::buffer_impl>(
7880
hostData, get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
79-
propList, make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(allocator));
81+
propList,
82+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
83+
allocator));
8084
}
8185

8286
template <typename _T = T>
@@ -86,7 +90,8 @@ class buffer {
8690
: Range(bufferRange) {
8791
impl = std::make_shared<detail::buffer_impl>(
8892
hostData, get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
89-
propList, make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
93+
propList,
94+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
9095
}
9196

9297
template <typename _T = T>
@@ -96,7 +101,9 @@ class buffer {
96101
: Range(bufferRange) {
97102
impl = std::make_shared<detail::buffer_impl>(
98103
hostData, get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
99-
propList, make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(allocator));
104+
propList,
105+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
106+
allocator));
100107
}
101108

102109
buffer(const shared_ptr_class<T> &hostData,
@@ -105,7 +112,9 @@ class buffer {
105112
: Range(bufferRange) {
106113
impl = std::make_shared<detail::buffer_impl>(
107114
hostData, get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
108-
propList, make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(allocator));
115+
propList,
116+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
117+
allocator));
109118
}
110119

111120
buffer(const shared_ptr_class<T> &hostData,
@@ -114,7 +123,8 @@ class buffer {
114123
: Range(bufferRange) {
115124
impl = std::make_shared<detail::buffer_impl>(
116125
hostData, get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)),
117-
propList, make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
126+
propList,
127+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
118128
}
119129

120130
template <class InputIterator, int N = dimensions,
@@ -125,7 +135,9 @@ class buffer {
125135
: Range(range<1>(std::distance(first, last))) {
126136
impl = std::make_shared<detail::buffer_impl>(
127137
first, last, get_count() * sizeof(T),
128-
detail::getNextPowerOfTwo(sizeof(T)), propList, make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(allocator));
138+
detail::getNextPowerOfTwo(sizeof(T)), propList,
139+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
140+
allocator));
129141
}
130142

131143
template <class InputIterator, int N = dimensions,
@@ -136,7 +148,8 @@ class buffer {
136148
: Range(range<1>(std::distance(first, last))) {
137149
impl = std::make_shared<detail::buffer_impl>(
138150
first, last, get_count() * sizeof(T),
139-
detail::getNextPowerOfTwo(sizeof(T)), propList, make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
151+
detail::getNextPowerOfTwo(sizeof(T)), propList,
152+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>());
140153
}
141154

142155
// This constructor is a prototype for a future SYCL specification
@@ -149,7 +162,8 @@ class buffer {
149162
impl = std::make_shared<detail::buffer_impl>(
150163
container.data(), container.data() + container.size(),
151164
get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)), propList,
152-
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(allocator));
165+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
166+
allocator));
153167
}
154168

155169
// This constructor is a prototype for a future SYCL specification
@@ -186,7 +200,9 @@ class buffer {
186200

187201
Range[0] = BufSize / sizeof(T);
188202
impl = std::make_shared<detail::buffer_impl>(
189-
MemObject, SyclContext, BufSize, make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(), AvailableEvent);
203+
MemObject, SyclContext, BufSize,
204+
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(),
205+
AvailableEvent);
190206
}
191207

192208
buffer(const buffer &rhs) = default;

sycl/include/CL/sycl/detail/buffer_impl.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,20 @@ class buffer_impl final : public SYCLMemObjT {
4444

4545
public:
4646
buffer_impl(size_t SizeInBytes, size_t RequiredAlign,
47-
const property_list &Props, unique_ptr_class<SYCLMemObjAllocator> Allocator)
47+
const property_list &Props,
48+
unique_ptr_class<SYCLMemObjAllocator> Allocator)
4849
: BaseT(SizeInBytes, Props, std::move(Allocator)) {}
4950

5051
buffer_impl(void *HostData, size_t SizeInBytes, size_t RequiredAlign,
51-
const property_list &Props, unique_ptr_class<SYCLMemObjAllocator> Allocator)
52+
const property_list &Props,
53+
unique_ptr_class<SYCLMemObjAllocator> Allocator)
5254
: BaseT(SizeInBytes, Props, std::move(Allocator)) {
5355
BaseT::handleHostData(HostData, RequiredAlign);
5456
}
5557

5658
buffer_impl(const void *HostData, size_t SizeInBytes, size_t RequiredAlign,
57-
const property_list &Props, unique_ptr_class<SYCLMemObjAllocator> Allocator)
59+
const property_list &Props,
60+
unique_ptr_class<SYCLMemObjAllocator> Allocator)
5861
: BaseT(SizeInBytes, Props, std::move(Allocator)) {
5962
BaseT::handleHostData(HostData, RequiredAlign);
6063
}
@@ -74,7 +77,8 @@ class buffer_impl final : public SYCLMemObjT {
7477
template <class InputIterator>
7578
buffer_impl(EnableIfNotConstIterator<InputIterator> First, InputIterator Last,
7679
const size_t SizeInBytes, size_t RequiredAlign,
77-
const property_list &Props, unique_ptr_class<SYCLMemObjAllocator> Allocator)
80+
const property_list &Props,
81+
unique_ptr_class<SYCLMemObjAllocator> Allocator)
7882
: BaseT(SizeInBytes, Props, std::move(Allocator)) {
7983
BaseT::handleHostData(First, Last, RequiredAlign);
8084
// TODO: There is contradiction in the spec, in one place it says
@@ -92,13 +96,15 @@ class buffer_impl final : public SYCLMemObjT {
9296
template <class InputIterator>
9397
buffer_impl(EnableIfConstIterator<InputIterator> First, InputIterator Last,
9498
const size_t SizeInBytes, size_t RequiredAlign,
95-
const property_list &Props, unique_ptr_class<SYCLMemObjAllocator> Allocator)
99+
const property_list &Props,
100+
unique_ptr_class<SYCLMemObjAllocator> Allocator)
96101
: BaseT(SizeInBytes, Props, std::move(Allocator)) {
97102
BaseT::handleHostData(First, Last, RequiredAlign);
98103
}
99104

100105
buffer_impl(cl_mem MemObject, const context &SyclContext,
101-
const size_t SizeInBytes, unique_ptr_class<SYCLMemObjAllocator> Allocator,
106+
const size_t SizeInBytes,
107+
unique_ptr_class<SYCLMemObjAllocator> Allocator,
102108
event AvailableEvent)
103109
: BaseT(MemObject, SyclContext, SizeInBytes, std::move(AvailableEvent),
104110
std::move(Allocator)) {}

sycl/include/CL/sycl/detail/image_impl.hpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,24 @@ template <int Dimensions> class image_impl final : public SYCLMemObjT {
9292

9393
public:
9494
image_impl(image_channel_order Order, image_channel_type Type,
95-
const range<Dimensions> &ImageRange, unique_ptr_class<SYCLMemObjAllocator> Allocator,
95+
const range<Dimensions> &ImageRange,
96+
unique_ptr_class<SYCLMemObjAllocator> Allocator,
9697
const property_list &PropList = {})
9798
: image_impl((void *)nullptr, Order, Type, ImageRange,
9899
std::move(Allocator), PropList) {}
99100

100101
template <bool B = (Dimensions > 1)>
101102
image_impl(image_channel_order Order, image_channel_type Type,
102103
const range<Dimensions> &ImageRange,
103-
const EnableIfPitchT<B> &Pitch, unique_ptr_class<SYCLMemObjAllocator> Allocator,
104+
const EnableIfPitchT<B> &Pitch,
105+
unique_ptr_class<SYCLMemObjAllocator> Allocator,
104106
const property_list &PropList = {})
105107
: image_impl((void *)nullptr, Order, Type, ImageRange, Pitch,
106108
std::move(Allocator), PropList) {}
107109

108110
image_impl(void *HData, image_channel_order Order, image_channel_type Type,
109-
const range<Dimensions> &ImageRange, unique_ptr_class<SYCLMemObjAllocator> Allocator,
111+
const range<Dimensions> &ImageRange,
112+
unique_ptr_class<SYCLMemObjAllocator> Allocator,
110113
const property_list &PropList = {})
111114
: BaseT(PropList, std::move(Allocator)), MRange(ImageRange),
112115
MOrder(Order), MType(Type),
@@ -118,7 +121,8 @@ template <int Dimensions> class image_impl final : public SYCLMemObjT {
118121

119122
image_impl(const void *HData, image_channel_order Order,
120123
image_channel_type Type, const range<Dimensions> &ImageRange,
121-
unique_ptr_class<SYCLMemObjAllocator> Allocator, const property_list &PropList = {})
124+
unique_ptr_class<SYCLMemObjAllocator> Allocator,
125+
const property_list &PropList = {})
122126
: BaseT(PropList, std::move(Allocator)), MRange(ImageRange),
123127
MOrder(Order), MType(Type),
124128
MNumChannels(getImageNumberChannels(MOrder)),
@@ -130,7 +134,8 @@ template <int Dimensions> class image_impl final : public SYCLMemObjT {
130134
template <bool B = (Dimensions > 1)>
131135
image_impl(void *HData, image_channel_order Order, image_channel_type Type,
132136
const range<Dimensions> &ImageRange,
133-
const EnableIfPitchT<B> &Pitch, unique_ptr_class<SYCLMemObjAllocator> Allocator,
137+
const EnableIfPitchT<B> &Pitch,
138+
unique_ptr_class<SYCLMemObjAllocator> Allocator,
134139
const property_list &PropList = {})
135140
: BaseT(PropList, std::move(Allocator)), MRange(ImageRange),
136141
MOrder(Order), MType(Type),
@@ -142,7 +147,8 @@ template <int Dimensions> class image_impl final : public SYCLMemObjT {
142147

143148
image_impl(shared_ptr_class<void> &HData, image_channel_order Order,
144149
image_channel_type Type, const range<Dimensions> &ImageRange,
145-
unique_ptr_class<SYCLMemObjAllocator> Allocator, const property_list &PropList = {})
150+
unique_ptr_class<SYCLMemObjAllocator> Allocator,
151+
const property_list &PropList = {})
146152
: BaseT(PropList, std::move(Allocator)), MRange(ImageRange),
147153
MOrder(Order), MType(Type),
148154
MNumChannels(getImageNumberChannels(MOrder)),
@@ -155,7 +161,8 @@ template <int Dimensions> class image_impl final : public SYCLMemObjT {
155161
template <bool B = (Dimensions > 1)>
156162
image_impl(shared_ptr_class<void> &HData, image_channel_order Order,
157163
image_channel_type Type, const range<Dimensions> &ImageRange,
158-
const EnableIfPitchT<B> &Pitch, unique_ptr_class<SYCLMemObjAllocator> Allocator,
164+
const EnableIfPitchT<B> &Pitch,
165+
unique_ptr_class<SYCLMemObjAllocator> Allocator,
159166
const property_list &PropList = {})
160167
: BaseT(PropList, std::move(Allocator)), MRange(ImageRange),
161168
MOrder(Order), MType(Type),

sycl/include/CL/sycl/detail/sycl_mem_obj_allocator.hpp

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,73 +18,74 @@ class aligned_allocator;
1818
class SYCLMemObjAllocator {
1919

2020
protected:
21-
virtual void* getAllocatorImpl() = 0;
21+
virtual void *getAllocatorImpl() = 0;
22+
2223
public:
23-
virtual ~SYCLMemObjAllocator() = default;
24-
virtual void *allocate(std::size_t) = 0;
25-
virtual void deallocate(void *, std::size_t) = 0;
26-
virtual std::size_t getValueSize() const = 0;
27-
virtual void setAlignment(std::size_t RequiredAlign) = 0;
24+
virtual ~SYCLMemObjAllocator() = default;
25+
virtual void *allocate(std::size_t) = 0;
26+
virtual void deallocate(void *, std::size_t) = 0;
27+
virtual std::size_t getValueSize() const = 0;
28+
virtual void setAlignment(std::size_t RequiredAlign) = 0;
2829
template <typename AllocatorT> AllocatorT getAllocator() {
2930
return *reinterpret_cast<AllocatorT *>(getAllocatorImpl());
3031
}
3132
};
3233

33-
template <typename AllocatorT> class SYCLMemObjAllocatorHolder
34-
: public SYCLMemObjAllocator {
35-
using sycl_memory_object_allocator = detail::aligned_allocator<char>;
34+
template <typename AllocatorT>
35+
class SYCLMemObjAllocatorHolder : public SYCLMemObjAllocator {
36+
using sycl_memory_object_allocator = detail::aligned_allocator<char>;
3637

37-
template <typename T>
38-
using EnableIfDefaultAllocator =
39-
enable_if_t<std::is_same<T, sycl_memory_object_allocator>::value>;
38+
template <typename T>
39+
using EnableIfDefaultAllocator =
40+
enable_if_t<std::is_same<T, sycl_memory_object_allocator>::value>;
4041

41-
template <typename T>
42-
using EnableIfNonDefaultAllocator =
43-
enable_if_t<!std::is_same<T, sycl_memory_object_allocator>::value>;
42+
template <typename T>
43+
using EnableIfNonDefaultAllocator =
44+
enable_if_t<!std::is_same<T, sycl_memory_object_allocator>::value>;
4445

45-
public:
46-
SYCLMemObjAllocatorHolder(AllocatorT Allocator)
47-
: MAllocator(Allocator),
48-
MValueSize(sizeof(typename AllocatorT::value_type)){}
46+
public:
47+
SYCLMemObjAllocatorHolder(AllocatorT Allocator)
48+
: MAllocator(Allocator),
49+
MValueSize(sizeof(typename AllocatorT::value_type)) {}
4950

50-
SYCLMemObjAllocatorHolder()
51-
: MAllocator(AllocatorT()),
52-
MValueSize(sizeof(typename AllocatorT::value_type)){}
51+
SYCLMemObjAllocatorHolder()
52+
: MAllocator(AllocatorT()),
53+
MValueSize(sizeof(typename AllocatorT::value_type)) {}
5354

54-
~SYCLMemObjAllocatorHolder() = default;
55+
~SYCLMemObjAllocatorHolder() = default;
5556

56-
virtual void *allocate(std::size_t Count) override {
57-
return reinterpret_cast<void *>(MAllocator.allocate(Count));
58-
}
57+
virtual void *allocate(std::size_t Count) override {
58+
return reinterpret_cast<void *>(MAllocator.allocate(Count));
59+
}
5960

60-
virtual void deallocate(void *Ptr, std::size_t Count) override {
61-
MAllocator.deallocate(
62-
reinterpret_cast<typename AllocatorT::value_type *>(Ptr), Count);
63-
}
61+
virtual void deallocate(void *Ptr, std::size_t Count) override {
62+
MAllocator.deallocate(
63+
reinterpret_cast<typename AllocatorT::value_type *>(Ptr), Count);
64+
}
6465

65-
void setAlignment(std::size_t RequiredAlign) override {
66-
setAlignImpl(RequiredAlign);
67-
}
66+
void setAlignment(std::size_t RequiredAlign) override {
67+
setAlignImpl(RequiredAlign);
68+
}
6869

69-
virtual std::size_t getValueSize() const override { return MValueSize; }
70+
virtual std::size_t getValueSize() const override { return MValueSize; }
7071

71-
protected:
72-
virtual void *getAllocatorImpl() override { return &MAllocator; }
72+
protected:
73+
virtual void *getAllocatorImpl() override { return &MAllocator; }
7374

74-
private:
75-
template <typename T = AllocatorT>
76-
EnableIfNonDefaultAllocator<T> setAlignImpl(std::size_t RequiredAlign) {
77-
// Do nothing in case of user's allocator.
78-
}
75+
private:
76+
template <typename T = AllocatorT>
77+
EnableIfNonDefaultAllocator<T> setAlignImpl(std::size_t RequiredAlign) {
78+
// Do nothing in case of user's allocator.
79+
}
7980

80-
template <typename T = AllocatorT>
81-
EnableIfDefaultAllocator<T> setAlignImpl(std::size_t RequiredAlign) {
82-
MAllocator.setAlignment(std::max<size_t>(RequiredAlign, 64));
83-
}
81+
template <typename T = AllocatorT>
82+
EnableIfDefaultAllocator<T> setAlignImpl(std::size_t RequiredAlign) {
83+
MAllocator.setAlignment(std::max<size_t>(RequiredAlign, 64));
84+
}
8485

85-
AllocatorT MAllocator;
86-
std::size_t MValueSize;
87-
};
86+
AllocatorT MAllocator;
87+
std::size_t MValueSize;
88+
};
8889
} // namespace detail
8990
} // namespace sycl
9091
}

sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,17 @@ class SYCLMemObjT : public SYCLMemObjI {
6767
MSizeInBytes(SizeInBytes), MUserPtr(nullptr), MShadowCopy(nullptr),
6868
MUploadDataFunctor(nullptr), MSharedPtrStorage(nullptr) {}
6969

70-
SYCLMemObjT(const property_list &Props, unique_ptr_class<SYCLMemObjAllocator> Allocator)
70+
SYCLMemObjT(const property_list &Props,
71+
unique_ptr_class<SYCLMemObjAllocator> Allocator)
7172
: SYCLMemObjT(/*SizeInBytes*/ 0, Props, std::move(Allocator)) {}
7273

7374
SYCLMemObjT(cl_mem MemObject, const context &SyclContext,
7475
const size_t SizeInBytes, event AvailableEvent,
7576
unique_ptr_class<SYCLMemObjAllocator> Allocator);
7677

7778
SYCLMemObjT(cl_mem MemObject, const context &SyclContext,
78-
event AvailableEvent, unique_ptr_class<SYCLMemObjAllocator> Allocator)
79+
event AvailableEvent,
80+
unique_ptr_class<SYCLMemObjAllocator> Allocator)
7981
: SYCLMemObjT(MemObject, SyclContext, /*SizeInBytes*/ 0, AvailableEvent,
8082
std::move(Allocator)) {}
8183

0 commit comments

Comments
 (0)