21 #include <cuda_runtime.h>
24 #define checkRuntime(call) check_runtime(call, #call, __LINE__, __FILE__)
26 #define CUOSD_PRINT_E(f_, ...) \
27 fprintf(stderr, "[cuOSD Error] at %s:%d : " f_, (const char*)__FILE__, __LINE__, ##__VA_ARGS__)
29 #define CUOSD_PRINT_W(f_, ...) \
30 printf("[cuOSD Warning] at %s:%d : " f_, (const char*)__FILE__, __LINE__, ##__VA_ARGS__)
32 static bool inline check_runtime(cudaError_t e,
const char* call,
int line,
const char *file) {
33 if (e != cudaSuccess) {
34 fprintf(stderr,
"CUDA Runtime error %s # %s, code = %s [ %d ] in file %s:%d\n", call, cudaGetErrorString(e), cudaGetErrorName(e), e, file, line);
43 T*
host()
const{
return host_;}
45 size_t size()
const{
return size_;}
46 size_t bytes()
const{
return size_ *
sizeof(T);}
53 checkRuntime(cudaMemcpyAsync(device_, host_,
bytes(), cudaMemcpyHostToDevice, stream));
56 checkRuntime(cudaMemcpyAsync(host_, device_,
bytes(), cudaMemcpyDeviceToHost, stream));
60 if (capacity_ <
size) {
71 if (host_ || device_) {