diff options
Diffstat (limited to 'cuda')
-rw-r--r-- | cuda/2d/astra.cu | 11 | ||||
-rw-r--r-- | cuda/2d/astra.h | 2 | ||||
-rw-r--r-- | cuda/3d/mem3d.cu | 19 | ||||
-rw-r--r-- | cuda/3d/mem3d.h | 1 |
4 files changed, 19 insertions, 14 deletions
diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu index 81459de..69a4e86 100644 --- a/cuda/2d/astra.cu +++ b/cuda/2d/astra.cu @@ -529,5 +529,16 @@ _AstraExport bool setGPUIndex(int iGPUIndex) return true; } +_AstraExport size_t availableGPUMemory() +{ + size_t free, total; + cudaError_t err = cudaMemGetInfo(&free, &total); + if (err != cudaSuccess) + return 0; + return free; +} + + + } diff --git a/cuda/2d/astra.h b/cuda/2d/astra.h index 9355cb4..119d172 100644 --- a/cuda/2d/astra.h +++ b/cuda/2d/astra.h @@ -121,5 +121,7 @@ _AstraExport std::string getCudaDeviceString(int device); _AstraExport bool setGPUIndex(int index); +_AstraExport size_t availableGPUMemory(); + } #endif 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); |