summaryrefslogtreecommitdiff
path: root/src/cupp11.hpp
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-12-30 18:45:06 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2017-12-30 18:45:06 +0100
commitad1227c4f2934b0f60c0030101e18b8fb21daf8c (patch)
tree00db3a1af9a52c93df4e9473e05fc8f636838e98 /src/cupp11.hpp
parent6d1e30e61f5ef73f0a83e12f064cae64644034ca (diff)
Added optional temp-buffer argument to C++ interface of GEMM
Diffstat (limited to 'src/cupp11.hpp')
-rw-r--r--src/cupp11.hpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cupp11.hpp b/src/cupp11.hpp
index eb177ca2..509ae3e8 100644
--- a/src/cupp11.hpp
+++ b/src/cupp11.hpp
@@ -549,12 +549,12 @@ public:
// Regular constructor with memory management. If this class does not own the buffer object, then
// the memory will not be freed automatically afterwards.
explicit Buffer(const Context &, const BufferAccess access, const size_t size):
- buffer_(new CUdeviceptr, [access](CUdeviceptr* m) {
- if (access != BufferAccess::kNotOwned) { CheckError(cuMemFree(*m)); }
+ buffer_(new CUdeviceptr, [access, size](CUdeviceptr* m) {
+ if (access != BufferAccess::kNotOwned && size > 0) { CheckError(cuMemFree(*m)); }
delete m;
}),
access_(access) {
- CheckError(cuMemAlloc(buffer_.get(), size*sizeof(T)));
+ if (size > 0) { CheckError(cuMemAlloc(buffer_.get(), size*sizeof(T))); }
}
// As above, but now with read/write access as a default