From a5bb8f3d9cf97b9e725e88dcdc6b21d2106e0292 Mon Sep 17 00:00:00 2001 From: Gallo Alejandro Date: Mon, 12 Sep 2022 19:39:38 +0200 Subject: [PATCH] Give a better message when out of memory in allocating SliceUnion --- include/atrip/SliceUnion.hpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/atrip/SliceUnion.hpp b/include/atrip/SliceUnion.hpp index 87ba5e8..1f8c826 100644 --- a/include/atrip/SliceUnion.hpp +++ b/include/atrip/SliceUnion.hpp @@ -412,10 +412,17 @@ template for (auto& ptr: sliceBuffers) { #if defined(HAVE_CUDA) - cuMemAlloc(&ptr, sizeof(F) * sources[0].size()); - if (ptr == 0UL) { - throw "UNSUFICCIENT MEMORY ON THE GRAPHIC CARD FOR FREE POINTERS"; - } + const CUresult error = + cuMemAlloc(&ptr, sizeof(F) * sources[0].size()); + if (ptr == 0UL) { + throw "UNSUFICCIENT MEMORY ON THE GRAPHIC CARD FOR FREE POINTERS"; + } + if (error != CUDA_SUCCESS) { + std::stringstream s; + s << "Error allocating memory for slice buffers " + << "code " << error << "\n"; + throw s.str(); + } #else ptr = (DataPtr)malloc(sizeof(F) * sources[0].size()); #endif