28 #include <cuda_runtime.h> 35 auto s = (cudaStream_t*)m_stream;
37 delete (cudaStream_t*)m_stream;
46 gpuErrchk(cudaRuntimeGetVersion(&version));
55 m_stream =
new cudaStream_t;
56 gpuErrchk(cudaStreamCreate((cudaStream_t*)m_stream));
65 void GPU::obtainUUID() {
69 if (NVML_SUCCESS == nvmlInit()) {
70 if (NVML_SUCCESS == nvmlDeviceGetHandleByIndex(m_device, &device)) {
72 if (NVML_SUCCESS == nvmlDeviceGetUUID(device, uuid, 80)) {
98 assert(0 == cudaHostRegisterDefault);
100 if (0 != ((
size_t)h_mem % 4096)) {
105 gpuErrchk(cudaHostRegister(const_cast<void*>(h_mem), bytes, flags));
110 auto err = cudaHostUnregister(const_cast<void*>(h_mem));
111 if (cudaErrorHostMemoryNotRegistered == err) {
120 gpuErrchk(cudaGetDeviceCount(&deviceCount));
131 auto stream = (cudaStream_t*)m_stream;
141 cudaPointerAttributes attr;
142 if (cudaPointerGetAttributes(&attr, h_mem) != cudaSuccess) {
146 #if defined(CUDART_VERSION) && CUDART_VERSION >= 10000 147 return (cudaMemoryTypeHost == attr.type) || (cudaMemoryTypeManaged == attr.type);
149 return cudaMemoryTypeHost == attr.memoryType;
154 cudaPointerAttributes attr;
155 if (cudaPointerGetAttributes(&attr, p) == cudaErrorInvalidValue) {
159 #if defined(CUDART_VERSION) && CUDART_VERSION >= 10000 160 return (cudaMemoryTypeDevice == attr.type) || (cudaMemoryTypeManaged == attr.type);
162 return cudaMemoryTypeDevice == attr.memoryType;
#define REPORT_ERROR(nerr, ErrormMsg)
static void setDevice(int device)
static bool isMemoryPinned(const void *h_mem)
static void pinMemory(const void *h_mem, size_t bytes, unsigned int flags=0)
void peekLastError() const
static int getDeviceCount()
static void unpinMemory(const void *h_mem)
bool isGpuPointer(const void *)