16 #include <cuda_runtime.h>
19 #define checkRuntime(call) check_runtime(call, #call, __LINE__, __FILE__)
21 #define CUOSD_PRINT_E(f_, ...) \
22 fprintf(stderr, "[cuOSD Error] at %s:%d : " f_, (const char*)__FILE__, __LINE__, ##__VA_ARGS__)
24 #define CUOSD_PRINT_W(f_, ...) \
25 printf("[cuOSD Warning] at %s:%d : " f_, (const char*)__FILE__, __LINE__, ##__VA_ARGS__)
27 static bool inline check_runtime(cudaError_t e,
const char* call,
int line,
const char *file) {
28 if (e != cudaSuccess) {
29 fprintf(stderr,
"CUDA Runtime error %s # %s, code = %s [ %d ] in file %s:%d\n", call, cudaGetErrorString(e), cudaGetErrorName(e), e, file, line);
38 T*
host()
const{
return host_;}
40 size_t size()
const{
return size_;}
41 size_t bytes()
const{
return size_ *
sizeof(T);}
48 checkRuntime(cudaMemcpyAsync(device_, host_,
bytes(), cudaMemcpyHostToDevice, stream));
51 checkRuntime(cudaMemcpyAsync(host_, device_,
bytes(), cudaMemcpyDeviceToHost, stream));
55 if (capacity_ <
size) {
66 if (host_ || device_) {