diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2018-01-06 16:08:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-06 16:08:27 +0100 |
commit | a7ccce196915db7a3b7ea7fe8ea9048f5b1204c6 (patch) | |
tree | 27dd8771ee6f913b5a2dabfae115bbe7fbc9d979 /src/cupp11.hpp | |
parent | 8040a4e355bdf6531eb9c4c5ae1fe4f792899d24 (diff) | |
parent | ad197da08da7ef414db90dbb97e92c575363c280 (diff) |
Merge pull request #238 from CNugteren/gemm_api_with_temp_buffer
GEMM API with optional temp buffer
Diffstat (limited to 'src/cupp11.hpp')
-rw-r--r-- | src/cupp11.hpp | 6 |
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 |