summaryrefslogtreecommitdiffstats
path: root/matlab
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-10-17 17:39:11 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-10-17 17:39:11 +0200
commit207e8f099f8004de82ee02fff235e85638ca2223 (patch)
tree1fb8982fec86d19ae5a3e322d6eb55801e27f2af /matlab
parent17ebcfefa7c42cff61a81bf12a915983b330ed15 (diff)
downloadastra-207e8f099f8004de82ee02fff235e85638ca2223.tar.gz
astra-207e8f099f8004de82ee02fff235e85638ca2223.tar.bz2
astra-207e8f099f8004de82ee02fff235e85638ca2223.tar.xz
astra-207e8f099f8004de82ee02fff235e85638ca2223.zip
Add astra_get_gpu_info utility function
Diffstat (limited to 'matlab')
-rw-r--r--matlab/mex/astra_mex_c.cpp19
-rw-r--r--matlab/tools/astra_get_gpu_info.m20
2 files changed, 39 insertions, 0 deletions
diff --git a/matlab/mex/astra_mex_c.cpp b/matlab/mex/astra_mex_c.cpp
index d9ff8f3..c16059f 100644
--- a/matlab/mex/astra_mex_c.cpp
+++ b/matlab/mex/astra_mex_c.cpp
@@ -39,6 +39,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#ifdef ASTRA_CUDA
#include "../cuda/2d/darthelper.h"
+#include "../cuda/2d/util.h"
#include "astra/CompositeGeometryManager.h"
#endif
@@ -131,6 +132,22 @@ void astra_mex_set_gpu_index(int nlhs, mxArray* plhs[], int nrhs, const mxArray*
#endif
}
+/** get_gpu_info = astra_mex('get_gpu_info');
+ *
+ * Get GPU info
+ */
+void astra_mex_get_gpu_info(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+#ifdef ASTRA_CUDA
+ int device = -1;
+ if (nrhs >= 2 && mxIsDouble(prhs[1]) && mxGetN(prhs[1]) * mxGetM(prhs[1]) == 1 ) {
+ device = (int)mxGetScalar(prhs[1]);
+ }
+ mexPrintf("%s\n", astraCUDA::getCudaDeviceString(device).c_str());
+#endif
+}
+
+
//-----------------------------------------------------------------------------------------
/** version_number = astra_mex('version');
*
@@ -222,6 +239,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
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 if (sMode == std::string("get_gpu_info")) {
+ astra_mex_get_gpu_info(nlhs, plhs, nrhs, prhs);
} else if (sMode == std::string("info")) {
astra_mex_info(nlhs, plhs, nrhs, prhs);
} else if (sMode == std::string("delete")) {
diff --git a/matlab/tools/astra_get_gpu_info.m b/matlab/tools/astra_get_gpu_info.m
new file mode 100644
index 0000000..c220371
--- /dev/null
+++ b/matlab/tools/astra_get_gpu_info.m
@@ -0,0 +1,20 @@
+function astra_set_gpu_index(index)
+
+%--------------------------------------------------------------------------
+% Set the index of the GPU to use
+%--------------------------------------------------------------------------
+%--------------------------------------------------------------------------
+% This file is part of the ASTRA Toolbox
+%
+% Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp
+% 2014-2016, CWI, Amsterdam
+% License: Open Source under GPLv3
+% Contact: astra@uantwerpen.be
+% Website: http://www.astra-toolbox.com/
+%--------------------------------------------------------------------------
+
+if nargin < 1
+ astra_mex('get_gpu_info');
+else
+ astra_mex('get_gpu_info', index);
+end