From 6ee36e978b73c99f4543278662e9da914357378e Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 16 Oct 2017 19:07:45 +0200 Subject: Fix Windows/Python build --- cuda/3d/mem3d.cu | 2 +- cuda/3d/mem3d.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cuda') 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); -- cgit v1.2.3 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 ++++++++++++++++++++++++ cuda/2d/util.h | 4 ++++ 2 files changed, 28 insertions(+) (limited to 'cuda') 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; +} + + } diff --git a/cuda/2d/util.h b/cuda/2d/util.h index 875aae3..31fcfbd 100644 --- a/cuda/2d/util.h +++ b/cuda/2d/util.h @@ -30,6 +30,7 @@ along with the ASTRA Toolbox. If not, see . #include #include +#include #ifdef _MSC_VER @@ -92,6 +93,9 @@ void reportCudaError(cudaError_t err); float dotProduct2D(float* D_data, unsigned int pitch, unsigned int width, unsigned int height); +// 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); } -- cgit v1.2.3 From d753de051893698bfd1e107a2d03b1a38b55dd91 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 31 Oct 2017 17:10:56 +0100 Subject: Remove some unnecessary includes --- cuda/2d/algo.h | 3 ++- cuda/2d/astra.h | 1 - cuda/2d/cgls.h | 1 - cuda/2d/darthelper.h | 2 +- cuda/2d/em.h | 1 - cuda/2d/sart.h | 1 - cuda/2d/sirt.h | 1 - cuda/2d/util.h | 16 +--------------- cuda/3d/cgls3d.h | 1 - cuda/3d/darthelper3d.h | 5 +---- cuda/3d/sirt3d.h | 1 - 11 files changed, 5 insertions(+), 28 deletions(-) (limited to 'cuda') diff --git a/cuda/2d/algo.h b/cuda/2d/algo.h index dc3bb05..4a75907 100644 --- a/cuda/2d/algo.h +++ b/cuda/2d/algo.h @@ -28,7 +28,8 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_ALGO_H #define _CUDA_ALGO_H -#include "util.h" +#include "astra/Globals.h" +#include "dims.h" namespace astraCUDA { diff --git a/cuda/2d/astra.h b/cuda/2d/astra.h index 78d00e3..c9e0762 100644 --- a/cuda/2d/astra.h +++ b/cuda/2d/astra.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_ASTRA_H #define _CUDA_ASTRA_H -#include "fft.h" #include "fbp_filters.h" #include "dims.h" #include "algo.h" 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 . #ifndef _CUDA_CGLS_H #define _CUDA_CGLS_H -#include "util.h" #include "algo.h" namespace astraCUDA { diff --git a/cuda/2d/darthelper.h b/cuda/2d/darthelper.h index a2f1f45..9a2837c 100644 --- a/cuda/2d/darthelper.h +++ b/cuda/2d/darthelper.h @@ -28,7 +28,7 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_ARITH2_H #define _CUDA_ARITH2_H -#include "util.h" +#include "astra/Globals.h" namespace astraCUDA { 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 . #ifndef _CUDA_EM_H #define _CUDA_EM_H -#include "util.h" #include "algo.h" namespace astraCUDA { 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 . #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 . #ifndef _CUDA_SIRT_H #define _CUDA_SIRT_H -#include "util.h" #include "algo.h" namespace astraCUDA { diff --git a/cuda/2d/util.h b/cuda/2d/util.h index 31fcfbd..6e36b6e 100644 --- a/cuda/2d/util.h +++ b/cuda/2d/util.h @@ -32,21 +32,7 @@ along with the ASTRA Toolbox. If not, see . #include #include -#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" 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 . #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 . #ifndef _CUDA_DARTHELPER3_H #define _CUDA_DARTHELPER3_H -#include -#include -#include "util3d.h" -#include "algo3d.h" +#include "dims3d.h" namespace astraCUDA3d { 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 . #ifndef _CUDA_SIRT3D_H #define _CUDA_SIRT3D_H -#include "util3d.h" #include "algo3d.h" namespace astraCUDA3d { -- 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/astra.cu | 41 +++++++++++++++++++++++++++++++++++++++++ cuda/2d/astra.h | 9 +++++++++ cuda/2d/darthelper.cu | 16 ---------------- cuda/2d/darthelper.h | 2 -- cuda/2d/util.cu | 25 ------------------------- cuda/2d/util.h | 4 ---- 6 files changed, 50 insertions(+), 47 deletions(-) (limited to 'cuda') diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu index 2ff9230..c0132b2 100644 --- a/cuda/2d/astra.cu +++ b/cuda/2d/astra.cu @@ -986,6 +986,47 @@ bool convertAstraGeometry(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 c9e0762..e4cefac 100644 --- a/cuda/2d/astra.h +++ b/cuda/2d/astra.h @@ -224,6 +224,15 @@ _AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, astraCUDA::SFanProjection*& pProjs, 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/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 9a2837c..67a6a7d 100644 --- a/cuda/2d/darthelper.h +++ b/cuda/2d/darthelper.h @@ -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/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; -} - - - } diff --git a/cuda/2d/util.h b/cuda/2d/util.h index 6e36b6e..382d862 100644 --- a/cuda/2d/util.h +++ b/cuda/2d/util.h @@ -79,10 +79,6 @@ void reportCudaError(cudaError_t err); float dotProduct2D(float* D_data, unsigned int pitch, unsigned int width, unsigned int height); -// 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); - } #endif -- cgit v1.2.3