Check bufers fit on CUDA device
This commit is contained in:
parent
9aa27cd91d
commit
40c787d040
@ -16,6 +16,12 @@ CUDAStream<T>::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();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "Stream.h"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user