From 17ebcfefa7c42cff61a81bf12a915983b330ed15 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 17:20:40 +0200 Subject: Add astra.astra.get_gpu_info utility function --- cuda/2d/util.cu | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'cuda/2d/util.cu') diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu index 09d1a2b..9c1bb28 100644 --- a/cuda/2d/util.cu +++ b/cuda/2d/util.cu @@ -274,5 +274,29 @@ void reportCudaError(cudaError_t err) } +_AstraExport std::string getCudaDeviceString(int device) +{ + char buf[1024]; + cudaError_t err; + if (device == -1) { + err = cudaGetDevice(&device); + if (err != cudaSuccess) { + return "Error getting current GPU index"; + } + } + + cudaDeviceProp prop; + err = cudaGetDeviceProperties(&prop, device); + if (err != cudaSuccess) { + snprintf(buf, 1024, "GPU #%d: Invalid device (%d): %s", device, err, cudaGetErrorString(err)); + return buf; + } + + long mem = prop.totalGlobalMem / (1024*1024); + snprintf(buf, 1024, "GPU #%d: %s, with %ldMB", device, prop.name, mem); + return buf; +} + + } -- cgit v1.2.3 From f70f68fcd465f421b566b199e23e66c1f186b01d Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 1 Nov 2017 15:05:13 +0100 Subject: Separate cuda from astra headers further --- cuda/2d/util.cu | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'cuda/2d/util.cu') diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu index 9c1bb28..871e139 100644 --- a/cuda/2d/util.cu +++ b/cuda/2d/util.cu @@ -274,29 +274,4 @@ void reportCudaError(cudaError_t err) } -_AstraExport std::string getCudaDeviceString(int device) -{ - char buf[1024]; - cudaError_t err; - if (device == -1) { - err = cudaGetDevice(&device); - if (err != cudaSuccess) { - return "Error getting current GPU index"; - } - } - - cudaDeviceProp prop; - err = cudaGetDeviceProperties(&prop, device); - if (err != cudaSuccess) { - snprintf(buf, 1024, "GPU #%d: Invalid device (%d): %s", device, err, cudaGetErrorString(err)); - return buf; - } - - long mem = prop.totalGlobalMem / (1024*1024); - snprintf(buf, 1024, "GPU #%d: %s, with %ldMB", device, prop.name, mem); - return buf; -} - - - } -- cgit v1.2.3