Loading include/dca/linalg/util/allocators/device_allocator.hpp +10 −5 Original line number Diff line number Diff line Loading @@ -44,9 +44,14 @@ protected: void deallocate(T*& ptr, std::size_t /*n*/ = 0) noexcept { cudaError_t ret = cudaFree(ptr); if (ret != cudaSuccess) { if (ret == cudaErrorCudartUnloading) { // std::cerr << "Warning: deallocating CUDA DEVICE memory after device shutdown" << std::endl; } else { printErrorMessage(ret, __FUNCTION__, __FILE__, __LINE__); std::terminate(); } } ptr = nullptr; } Loading @@ -55,8 +60,8 @@ public: void setStream(const cudaStream_t /*stream*/) const {} }; } // util } // linalg } // dca } // namespace util } // namespace linalg } // namespace dca #endif // DCA_LINALG_UTIL_ALLOCATORS_DEVICE_ALLOCATOR_HPP include/dca/linalg/util/allocators/pinned_allocator.hpp +17 −8 Original line number Diff line number Diff line Loading @@ -50,13 +50,18 @@ public: void deallocate(T*& ptr, std::size_t /*n*/ = 0) noexcept { cudaError_t ret = cudaFreeHost(ptr); if (ret != cudaSuccess) { if (ret == cudaErrorCudartUnloading) { // std::cerr << "Warning: deallocating CUDA HOST memory after device shutdown" << std::endl; } else { printErrorMessage(ret, __FUNCTION__, __FILE__, __LINE__); std::terminate(); } } ptr = nullptr; } }; // These are part of the requirements for a C++ Allocator however these are insufficient Loading @@ -64,12 +69,16 @@ public: // They are part of what's needed to do a std::move on a PinnedAllocator backed object // and avoid deallocation and reallocation. template <class T, class U> bool operator==(const PinnedAllocator<T>&, const PinnedAllocator<U>&) { return true; } bool operator==(const PinnedAllocator<T>&, const PinnedAllocator<U>&) { return true; } template <class T, class U> bool operator!=(const PinnedAllocator<T>&, const PinnedAllocator<U>&) { return false; } bool operator!=(const PinnedAllocator<T>&, const PinnedAllocator<U>&) { return false; } } // util } // linalg } // dca } // namespace util } // namespace linalg } // namespace dca #endif // DCA_LINALG_UTIL_ALLOCATORS_PINNED_ALLOCATOR_HPP Loading
include/dca/linalg/util/allocators/device_allocator.hpp +10 −5 Original line number Diff line number Diff line Loading @@ -44,9 +44,14 @@ protected: void deallocate(T*& ptr, std::size_t /*n*/ = 0) noexcept { cudaError_t ret = cudaFree(ptr); if (ret != cudaSuccess) { if (ret == cudaErrorCudartUnloading) { // std::cerr << "Warning: deallocating CUDA DEVICE memory after device shutdown" << std::endl; } else { printErrorMessage(ret, __FUNCTION__, __FILE__, __LINE__); std::terminate(); } } ptr = nullptr; } Loading @@ -55,8 +60,8 @@ public: void setStream(const cudaStream_t /*stream*/) const {} }; } // util } // linalg } // dca } // namespace util } // namespace linalg } // namespace dca #endif // DCA_LINALG_UTIL_ALLOCATORS_DEVICE_ALLOCATOR_HPP
include/dca/linalg/util/allocators/pinned_allocator.hpp +17 −8 Original line number Diff line number Diff line Loading @@ -50,13 +50,18 @@ public: void deallocate(T*& ptr, std::size_t /*n*/ = 0) noexcept { cudaError_t ret = cudaFreeHost(ptr); if (ret != cudaSuccess) { if (ret == cudaErrorCudartUnloading) { // std::cerr << "Warning: deallocating CUDA HOST memory after device shutdown" << std::endl; } else { printErrorMessage(ret, __FUNCTION__, __FILE__, __LINE__); std::terminate(); } } ptr = nullptr; } }; // These are part of the requirements for a C++ Allocator however these are insufficient Loading @@ -64,12 +69,16 @@ public: // They are part of what's needed to do a std::move on a PinnedAllocator backed object // and avoid deallocation and reallocation. template <class T, class U> bool operator==(const PinnedAllocator<T>&, const PinnedAllocator<U>&) { return true; } bool operator==(const PinnedAllocator<T>&, const PinnedAllocator<U>&) { return true; } template <class T, class U> bool operator!=(const PinnedAllocator<T>&, const PinnedAllocator<U>&) { return false; } bool operator!=(const PinnedAllocator<T>&, const PinnedAllocator<U>&) { return false; } } // util } // linalg } // dca } // namespace util } // namespace linalg } // namespace dca #endif // DCA_LINALG_UTIL_ALLOCATORS_PINNED_ALLOCATOR_HPP