@@ -62,8 +62,8 @@ class UnifiedBuffer
6262 {
6363 assert (mSize <= mCapacity );
6464 cudaCheck (cudaMallocManaged (&mPtr , mCapacity , cudaMemAttachGlobal));
65- cudaCheck (cudaMemAdvise (mPtr , size, cudaMemAdviseSetPreferredLocation, device));
66- cudaCheck (cudaMemPrefetchAsync (mPtr , size, device, stream));
65+ cudaCheck (util::cuda::memAdvise (mPtr , size, cudaMemAdviseSetPreferredLocation, device));
66+ cudaCheck (util::cuda::memPrefetchAsync (mPtr , size, device, stream));
6767 }
6868
6969 // / @brief Constructor with a specified device
@@ -113,8 +113,8 @@ class UnifiedBuffer
113113 {
114114 const size_t capacity = (reference && reference->capacity ()) ? reference->capacity () : size;
115115 UnifiedBuffer buffer (size, capacity);
116- cudaCheck (cudaMemAdvise (buffer.mPtr , size, cudaMemAdviseSetPreferredLocation, device));
117- cudaCheck (cudaMemPrefetchAsync (buffer.mPtr , size, device, stream));
116+ cudaCheck (util::cuda::memAdvise (buffer.mPtr , size, cudaMemAdviseSetPreferredLocation, device));
117+ cudaCheck (util::cuda::memPrefetchAsync (buffer.mPtr , size, device, stream));
118118 return buffer;
119119 }
120120
@@ -184,7 +184,7 @@ class UnifiedBuffer
184184 } else {
185185 void *ptr = 0 ;
186186 cudaCheck (cudaMallocManaged (&ptr, size, cudaMemAttachGlobal));
187- if (dev > -2 ) for (auto a : list) cudaCheck (cudaMemAdvise (ptr, size, a, dev));
187+ if (dev > -2 ) for (auto a : list) cudaCheck (util::cuda::memAdvise (ptr, size, a, dev));
188188 if (mSize > 0 ) {// copy over data from the old memory block
189189 cudaCheck (cudaMemcpy (ptr, mPtr , std::min (mSize , size), cudaMemcpyDefault));
190190 cudaCheck (cudaFree (mPtr ));
@@ -201,7 +201,7 @@ class UnifiedBuffer
201201 // / @param adv advice to be applied to the resized range
202202 void advise (ptrdiff_t byteOffset, size_t size, int dev, cudaMemoryAdvise adv) const
203203 {
204- cudaCheck (cudaMemAdvise (util::PtrAdd (mPtr , byteOffset), size, adv, dev));
204+ cudaCheck (util::cuda::memAdvise (util::PtrAdd (mPtr , byteOffset), size, adv, dev));
205205 }
206206
207207 // / @brief Apply a list of advices to a memory block
@@ -212,7 +212,7 @@ class UnifiedBuffer
212212 void advise (ptrdiff_t byteOffset, size_t size, int dev, std::initializer_list<cudaMemoryAdvise> list) const
213213 {
214214 void *ptr = util::PtrAdd (mPtr , byteOffset);
215- for (auto a : list) cudaCheck (cudaMemAdvise (ptr, size, a, dev));
215+ for (auto a : list) cudaCheck (util::cuda::memAdvise (ptr, size, a, dev));
216216 }
217217
218218 // / @brief Prefetches data to the specified device, i.e. ensure the device has an up-to-date copy of the memory specified
@@ -222,7 +222,7 @@ class UnifiedBuffer
222222 // / @param stream cuda stream
223223 void prefetch (ptrdiff_t byteOffset = 0 , size_t size = 0 , int dev = cudaCpuDeviceId, cudaStream_t stream = cudaStreamPerThread) const
224224 {
225- cudaCheck (cudaMemPrefetchAsync (util::PtrAdd (mPtr , byteOffset), size ? size : mSize , dev, stream));
225+ cudaCheck (util::cuda::memPrefetchAsync (util::PtrAdd (mPtr , byteOffset), size ? size : mSize , dev, stream));
226226 }
227227
228228 // /////////////////////////////////////////////////////////////////////
@@ -234,7 +234,7 @@ class UnifiedBuffer
234234 // / @note Legacy method included for compatibility with DeviceBuffer
235235 void deviceUpload (int device = 0 , cudaStream_t stream = cudaStreamPerThread, bool sync = false ) const
236236 {
237- cudaCheck (cudaMemPrefetchAsync (mPtr , mSize , device, stream));
237+ cudaCheck (util::cuda::memPrefetchAsync (mPtr , mSize , device, stream));
238238 if (sync) cudaCheck (cudaStreamSynchronize (stream));
239239 }
240240 void deviceUpload (int device, void * stream, bool sync) const {this ->deviceUpload (device, cudaStream_t (stream));}
@@ -256,7 +256,7 @@ class UnifiedBuffer
256256 // / @param sync if false the memory copy is asynchronous
257257 void deviceDownload (cudaStream_t stream = 0 , bool sync = false ) const
258258 {
259- cudaCheck (cudaMemPrefetchAsync (mPtr , mSize , cudaCpuDeviceId, stream));
259+ cudaCheck (util::cuda::memPrefetchAsync (mPtr , mSize , cudaCpuDeviceId, stream));
260260 if (sync) cudaCheck (cudaStreamSynchronize (stream));
261261 }
262262
0 commit comments