Skip to content

Commit f86b562

Browse files
author
Alexander Batashev
authored
[SYCL] Do not export utility methods from SYCLMemObjT (#1768)
Signed-off-by: Alexander Batashev <[email protected]>
1 parent 2623abe commit f86b562

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

sycl/include/CL/sycl/detail/export.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@
3939
#ifndef __SYCL_EXPORT
4040
#define __SYCL_EXPORT
4141
#define __SYCL_EXPORT_DEPRECATED(x)
42+
#define DLL_LOCAL
4243
#endif
4344
#endif // __SYCL_DEVICE_ONLY__

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

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,57 +86,64 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
8686

8787
const plugin &getPlugin() const;
8888

89-
size_t getSize() const override { return MSizeInBytes; }
90-
size_t get_count() const {
89+
DLL_LOCAL size_t getSize() const override { return MSizeInBytes; }
90+
DLL_LOCAL size_t get_count() const {
9191
size_t AllocatorValueSize = MAllocator->getValueSize();
9292
return (getSize() + AllocatorValueSize - 1) / AllocatorValueSize;
9393
}
9494

95-
template <typename propertyT> bool has_property() const {
95+
template <typename propertyT> DLL_LOCAL bool has_property() const {
9696
return MProps.has_property<propertyT>();
9797
}
9898

99-
template <typename propertyT> propertyT get_property() const {
99+
template <typename propertyT> DLL_LOCAL propertyT get_property() const {
100100
return MProps.get_property<propertyT>();
101101
}
102102

103-
template <typename AllocatorT> AllocatorT get_allocator() const {
103+
template <typename AllocatorT> DLL_LOCAL AllocatorT get_allocator() const {
104104
return MAllocator->getAllocator<AllocatorT>();
105105
}
106106

107-
void *allocateHostMem() override { return MAllocator->allocate(get_count()); }
107+
DLL_LOCAL void *allocateHostMem() override {
108+
return MAllocator->allocate(get_count());
109+
}
108110

109-
void releaseHostMem(void *Ptr) override {
111+
DLL_LOCAL void releaseHostMem(void *Ptr) override {
110112
if (Ptr)
111113
MAllocator->deallocate(Ptr, get_count());
112114
}
113115

114116
void releaseMem(ContextImplPtr Context, void *MemAllocation) override;
115117

116-
void *getUserPtr() const {
118+
DLL_LOCAL void *getUserPtr() const {
117119
return MOpenCLInterop ? static_cast<void *>(MInteropMemObject) : MUserPtr;
118120
}
119121

120-
void set_write_back(bool NeedWriteBack) { MNeedWriteBack = NeedWriteBack; }
122+
DLL_LOCAL void set_write_back(bool NeedWriteBack) {
123+
MNeedWriteBack = NeedWriteBack;
124+
}
121125

122-
void set_final_data(std::nullptr_t) { MUploadDataFunctor = nullptr; }
126+
DLL_LOCAL void set_final_data(std::nullptr_t) {
127+
MUploadDataFunctor = nullptr;
128+
}
123129

124130
template <template <typename T> class PtrT, typename T>
125-
enable_if_t<std::is_convertible<PtrT<T>, weak_ptr_class<T>>::value>
131+
DLL_LOCAL enable_if_t<std::is_convertible<PtrT<T>, weak_ptr_class<T>>::value>
126132
set_final_data(PtrT<T> FinalData) {
127133
weak_ptr_class<T> TempFinalData(FinalData);
128134
set_final_data(TempFinalData);
129135
}
130136

131-
template <typename T> void set_final_data(weak_ptr_class<T> FinalData) {
137+
template <typename T>
138+
DLL_LOCAL void set_final_data(weak_ptr_class<T> FinalData) {
132139
MUploadDataFunctor = [this, FinalData]() {
133140
if (shared_ptr_class<T> LockedFinalData = FinalData.lock()) {
134141
updateHostMemory(LockedFinalData.get());
135142
}
136143
};
137144
}
138145

139-
void set_final_data_from_storage() {
146+
DLL_LOCAL void set_final_data_from_storage() {
140147
MUploadDataFunctor = [this]() {
141148
if (!MSharedPtrStorage.unique()) {
142149
void *FinalData = const_cast<void *>(MSharedPtrStorage.get());
@@ -146,7 +153,8 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
146153
}
147154

148155
template <typename Destination>
149-
EnableIfOutputPointerT<Destination> set_final_data(Destination FinalData) {
156+
DLL_LOCAL EnableIfOutputPointerT<Destination>
157+
set_final_data(Destination FinalData) {
150158
if (!FinalData)
151159
MUploadDataFunctor = nullptr;
152160
else
@@ -156,7 +164,8 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
156164
}
157165

158166
template <typename Destination>
159-
EnableIfOutputIteratorT<Destination> set_final_data(Destination FinalData) {
167+
DLL_LOCAL EnableIfOutputIteratorT<Destination>
168+
set_final_data(Destination FinalData) {
160169
MUploadDataFunctor = [this, FinalData]() {
161170
using DestinationValueT = iterator_value_type_t<Destination>;
162171
// TODO if Destination is ContiguousIterator then don't create
@@ -179,18 +188,18 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
179188
// members must be alive.
180189
void updateHostMemory();
181190

182-
bool useHostPtr() {
191+
DLL_LOCAL bool useHostPtr() {
183192
return has_property<property::buffer::use_host_ptr>() ||
184193
has_property<property::image::use_host_ptr>();
185194
}
186195

187-
bool canReuseHostPtr(void *HostPtr, const size_t RequiredAlign) {
196+
DLL_LOCAL bool canReuseHostPtr(void *HostPtr, const size_t RequiredAlign) {
188197
bool Aligned =
189198
(reinterpret_cast<std::uintptr_t>(HostPtr) % RequiredAlign) == 0;
190199
return Aligned || useHostPtr();
191200
}
192201

193-
void handleHostData(void *HostPtr, const size_t RequiredAlign) {
202+
DLL_LOCAL void handleHostData(void *HostPtr, const size_t RequiredAlign) {
194203
if (!MHostPtrReadOnly)
195204
set_final_data(reinterpret_cast<char *>(HostPtr));
196205

@@ -204,14 +213,15 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
204213
}
205214
}
206215

207-
void handleHostData(const void *HostPtr, const size_t RequiredAlign) {
216+
DLL_LOCAL void handleHostData(const void *HostPtr,
217+
const size_t RequiredAlign) {
208218
MHostPtrReadOnly = true;
209219
handleHostData(const_cast<void *>(HostPtr), RequiredAlign);
210220
}
211221

212222
template <typename T>
213-
void handleHostData(const shared_ptr_class<T> &HostPtr,
214-
const size_t RequiredAlign) {
223+
DLL_LOCAL void handleHostData(const shared_ptr_class<T> &HostPtr,
224+
const size_t RequiredAlign) {
215225
MSharedPtrStorage = HostPtr;
216226
MHostPtrReadOnly = std::is_const<T>::value;
217227
if (HostPtr) {
@@ -230,8 +240,8 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
230240
}
231241

232242
template <class InputIterator>
233-
void handleHostData(InputIterator First, InputIterator Last,
234-
const size_t RequiredAlign) {
243+
DLL_LOCAL void handleHostData(InputIterator First, InputIterator Last,
244+
const size_t RequiredAlign) {
235245
MHostPtrReadOnly = iterator_to_const_type_t<InputIterator>::value;
236246
setAlign(RequiredAlign);
237247
if (useHostPtr())
@@ -254,23 +264,24 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
254264
static_cast<IteratorPointerToNonConstValueType>(MUserPtr));
255265
}
256266

257-
void setAlign(size_t RequiredAlign) {
267+
DLL_LOCAL void setAlign(size_t RequiredAlign) {
258268
MAllocator->setAlignment(RequiredAlign);
259269
}
260270

261271
static size_t getBufSizeForContext(const ContextImplPtr &Context,
262272
cl_mem MemObject);
263273

264-
void *allocateMem(ContextImplPtr Context, bool InitFromUserData,
265-
void *HostPtr, RT::PiEvent &InteropEvent) override {
274+
DLL_LOCAL void *allocateMem(ContextImplPtr Context, bool InitFromUserData,
275+
void *HostPtr,
276+
RT::PiEvent &InteropEvent) override {
266277
(void)Context;
267278
(void)InitFromUserData;
268279
(void)HostPtr;
269280
(void)InteropEvent;
270281
throw runtime_error("Not implemented", PI_INVALID_OPERATION);
271282
}
272283

273-
MemObjType getType() const override { return UNDEFINED; }
284+
DLL_LOCAL MemObjType getType() const override { return UNDEFINED; }
274285

275286
protected:
276287
// Allocator used for allocation memory on host.

0 commit comments

Comments
 (0)