summaryrefslogtreecommitdiffstats
path: root/cuda/2d
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
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')
-rw-r--r--cuda/2d/algo.h3
-rw-r--r--cuda/2d/astra.cu42
-rw-r--r--cuda/2d/astra.h9
-rw-r--r--cuda/2d/cgls.h1
-rw-r--r--cuda/2d/darthelper.cu16
-rw-r--r--cuda/2d/darthelper.h4
-rw-r--r--cuda/2d/em.h1
-rw-r--r--cuda/2d/fbp.cu1
-rw-r--r--cuda/2d/sart.h1
-rw-r--r--cuda/2d/sirt.h1
-rw-r--r--cuda/2d/util.cu1
-rw-r--r--cuda/2d/util.h18
12 files changed, 56 insertions, 42 deletions
diff --git a/cuda/2d/algo.h b/cuda/2d/algo.h
index c1d932c..d70859f 100644
--- a/cuda/2d/algo.h
+++ b/cuda/2d/algo.h
@@ -28,7 +28,8 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#ifndef _CUDA_ALGO_H
#define _CUDA_ALGO_H
-#include "util.h"
+#include "astra/Globals.h"
+#include "dims.h"
namespace astra {
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;
+}
}
diff --git a/cuda/2d/astra.h b/cuda/2d/astra.h
index a20b830..9355cb4 100644
--- a/cuda/2d/astra.h
+++ b/cuda/2d/astra.h
@@ -111,6 +111,15 @@ _AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom,
astraCUDA::SParProjection*& pParProjs,
astraCUDA::SFanProjection*& pFanProjs,
float& outputScale);
+}
+
+namespace astraCUDA {
+
+// Return string with CUDA device number, name and memory size.
+// Use device == -1 to get info for the current device.
+_AstraExport std::string getCudaDeviceString(int device);
+
+_AstraExport bool setGPUIndex(int index);
}
#endif
diff --git a/cuda/2d/cgls.h b/cuda/2d/cgls.h
index 804f943..c45b5a4 100644
--- a/cuda/2d/cgls.h
+++ b/cuda/2d/cgls.h
@@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#ifndef _CUDA_CGLS_H
#define _CUDA_CGLS_H
-#include "util.h"
#include "algo.h"
namespace astraCUDA {
diff --git a/cuda/2d/darthelper.cu b/cuda/2d/darthelper.cu
index 744184e..d4b5220 100644
--- a/cuda/2d/darthelper.cu
+++ b/cuda/2d/darthelper.cu
@@ -356,20 +356,4 @@ void dartSmoothing(float* out, const float* in, float b, unsigned int radius, un
}
-
-_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;
-}
-
-
}
diff --git a/cuda/2d/darthelper.h b/cuda/2d/darthelper.h
index a2f1f45..67a6a7d 100644
--- a/cuda/2d/darthelper.h
+++ b/cuda/2d/darthelper.h
@@ -28,7 +28,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#ifndef _CUDA_ARITH2_H
#define _CUDA_ARITH2_H
-#include "util.h"
+#include "astra/Globals.h"
namespace astraCUDA {
@@ -36,8 +36,6 @@ namespace astraCUDA {
void dartMask(float* out, const float* in, unsigned int conn, unsigned int radius, unsigned int threshold, unsigned int width, unsigned int height);
void dartSmoothing(float* out, const float* in, float b, unsigned int radius, unsigned int width, unsigned int height);
- _AstraExport bool setGPUIndex(int index);
-
}
#endif
diff --git a/cuda/2d/em.h b/cuda/2d/em.h
index f99e798..15795f7 100644
--- a/cuda/2d/em.h
+++ b/cuda/2d/em.h
@@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#ifndef _CUDA_EM_H
#define _CUDA_EM_H
-#include "util.h"
#include "algo.h"
namespace astraCUDA {
diff --git a/cuda/2d/fbp.cu b/cuda/2d/fbp.cu
index 04cac1e..365fc88 100644
--- a/cuda/2d/fbp.cu
+++ b/cuda/2d/fbp.cu
@@ -30,6 +30,7 @@ $Id$
#include "fft.h"
#include "par_bp.h"
#include "fan_bp.h"
+#include "util.h"
// For fan-beam preweighting
#include "../3d/fdk.h"
diff --git a/cuda/2d/sart.h b/cuda/2d/sart.h
index ab99e66..06051ae 100644
--- a/cuda/2d/sart.h
+++ b/cuda/2d/sart.h
@@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#ifndef _CUDA_SART_H
#define _CUDA_SART_H
-#include "util.h"
#include "algo.h"
namespace astraCUDA {
diff --git a/cuda/2d/sirt.h b/cuda/2d/sirt.h
index 488ab0a..7c440d5 100644
--- a/cuda/2d/sirt.h
+++ b/cuda/2d/sirt.h
@@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#ifndef _CUDA_SIRT_H
#define _CUDA_SIRT_H
-#include "util.h"
#include "algo.h"
namespace astraCUDA {
diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu
index 09d1a2b..871e139 100644
--- a/cuda/2d/util.cu
+++ b/cuda/2d/util.cu
@@ -274,5 +274,4 @@ void reportCudaError(cudaError_t err)
}
-
}
diff --git a/cuda/2d/util.h b/cuda/2d/util.h
index 875aae3..382d862 100644
--- a/cuda/2d/util.h
+++ b/cuda/2d/util.h
@@ -30,22 +30,9 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#include <cuda.h>
#include <driver_types.h>
+#include <string>
-#ifdef _MSC_VER
-
-#ifdef DLL_EXPORTS
-#define _AstraExport __declspec(dllexport)
-#define EXPIMP_TEMPLATE
-#else
-#define _AstraExport __declspec(dllimport)
-#define EXPIMP_TEMPLATE extern
-#endif
-
-#else
-
-#define _AstraExport
-
-#endif
+#include "astra/Globals.h"
#include "dims.h"
@@ -92,7 +79,6 @@ void reportCudaError(cudaError_t err);
float dotProduct2D(float* D_data, unsigned int pitch,
unsigned int width, unsigned int height);
-
}
#endif