From 0ad6cb01b9176e99c3e4bb5643ac6a5dd477aad6 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 9 Nov 2017 20:57:31 +0100 Subject: Check for CUDA support at run-time in use_cuda() --- src/CompositeGeometryManager.cpp | 3 ++- src/Globals.cpp | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/CompositeGeometryManager.cpp b/src/CompositeGeometryManager.cpp index 8af430c..cfc2db3 100644 --- a/src/CompositeGeometryManager.cpp +++ b/src/CompositeGeometryManager.cpp @@ -43,6 +43,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/Float32VolumeData3DGPU.h" #include "astra/Logging.h" +#include "../cuda/2d/astra.h" #include "../cuda/3d/mem3d.h" #include @@ -1653,7 +1654,7 @@ bool CCompositeGeometryManager::doJobs(TJobList &jobs) // Get memory from first GPU. Not optimal... if (!m_GPUIndices.empty()) astraCUDA3d::setGPUIndex(m_GPUIndices[0]); - maxSize = astraCUDA3d::availableGPUMemory(); + maxSize = astraCUDA::availableGPUMemory(); if (maxSize == 0) { ASTRA_WARN("Unable to get available GPU memory. Defaulting to 1GB."); maxSize = 1024 * 1024 * 1024; diff --git a/src/Globals.cpp b/src/Globals.cpp index 0edb397..bbe0c2f 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -26,9 +26,19 @@ along with the ASTRA Toolbox. If not, see . */ #include "astra/Globals.h" +#include "cuda/2d/astra.h" + +namespace astra { + +bool running_in_matlab=false; + +_AstraExport bool cudaAvailable() { +#ifdef ASTRA_CUDA + return astraCUDA::availableGPUMemory() > 0; +#else + return false; +#endif +} -namespace astra{ - bool running_in_matlab=false; } -// nothing to see here :) -- cgit v1.2.3