summaryrefslogtreecommitdiffstats
path: root/matlab
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <WillemJan.Palenstijn@uantwerpen.be>2014-04-02 14:21:59 +0000
committerwpalenst <WillemJan.Palenstijn@uantwerpen.be>2014-04-02 14:21:59 +0000
commit2895e27613dab0815e9f0f2f0ed7853d31f856b4 (patch)
tree851d7171e07aa6db322cbf9286107b3db20f6a4e /matlab
parent1d1e084d501883784eab283c622cb28510f36d27 (diff)
downloadastra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.tar.gz
astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.tar.bz2
astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.tar.xz
astra-2895e27613dab0815e9f0f2f0ed7853d31f856b4.zip
Add global astra_set_gpu_index function
Diffstat (limited to 'matlab')
-rw-r--r--matlab/mex/astra_mex_c.cpp20
-rw-r--r--matlab/tools/astra_set_gpu_index.m18
2 files changed, 38 insertions, 0 deletions
diff --git a/matlab/mex/astra_mex_c.cpp b/matlab/mex/astra_mex_c.cpp
index 0068664..816f1f3 100644
--- a/matlab/mex/astra_mex_c.cpp
+++ b/matlab/mex/astra_mex_c.cpp
@@ -36,6 +36,8 @@ $Id$
#include "astra/Globals.h"
+#include "../cuda/2d/darthelper.h"
+
using namespace std;
using namespace astra;
@@ -72,6 +74,22 @@ void astra_mex_use_cuda(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs
}
//-----------------------------------------------------------------------------------------
+/** set_gpu_index = astra_mex('set_gpu_index');
+ *
+ * Set active GPU
+ */
+void astra_mex_set_gpu_index(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+#ifdef ASTRA_CUDA
+ if (nrhs >= 2) {
+ bool ret = astraCUDA::setGPUIndex((int)mxGetScalar(prhs[1]));
+ if (!ret)
+ mexPrintf("Failed to set GPU %d\n", (int)mxGetScalar(prhs[1]));
+ }
+#endif
+}
+
+//-----------------------------------------------------------------------------------------
/** version_number = astra_mex('version');
*
* Fetch the version number of the toolbox.
@@ -117,6 +135,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
astra_mex_use_cuda(nlhs, plhs, nrhs, prhs);
} else if (sMode == std::string("credits")) {
astra_mex_credits(nlhs, plhs, nrhs, prhs);
+ } else if (sMode == std::string("set_gpu_index")) {
+ astra_mex_set_gpu_index(nlhs, plhs, nrhs, prhs);
} else {
printHelp();
}
diff --git a/matlab/tools/astra_set_gpu_index.m b/matlab/tools/astra_set_gpu_index.m
new file mode 100644
index 0000000..192ba00
--- /dev/null
+++ b/matlab/tools/astra_set_gpu_index.m
@@ -0,0 +1,18 @@
+function astra_set_gpu_index(index)
+
+%--------------------------------------------------------------------------
+% Set the index of the GPU to use
+%--------------------------------------------------------------------------
+%------------------------------------------------------------------------
+% This file is part of the
+% All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA-Toolbox")
+%
+% Copyright: iMinds-Vision Lab, University of Antwerp
+% License: Open Source under GPLv3
+% Contact: mailto:astra@ua.ac.be
+% Website: http://astra.ua.ac.be
+%------------------------------------------------------------------------
+% $Id$
+
+astra_mex('set_gpu_index', index);
+