summaryrefslogtreecommitdiffstats
path: root/cuda/2d/astra.cu
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-11-22 16:41:34 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-11-22 16:41:34 +0100
commita527cc9e29cae256bd095b032f34c80957e84907 (patch)
treee68dd547d6a88c188eca4798423adf084ba58124 /cuda/2d/astra.cu
parent6a7b605102f1c22224b516906cb4a848cda50a3b (diff)
parentbd2798bed2fddfe00dac006013a9fb1363417f20 (diff)
downloadastra-a527cc9e29cae256bd095b032f34c80957e84907.tar.gz
astra-a527cc9e29cae256bd095b032f34c80957e84907.tar.bz2
astra-a527cc9e29cae256bd095b032f34c80957e84907.tar.xz
astra-a527cc9e29cae256bd095b032f34c80957e84907.zip
Merge branch 'master' into parallel_vec
Diffstat (limited to 'cuda/2d/astra.cu')
-rw-r--r--cuda/2d/astra.cu42
1 files changed, 41 insertions, 1 deletions
diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu
index 279b57d..81459de 100644
--- a/cuda/2d/astra.cu
+++ b/cuda/2d/astra.cu
@@ -441,7 +441,6 @@ bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom,
return true;
}
-
bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom,
const CProjectionGeometry2D* pProjGeom,
astraCUDA::SParProjection*& pParProjs,
@@ -488,6 +487,47 @@ bool convertAstraGeometry_dims(const CVolumeGeometry2D* pVolGeom,
+}
+
+namespace astraCUDA {
+
+
+_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;
+}
+
+_AstraExport bool setGPUIndex(int iGPUIndex)
+{
+ if (iGPUIndex != -1) {
+ cudaSetDevice(iGPUIndex);
+ cudaError_t err = cudaGetLastError();
+
+ // Ignore errors caused by calling cudaSetDevice multiple times
+ if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess)
+ return false;
+ }
+
+ return true;
+}
}