diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2017-11-09 20:57:31 +0100 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2018-01-09 14:23:54 +0100 |
commit | 0ad6cb01b9176e99c3e4bb5643ac6a5dd477aad6 (patch) | |
tree | 69b27fa6406cf318d785c827e1fd05b786da2876 /cuda/3d | |
parent | de27e439a0c59fade175fba4e0b4a1e0c84b933d (diff) | |
download | astra-0ad6cb01b9176e99c3e4bb5643ac6a5dd477aad6.tar.gz astra-0ad6cb01b9176e99c3e4bb5643ac6a5dd477aad6.tar.bz2 astra-0ad6cb01b9176e99c3e4bb5643ac6a5dd477aad6.tar.xz astra-0ad6cb01b9176e99c3e4bb5643ac6a5dd477aad6.zip |
Check for CUDA support at run-time in use_cuda()
Diffstat (limited to 'cuda/3d')
-rw-r--r-- | cuda/3d/mem3d.cu | 19 | ||||
-rw-r--r-- | cuda/3d/mem3d.h | 1 |
2 files changed, 6 insertions, 14 deletions
diff --git a/cuda/3d/mem3d.cu b/cuda/3d/mem3d.cu index 2369149..e55cc13 100644 --- a/cuda/3d/mem3d.cu +++ b/cuda/3d/mem3d.cu @@ -32,6 +32,8 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "mem3d.h" +#include "../2d/astra.h" + #include "astra3d.h" #include "cone_fp.h" #include "cone_bp.h" @@ -53,15 +55,6 @@ struct SMemHandle3D_internal unsigned int nz; }; -size_t availableGPUMemory() -{ - size_t free, total; - cudaError_t err = cudaMemGetInfo(&free, &total); - if (err != cudaSuccess) - return 0; - return free; -} - int maxBlockDimension() { int dev; @@ -88,7 +81,7 @@ MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Me hnd.ny = y; hnd.nz = z; - size_t free = availableGPUMemory(); + size_t free = astraCUDA::availableGPUMemory(); cudaError_t err; err = cudaMalloc3D(&hnd.ptr, make_cudaExtent(sizeof(float)*x, y, z)); @@ -97,7 +90,7 @@ MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Me return MemHandle3D(); } - size_t free2 = availableGPUMemory(); + size_t free2 = astraCUDA::availableGPUMemory(); ASTRA_DEBUG("Allocated %d x %d x %d on GPU. (Pre: %lu, post: %lu)", x, y, z, free, free2); @@ -127,9 +120,9 @@ bool zeroGPUMemory(MemHandle3D handle, unsigned int x, unsigned int y, unsigned bool freeGPUMemory(MemHandle3D handle) { - size_t free = availableGPUMemory(); + size_t free = astraCUDA::availableGPUMemory(); cudaError_t err = cudaFree(handle.d->ptr.ptr); - size_t free2 = availableGPUMemory(); + size_t free2 = astraCUDA::availableGPUMemory(); ASTRA_DEBUG("Freeing memory. (Pre: %lu, post: %lu)", free, free2); diff --git a/cuda/3d/mem3d.h b/cuda/3d/mem3d.h index 619354b..12a532d 100644 --- a/cuda/3d/mem3d.h +++ b/cuda/3d/mem3d.h @@ -77,7 +77,6 @@ enum Mem3DZeroMode { INIT_ZERO }; -size_t availableGPUMemory(); int maxBlockDimension(); _AstraExport MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch); |