diff --git a/src/CUDAStream.cu b/src/CUDAStream.cu index caf5e1a..5ec1e67 100644 --- a/src/CUDAStream.cu +++ b/src/CUDAStream.cu @@ -16,6 +16,12 @@ CUDAStream::CUDAStream(const unsigned int ARRAY_SIZE) { array_size = ARRAY_SIZE; + // Check buffers fit on the device + cudaDeviceProp props; + cudaGetDeviceProperties(&props, 0); + if (props.totalGlobalMem < 3*ARRAY_SIZE*sizeof(T)) + throw std::runtime_error("Device does not have enough memory for all 3 buffers"); + // Create device buffers cudaMalloc(&d_a, ARRAY_SIZE*sizeof(T)); check_error(); diff --git a/src/CUDAStream.h b/src/CUDAStream.h index 451cfc1..bde574e 100644 --- a/src/CUDAStream.h +++ b/src/CUDAStream.h @@ -1,5 +1,6 @@ #include +#include #include "Stream.h"