diff options
Diffstat (limited to 'cuda')
-rw-r--r-- | cuda/2d/algo.h | 3 | ||||
-rw-r--r-- | cuda/2d/astra.cu | 42 | ||||
-rw-r--r-- | cuda/2d/astra.h | 9 | ||||
-rw-r--r-- | cuda/2d/cgls.h | 1 | ||||
-rw-r--r-- | cuda/2d/darthelper.cu | 16 | ||||
-rw-r--r-- | cuda/2d/darthelper.h | 4 | ||||
-rw-r--r-- | cuda/2d/em.h | 1 | ||||
-rw-r--r-- | cuda/2d/fbp.cu | 1 | ||||
-rw-r--r-- | cuda/2d/sart.h | 1 | ||||
-rw-r--r-- | cuda/2d/sirt.h | 1 | ||||
-rw-r--r-- | cuda/2d/util.cu | 1 | ||||
-rw-r--r-- | cuda/2d/util.h | 18 | ||||
-rw-r--r-- | cuda/3d/cgls3d.h | 1 | ||||
-rw-r--r-- | cuda/3d/darthelper3d.h | 5 | ||||
-rw-r--r-- | cuda/3d/mem3d.cu | 2 | ||||
-rw-r--r-- | cuda/3d/mem3d.h | 2 | ||||
-rw-r--r-- | cuda/3d/sirt3d.h | 1 |
17 files changed, 59 insertions, 50 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 diff --git a/cuda/3d/cgls3d.h b/cuda/3d/cgls3d.h index e09fcfb..2ed2b1d 100644 --- a/cuda/3d/cgls3d.h +++ b/cuda/3d/cgls3d.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #ifndef _CUDA_CGLS3D_H #define _CUDA_CGLS3D_H -#include "util3d.h" #include "algo3d.h" namespace astraCUDA3d { diff --git a/cuda/3d/darthelper3d.h b/cuda/3d/darthelper3d.h index 71ea5b0..539fa06 100644 --- a/cuda/3d/darthelper3d.h +++ b/cuda/3d/darthelper3d.h @@ -28,10 +28,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #ifndef _CUDA_DARTHELPER3_H #define _CUDA_DARTHELPER3_H -#include <cuda.h> -#include <driver_types.h> -#include "util3d.h" -#include "algo3d.h" +#include "dims3d.h" namespace astraCUDA3d { diff --git a/cuda/3d/mem3d.cu b/cuda/3d/mem3d.cu index ed779fa..2369149 100644 --- a/cuda/3d/mem3d.cu +++ b/cuda/3d/mem3d.cu @@ -326,7 +326,7 @@ bool FDK(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, co } -MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch) +_AstraExport MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch) { cudaPitchedPtr ptr; ptr.ptr = D_ptr; diff --git a/cuda/3d/mem3d.h b/cuda/3d/mem3d.h index 7a87ae6..619354b 100644 --- a/cuda/3d/mem3d.h +++ b/cuda/3d/mem3d.h @@ -80,7 +80,7 @@ enum Mem3DZeroMode { size_t availableGPUMemory(); int maxBlockDimension(); -MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch); +_AstraExport MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch); MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Mem3DZeroMode zero); diff --git a/cuda/3d/sirt3d.h b/cuda/3d/sirt3d.h index 69031b8..337ca89 100644 --- a/cuda/3d/sirt3d.h +++ b/cuda/3d/sirt3d.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #ifndef _CUDA_SIRT3D_H #define _CUDA_SIRT3D_H -#include "util3d.h" #include "algo3d.h" namespace astraCUDA3d { |