From 6ee36e978b73c99f4543278662e9da914357378e Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 16 Oct 2017 19:07:45 +0200 Subject: Fix Windows/Python build --- cuda/3d/mem3d.cu | 2 +- cuda/3d/mem3d.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cuda/3d/mem3d.cu b/cuda/3d/mem3d.cu index ed779fa..2369149 100644 --- a/cuda/3d/mem3d.cu +++ b/cuda/3d/mem3d.cu @@ -326,7 +326,7 @@ bool FDK(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, co } -MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch) +_AstraExport MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch) { cudaPitchedPtr ptr; ptr.ptr = D_ptr; diff --git a/cuda/3d/mem3d.h b/cuda/3d/mem3d.h index 7a87ae6..619354b 100644 --- a/cuda/3d/mem3d.h +++ b/cuda/3d/mem3d.h @@ -80,7 +80,7 @@ enum Mem3DZeroMode { size_t availableGPUMemory(); int maxBlockDimension(); -MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch); +_AstraExport MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch); MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Mem3DZeroMode zero); -- cgit v1.2.3 From 12277bc90d2140905d64ba339b52b2259f2e6326 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 16 Oct 2017 21:53:31 +0200 Subject: Update miniconda release for linux conda builds --- python/conda/linux_release/buildenv/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/conda/linux_release/buildenv/Dockerfile b/python/conda/linux_release/buildenv/Dockerfile index c73e4b9..ce0b63b 100644 --- a/python/conda/linux_release/buildenv/Dockerfile +++ b/python/conda/linux_release/buildenv/Dockerfile @@ -3,11 +3,11 @@ ENV PATH /root/miniconda3/bin:$PATH ENV DEBIAN_FRONTEND noninteractive # http://developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_64.run ADD cuda_5.5.22_linux_64.run /root/ -# https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh -ADD Miniconda3-4.2.12-Linux-x86_64.sh /root/ +# https://repo.continuum.io/miniconda/Miniconda3-4.3.27.1-Linux-x86_64.sh +ADD Miniconda3-4.3.27.1-Linux-x86_64.sh /root/ RUN apt-get update RUN apt-get install -y perl-modules build-essential autoconf libtool automake libboost-dev git -RUN /bin/bash /root/Miniconda3-4.2.12-Linux-x86_64.sh -b +RUN /bin/bash /root/Miniconda3-4.3.27.1-Linux-x86_64.sh -b RUN /bin/bash /root/cuda_5.5.22_linux_64.run -toolkit -silent RUN conda install -y conda-build ENV CUDA_ROOT /usr/local/cuda -- cgit v1.2.3 From c0cfd8f5d9a8f53246fc4120345687b32e4a23cf Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 16 Oct 2017 22:33:58 +0200 Subject: Update miniconda release for linux conda builds --- python/conda/linux_release/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/conda/linux_release/release.sh b/python/conda/linux_release/release.sh index cf62bd5..089cc7c 100644 --- a/python/conda/linux_release/release.sh +++ b/python/conda/linux_release/release.sh @@ -3,7 +3,7 @@ D=`mktemp -d` [ -f buildenv/cuda_5.5.22_linux_64.run ] || (cd buildenv; wget http://developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_64.run ) -[ -f buildenv/Miniconda3-4.2.12-Linux-x86_64.sh ] || (cd buildenv; wget https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh ) +[ -f buildenv/Miniconda3-4.3.27.1-Linux-x86_64.sh ] || (cd buildenv; wget https://repo.continuum.io/miniconda/Miniconda3-4.3.27.1-Linux-x86_64.sh ) docker build -t astra-build-env buildenv #docker build --no-cache --build-arg=BUILD_NUMBER=0 -t astra-builder builder -- cgit v1.2.3 From cce8c565f2f56c575870ef922b6d28b5f99ca8c8 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 16 Oct 2017 23:15:46 +0200 Subject: Fix outdated function call in matlab DART algorithm. (Thanks @NathanaelSix) --- matlab/algorithms/DART/StatisticsDefault.m | 2 +- matlab/algorithms/DART/tools/DARToptimizerBoneStudy.m | 2 +- matlab/algorithms/DART/tools/ProjDiffOptimFunc.m | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/matlab/algorithms/DART/StatisticsDefault.m b/matlab/algorithms/DART/StatisticsDefault.m index 02e877b..84275d9 100644 --- a/matlab/algorithms/DART/StatisticsDefault.m +++ b/matlab/algorithms/DART/StatisticsDefault.m @@ -42,7 +42,7 @@ classdef StatisticsDefault < matlab.mixin.Copyable % projection difference if strcmp(this.proj_diff, 'yes') - new_sino = DART.tomography.createForwardProjection(DART, DART.S); + new_sino = DART.tomography.project(DART.S); stats.proj_diff = sum((new_sino(:) - DART.base.sinogram(:)) .^2 ) ./ (sum(DART.base.sinogram(:)) ); stats.proj_diff_hist(DART.iterationcount) = stats.proj_diff; end diff --git a/matlab/algorithms/DART/tools/DARToptimizerBoneStudy.m b/matlab/algorithms/DART/tools/DARToptimizerBoneStudy.m index c641f87..f488cd6 100644 --- a/matlab/algorithms/DART/tools/DARToptimizerBoneStudy.m +++ b/matlab/algorithms/DART/tools/DARToptimizerBoneStudy.m @@ -97,7 +97,7 @@ function rmse = optim_func(values, D_base, params, Optim) % compute rmse ROI = load('roi.mat'); [rmse, f_250, f_100, w_250, w_125] = compute_rmse(D.S, ROI); - %projection = D.tomography.createForwardProjection(D, D.S); + %projection = D.tomography.project(D.S); %proj_diff = sum((projection(:) - D.base.sinogram(:)).^2); % save diff --git a/matlab/algorithms/DART/tools/ProjDiffOptimFunc.m b/matlab/algorithms/DART/tools/ProjDiffOptimFunc.m index 72b328f..64d71fd 100644 --- a/matlab/algorithms/DART/tools/ProjDiffOptimFunc.m +++ b/matlab/algorithms/DART/tools/ProjDiffOptimFunc.m @@ -19,7 +19,7 @@ classdef ProjDiffOptimFunc < handle methods (Access=public) function proj_diff = calculate(~, D, ~) - projection = D.tomography.createForwardProjection(D, D.S); + projection = D.tomography.project(D.S); proj_diff = sum((projection(:) - D.base.sinogram(:)).^2); end -- cgit v1.2.3 From e92587a8ff2c012cabdcef833038bc350c4947b5 Mon Sep 17 00:00:00 2001 From: Bernhard Froehler Date: Mon, 15 May 2017 09:06:58 +0200 Subject: README: boost lib path correction --- README.md | 2 +- README.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8af69a7..5211e69 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ Requirements: Visual Studio 2015 (full or community), boost (recent), CUDA 8.0, Using the Visual Studio IDE: Set the environment variable MATLAB_ROOT to your matlab install location. -Copy boost headers to lib\include\boost, and boost libraries to bin\x64. +Copy boost headers to lib\include\boost, and boost libraries to lib\x64. Open astra_vc14.sln in Visual Studio. Select the appropriate solution configuration (typically Release_CUDA|x64). Build the solution. diff --git a/README.txt b/README.txt index 6d84ea0..94da3d4 100644 --- a/README.txt +++ b/README.txt @@ -134,7 +134,7 @@ Requirements: Visual Studio 2015 (full or community), boost (recent), CUDA 8.0, Using the Visual Studio IDE: Set the environment variable MATLAB_ROOT to your matlab install location. -Copy boost headers to lib\include\boost, and boost libraries to bin\x64. +Copy boost headers to lib\include\boost, and boost libraries to lib\x64. Open astra_vc14.sln in Visual Studio. Select the appropriate solution configuration (typically Release_CUDA|x64). Build the solution. -- cgit v1.2.3 From a02ee2a02aead0c69acfd15693fd12d0d5efd52f Mon Sep 17 00:00:00 2001 From: Allard Hendriksen Date: Wed, 11 Oct 2017 16:41:31 +0200 Subject: Improve python create_vol_geom Remove redundant window computations. Also fixes the problem where >> astra.create_vol_geom(10,10,10) would not set the window options while all other parameter configurations of create_vol_geom did set the window options. Respects custom arguments for the window. --- python/astra/creators.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/python/astra/creators.py b/python/astra/creators.py index 53d98e0..1e4d937 100644 --- a/python/astra/creators.py +++ b/python/astra/creators.py @@ -81,37 +81,19 @@ This method can be called in a number of ways: if len(varargin) == 1 and isinstance(varargin[0], int) == 1: vol_geom['GridRowCount'] = varargin[0] vol_geom['GridColCount'] = varargin[0] - vol_geom['option']['WindowMinX'] = -varargin[0] / 2. - vol_geom['option']['WindowMaxX'] = varargin[0] / 2. - vol_geom['option']['WindowMinY'] = -varargin[0] / 2. - vol_geom['option']['WindowMaxY'] = varargin[0] / 2. # astra_create_vol_geom([row_count col_count]) elif len(varargin) == 1 and len(varargin[0]) == 2: vol_geom['GridRowCount'] = varargin[0][0] vol_geom['GridColCount'] = varargin[0][1] - vol_geom['option']['WindowMinX'] = -varargin[0][1] / 2. - vol_geom['option']['WindowMaxX'] = varargin[0][1] / 2. - vol_geom['option']['WindowMinY'] = -varargin[0][0] / 2. - vol_geom['option']['WindowMaxY'] = varargin[0][0] / 2. # astra_create_vol_geom([row_count col_count slice_count]) elif len(varargin) == 1 and len(varargin[0]) == 3: vol_geom['GridRowCount'] = varargin[0][0] vol_geom['GridColCount'] = varargin[0][1] vol_geom['GridSliceCount'] = varargin[0][2] - vol_geom['option']['WindowMinX'] = -varargin[0][1] / 2. - vol_geom['option']['WindowMaxX'] = varargin[0][1] / 2. - vol_geom['option']['WindowMinY'] = -varargin[0][0] / 2. - vol_geom['option']['WindowMaxY'] = varargin[0][0] / 2. - vol_geom['option']['WindowMinZ'] = -varargin[0][2] / 2. - vol_geom['option']['WindowMaxZ'] = varargin[0][2] / 2. # astra_create_vol_geom(row_count, col_count) elif len(varargin) == 2: vol_geom['GridRowCount'] = varargin[0] vol_geom['GridColCount'] = varargin[1] - vol_geom['option']['WindowMinX'] = -varargin[1] / 2. - vol_geom['option']['WindowMaxX'] = varargin[1] / 2. - vol_geom['option']['WindowMinY'] = -varargin[0] / 2. - vol_geom['option']['WindowMaxY'] = varargin[0] / 2. # astra_create_vol_geom(row_count, col_count, min_x, max_x, min_y, max_y) elif len(varargin) == 6: vol_geom['GridRowCount'] = varargin[0] @@ -136,6 +118,17 @@ This method can be called in a number of ways: vol_geom['option']['WindowMaxY'] = varargin[6] vol_geom['option']['WindowMinZ'] = varargin[7] vol_geom['option']['WindowMaxZ'] = varargin[8] + + # set the window options, if not set already. + if not 'WindowMinX' in vol_geom['option']: + vol_geom['option']['WindowMinX'] = -vol_geom['GridColCount'] / 2. + vol_geom['option']['WindowMaxX'] = vol_geom['GridColCount'] / 2. + vol_geom['option']['WindowMinY'] = -vol_geom['GridRowCount'] / 2. + vol_geom['option']['WindowMaxY'] = vol_geom['GridRowCount'] / 2. + if 'GridSliceCount' in vol_geom: + vol_geom['option']['WindowMinZ'] = -vol_geom['GridSliceCount'] / 2. + vol_geom['option']['WindowMaxZ'] = vol_geom['GridSliceCount'] / 2. + return vol_geom -- cgit v1.2.3 From b3a80d71aa9a80223729b8cb47a55297f985faaf Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 10:41:55 +0200 Subject: Improve matlab create_vol_geom --- matlab/tools/astra_create_vol_geom.m | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/matlab/tools/astra_create_vol_geom.m b/matlab/tools/astra_create_vol_geom.m index bf24609..24fa957 100644 --- a/matlab/tools/astra_create_vol_geom.m +++ b/matlab/tools/astra_create_vol_geom.m @@ -38,21 +38,12 @@ if numel(varargin) == 1 && numel(varargin{1}) == 1 vol_geom = struct(); vol_geom.GridRowCount = varargin{1}(1); vol_geom.GridColCount = varargin{1}(1); - vol_geom.option.WindowMinX = -varargin{1}(1) / 2; - vol_geom.option.WindowMaxX = varargin{1}(1) / 2; - vol_geom.option.WindowMinY = -varargin{1}(1) / 2; - vol_geom.option.WindowMaxY = varargin{1}(1) / 2; - % astra_create_vol_geom([row_count col_count]) elseif numel(varargin) == 1 && numel(varargin{1}) == 2 vol_geom = struct(); vol_geom.GridRowCount = varargin{1}(1); vol_geom.GridColCount = varargin{1}(2); - vol_geom.option.WindowMinX = -varargin{1}(2) / 2; - vol_geom.option.WindowMaxX = varargin{1}(2) / 2; - vol_geom.option.WindowMinY = -varargin{1}(1) / 2; - vol_geom.option.WindowMaxY = varargin{1}(1) / 2; % astra_create_vol_geom([row_count col_count slice_count]) elseif numel(varargin) == 1 && numel(varargin{1}) == 3 @@ -60,22 +51,12 @@ elseif numel(varargin) == 1 && numel(varargin{1}) == 3 vol_geom.GridRowCount = varargin{1}(1); vol_geom.GridColCount = varargin{1}(2); vol_geom.GridSliceCount = varargin{1}(3); - vol_geom.option.WindowMinX = -varargin{1}(2) / 2; - vol_geom.option.WindowMaxX = varargin{1}(2) / 2; - vol_geom.option.WindowMinY = -varargin{1}(1) / 2; - vol_geom.option.WindowMaxY = varargin{1}(1) / 2; - vol_geom.option.WindowMinZ = -varargin{1}(3) / 2; - vol_geom.option.WindowMaxZ = varargin{1}(3) / 2; % astra_create_vol_geom(row_count, col_count) elseif numel(varargin) == 2 vol_geom = struct(); vol_geom.GridRowCount = varargin{1}; vol_geom.GridColCount = varargin{2}; - vol_geom.option.WindowMinX = -varargin{2} / 2; - vol_geom.option.WindowMaxX = varargin{2} / 2; - vol_geom.option.WindowMinY = -varargin{1} / 2; - vol_geom.option.WindowMaxY = varargin{1} / 2; % astra_create_vol_geom(row_count, col_count, min_x, max_x, min_y, max_y) elseif numel(varargin) == 6 @@ -108,3 +89,15 @@ elseif numel(varargin) == 9 vol_geom.option.WindowMaxZ = varargin{9}; end + +% set the window options, if not set already. +if ~isfield(vol_geom, 'option') || ~isfield(vol_geom.option, 'WindowMinX') + vol_geom.option.WindowMinX = -vol_geom.GridColCount / 2; + vol_geom.option.WindowMaxX = vol_geom.GridColCount / 2; + vol_geom.option.WindowMinY = -vol_geom.GridRowCount / 2; + vol_geom.option.WindowMaxY = vol_geom.GridRowCount / 2; + if isfield(vol_geom, 'GridSliceCount') + vol_geom.option.WindowMinZ = -vol_geom.GridSliceCount / 2; + vol_geom.option.WindowMaxZ = vol_geom.GridSliceCount / 2; + end +end -- cgit v1.2.3 From 17ebcfefa7c42cff61a81bf12a915983b330ed15 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 17:20:40 +0200 Subject: Add astra.astra.get_gpu_info utility function --- cuda/2d/util.cu | 24 ++++++++++++++++++++++++ cuda/2d/util.h | 4 ++++ python/astra/astra.py | 10 ++++++++++ python/astra/astra_c.pyx | 9 +++++++++ 4 files changed, 47 insertions(+) diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu index 09d1a2b..9c1bb28 100644 --- a/cuda/2d/util.cu +++ b/cuda/2d/util.cu @@ -274,5 +274,29 @@ void reportCudaError(cudaError_t err) } +_AstraExport std::string getCudaDeviceString(int device) +{ + char buf[1024]; + cudaError_t err; + if (device == -1) { + err = cudaGetDevice(&device); + if (err != cudaSuccess) { + return "Error getting current GPU index"; + } + } + + cudaDeviceProp prop; + err = cudaGetDeviceProperties(&prop, device); + if (err != cudaSuccess) { + snprintf(buf, 1024, "GPU #%d: Invalid device (%d): %s", device, err, cudaGetErrorString(err)); + return buf; + } + + long mem = prop.totalGlobalMem / (1024*1024); + snprintf(buf, 1024, "GPU #%d: %s, with %ldMB", device, prop.name, mem); + return buf; +} + + } diff --git a/cuda/2d/util.h b/cuda/2d/util.h index 875aae3..31fcfbd 100644 --- a/cuda/2d/util.h +++ b/cuda/2d/util.h @@ -30,6 +30,7 @@ along with the ASTRA Toolbox. If not, see . #include #include +#include #ifdef _MSC_VER @@ -92,6 +93,9 @@ void reportCudaError(cudaError_t err); float dotProduct2D(float* D_data, unsigned int pitch, unsigned int width, unsigned int height); +// Return string with CUDA device number, name and memory size. +// Use device == -1 to get info for the current device. +_AstraExport std::string getCudaDeviceString(int device); } diff --git a/python/astra/astra.py b/python/astra/astra.py index 3804d51..434ccb9 100644 --- a/python/astra/astra.py +++ b/python/astra/astra.py @@ -45,6 +45,16 @@ def set_gpu_index(idx, memory=0): """ a.set_gpu_index(idx, memory) +def get_gpu_info(idx=-1): + """Get GPU info. + + :param idx: GPU index, or -1 for current device + :type idx: :class:`int` + :returns: :class:`str` -- GPU info + """ + return a.get_gpu_info(idx) + + def delete(ids): """Delete an astra object. diff --git a/python/astra/astra_c.pyx b/python/astra/astra_c.pyx index 6de10da..f39b0a1 100644 --- a/python/astra/astra_c.pyx +++ b/python/astra/astra_c.pyx @@ -42,9 +42,14 @@ cdef extern from "astra/Globals.h" namespace "astra": IF HAVE_CUDA==True: cdef extern from "../cuda/2d/darthelper.h" namespace "astraCUDA": bool setGPUIndex(int) + cdef extern from "../cuda/2d/util.h" namespace "astraCUDA": + string getCudaDeviceString(int) ELSE: def setGPUIndex(): pass + def getCudaDeviceString(idx): + pass + cdef extern from "astra/CompositeGeometryManager.h" namespace "astra": cdef cppclass SGPUParams: vector[int] GPUIndices @@ -85,9 +90,13 @@ IF HAVE_CUDA==True: ret = setGPUIndex(params.GPUIndices[0]) if not ret: six.print_("Failed to set GPU " + str(params.GPUIndices[0])) + def get_gpu_info(idx=-1): + return wrap_from_bytes(getCudaDeviceString(idx)) ELSE: def set_gpu_index(idx, memory=0): raise NotImplementedError("CUDA support is not enabled in ASTRA") + def get_gpu_info(idx=-1): + raise NotImplementedError("CUDA support is not enabled in ASTRA") def delete(ids): import collections -- cgit v1.2.3 From 207e8f099f8004de82ee02fff235e85638ca2223 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 17:39:11 +0200 Subject: Add astra_get_gpu_info utility function --- matlab/mex/astra_mex_c.cpp | 19 +++++++++++++++++++ matlab/tools/astra_get_gpu_info.m | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 matlab/tools/astra_get_gpu_info.m 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 . #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 -- cgit v1.2.3 From 7b25c857ded357c0cb0b481dac6404c27ed0293d Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 5 Jul 2017 15:15:42 +0200 Subject: Reduce stringstream creation/imbue overhead --- src/Utilities.cpp | 19 ++++++++++++++++++- src/XMLNode.cpp | 17 +++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/Utilities.cpp b/src/Utilities.cpp index eb06d8b..eb34092 100644 --- a/src/Utilities.cpp +++ b/src/Utilities.cpp @@ -73,7 +73,24 @@ std::vector stringToFloatVector(const std::string &s) std::vector stringToDoubleVector(const std::string &s) { - return stringToVector(s); + std::vector out; + out.reserve(100); + std::istringstream iss; + iss.imbue(std::locale::classic()); + size_t current = 0; + size_t next; + do { + next = s.find_first_of(",;", current); + std::string t = s.substr(current, next - current); + iss.str(t); + iss.clear(); + double f; + iss >> f; + out.push_back(f); + current = next + 1; + } while (next != std::string::npos); + + return out; } template diff --git a/src/XMLNode.cpp b/src/XMLNode.cpp index 3b7237f..0ddc511 100644 --- a/src/XMLNode.cpp +++ b/src/XMLNode.cpp @@ -30,6 +30,9 @@ along with the ASTRA Toolbox. If not, see . #include "rapidxml/rapidxml.hpp" #include "rapidxml/rapidxml_print.hpp" +#include +#include + using namespace rapidxml; using namespace astra; @@ -399,8 +402,6 @@ void XMLNode::setContent(double* pfList, int _iSize) template static std::string setContentMatrix_internal(T* _pfMatrix, int _iWidth, int _iHeight, bool transposed) { - std::string str = ""; - int s1,s2; if (!transposed) { @@ -411,17 +412,21 @@ static std::string setContentMatrix_internal(T* _pfMatrix, int _iWidth, int _iHe s2 = 1; } + std::ostringstream s; + s.imbue(std::locale::classic()); + s << std::setprecision(17); + for (int y = 0; y < _iHeight; ++y) { if (_iWidth > 0) - str += StringUtil::toString(_pfMatrix[0*s1 + y*s2]); + s << _pfMatrix[0*s1 + y*s2]; for (int x = 1; x < _iWidth; x++) - str += "," + StringUtil::toString(_pfMatrix[x*s1 + y*s2]); + s << "," << _pfMatrix[x*s1 + y*s2]; if (y != _iHeight-1) - str += ";"; + s << ";"; } - return str; + return s.str(); } void XMLNode::setContent(float32* _pfMatrix, int _iWidth, int _iHeight, bool transposed) -- cgit v1.2.3 From 8d8a3d26372d9c0a784e181121fc2b360f6fee51 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 31 Aug 2017 16:47:29 +0200 Subject: Add trailing ,/; to string repr of float vector/matrix This makes it possible to differentiate between a scalar and a one-element vector, and fixes #111. --- python/astra/utils.pyx | 2 ++ src/Utilities.cpp | 9 ++++++--- src/XMLNode.cpp | 9 ++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/python/astra/utils.pyx b/python/astra/utils.pyx index a40916b..bcff6c3 100644 --- a/python/astra/utils.pyx +++ b/python/astra/utils.pyx @@ -171,6 +171,7 @@ def stringToPythonValue(inputIn): input = castString(inputIn) # matrix if ';' in input: + input = input.rstrip(';') row_strings = input.split(';') col_strings = row_strings[0].split(',') nRows = len(row_strings) @@ -185,6 +186,7 @@ def stringToPythonValue(inputIn): # vector if ',' in input: + input = input.rstrip(',') items = input.split(',') out = np.empty(len(items)) for idx,item in enumerate(items): diff --git a/src/Utilities.cpp b/src/Utilities.cpp index eb34092..c90e67b 100644 --- a/src/Utilities.cpp +++ b/src/Utilities.cpp @@ -77,6 +77,7 @@ std::vector stringToDoubleVector(const std::string &s) out.reserve(100); std::istringstream iss; iss.imbue(std::locale::classic()); + size_t length = s.size(); size_t current = 0; size_t next; do { @@ -88,7 +89,7 @@ std::vector stringToDoubleVector(const std::string &s) iss >> f; out.push_back(f); current = next + 1; - } while (next != std::string::npos); + } while (next != std::string::npos && current != length); return out; } @@ -97,6 +98,7 @@ template std::vector stringToVector(const std::string& s) { std::vector out; + size_t length = s.size(); size_t current = 0; size_t next; do { @@ -104,7 +106,7 @@ std::vector stringToVector(const std::string& s) std::string t = s.substr(current, next - current); out.push_back(stringTo(t)); current = next + 1; - } while (next != std::string::npos); + } while (next != std::string::npos && current != length); return out; } @@ -134,13 +136,14 @@ void splitString(std::vector &items, const std::string& s, const char *delim) { items.clear(); + size_t length = s.size(); size_t current = 0; size_t next; do { next = s.find_first_of(delim, current); items.push_back(s.substr(current, next - current)); current = next + 1; - } while (next != std::string::npos); + } while (next != std::string::npos && current != length); } } diff --git a/src/XMLNode.cpp b/src/XMLNode.cpp index 0ddc511..2bf1330 100644 --- a/src/XMLNode.cpp +++ b/src/XMLNode.cpp @@ -379,9 +379,9 @@ void XMLNode::setContent(float32 _fValue) template static std::string setContentList_internal(T* pfList, int _iSize) { - std::string str = (_iSize > 0) ? StringUtil::toString(pfList[0]) : ""; - for (int i = 1; i < _iSize; i++) { - str += "," + StringUtil::toString(pfList[i]); + std::string str; + for (int i = 0; i < _iSize; i++) { + str += StringUtil::toString(pfList[i]) + ","; } return str; } @@ -422,8 +422,7 @@ static std::string setContentMatrix_internal(T* _pfMatrix, int _iWidth, int _iHe for (int x = 1; x < _iWidth; x++) s << "," << _pfMatrix[x*s1 + y*s2]; - if (y != _iHeight-1) - s << ";"; + s << ";"; } return s.str(); -- cgit v1.2.3 From 08fbd5bb090eba2d207eceb520351eabcfc389fe Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 21:23:31 +0200 Subject: Slightly increase numerical tolerance of test --- tests/test_ParallelBeamLinearKernelProjector2D.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_ParallelBeamLinearKernelProjector2D.cpp b/tests/test_ParallelBeamLinearKernelProjector2D.cpp index f1fa311..a34c82c 100644 --- a/tests/test_ParallelBeamLinearKernelProjector2D.cpp +++ b/tests/test_ParallelBeamLinearKernelProjector2D.cpp @@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE( testParallelBeamLinearKernelProjector2D_Rectangles ) pPix[i].m_iIndex / volGeom.getGridColCount(), iDet, projGeom.getProjectionAngle(0)); - BOOST_CHECK_SMALL( pPix[i].m_fWeight - fTest, 0.00037f); + BOOST_CHECK_SMALL( pPix[i].m_fWeight - fTest, 0.0004f); fW += pPix[i].m_fWeight; } -- cgit v1.2.3 From d1e2b4f904266c94f4ebf9fc5c95d495c95b0d5c Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 22:06:13 +0200 Subject: Improve stringToFloatVector to match stringToDoubleVector --- src/Utilities.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Utilities.cpp b/src/Utilities.cpp index c90e67b..2ae1b66 100644 --- a/src/Utilities.cpp +++ b/src/Utilities.cpp @@ -66,14 +66,10 @@ double stringToDouble(const std::string& s) template<> float stringTo(const std::string& s) { return stringToFloat(s); } template<> double stringTo(const std::string& s) { return stringToDouble(s); } -std::vector stringToFloatVector(const std::string &s) -{ - return stringToVector(s); -} - -std::vector stringToDoubleVector(const std::string &s) +template +std::vector stringToNumericVector(const std::string &s) { - std::vector out; + std::vector out; out.reserve(100); std::istringstream iss; iss.imbue(std::locale::classic()); @@ -85,7 +81,7 @@ std::vector stringToDoubleVector(const std::string &s) std::string t = s.substr(current, next - current); iss.str(t); iss.clear(); - double f; + T f; iss >> f; out.push_back(f); current = next + 1; @@ -94,6 +90,15 @@ std::vector stringToDoubleVector(const std::string &s) return out; } +std::vector stringToFloatVector(const std::string &s) +{ + return stringToNumericVector(s); +} +std::vector stringToDoubleVector(const std::string &s) +{ + return stringToNumericVector(s); +} + template std::vector stringToVector(const std::string& s) { -- cgit v1.2.3 From 521825da92af4d3a08609241353517b8ec7e780c Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 18 Oct 2017 23:00:25 +0200 Subject: Fix output initialization for MODE_ADD CGM jobs --- src/CompositeGeometryManager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/CompositeGeometryManager.cpp b/src/CompositeGeometryManager.cpp index a4dace2..184144c 100644 --- a/src/CompositeGeometryManager.cpp +++ b/src/CompositeGeometryManager.cpp @@ -1386,6 +1386,12 @@ static bool doJob(const CCompositeGeometryManager::TJobSet::const_iterator& iter bool ok = dstMem->allocateGPUMemory(outx, outy, outz, zero ? astraCUDA3d::INIT_ZERO : astraCUDA3d::INIT_NO); if (!ok) ASTRA_ERROR("Error allocating GPU memory"); + if (!zero) { + // instead of zeroing output memory, copy from host + ok = dstMem->copyToGPUMemory(dstdims); + if (!ok) ASTRA_ERROR("Error copying output data to GPU"); + } + for (CCompositeGeometryManager::TJobList::const_iterator i = L.begin(); i != L.end(); ++i) { const CCompositeGeometryManager::SJob &j = *i; -- cgit v1.2.3 From 71d27819b1b046109b5c70e3bd112f436e96a545 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 23 Oct 2017 12:14:28 +0200 Subject: Support 2d/3d in astra.algorithm.get_res_norm --- python/astra/PyIncludes.pxd | 4 ++++ python/astra/algorithm_c.pyx | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/python/astra/PyIncludes.pxd b/python/astra/PyIncludes.pxd index c091963..512b82f 100644 --- a/python/astra/PyIncludes.pxd +++ b/python/astra/PyIncludes.pxd @@ -152,6 +152,10 @@ cdef extern from "astra/ReconstructionAlgorithm2D.h" namespace "astra": cdef cppclass CReconstructionAlgorithm2D: bool getResidualNorm(float32&) +cdef extern from "astra/ReconstructionAlgorithm3D.h" namespace "astra": + cdef cppclass CReconstructionAlgorithm3D: + bool getResidualNorm(float32&) + cdef extern from "astra/Projector2D.h" namespace "astra": cdef cppclass CProjector2D: bool isInitialized() diff --git a/python/astra/algorithm_c.pyx b/python/astra/algorithm_c.pyx index 9ed0634..161fe98 100644 --- a/python/astra/algorithm_c.pyx +++ b/python/astra/algorithm_c.pyx @@ -44,7 +44,8 @@ from .utils import wrap_from_bytes cdef CAlgorithmManager * manAlg = PyAlgorithmManager.getSingletonPtr() cdef extern from *: - CReconstructionAlgorithm2D * dynamic_cast_recAlg "dynamic_cast" (CAlgorithm * ) except NULL + CReconstructionAlgorithm2D * dynamic_cast_recAlg2D "dynamic_cast" (CAlgorithm * ) + CReconstructionAlgorithm3D * dynamic_cast_recAlg3D "dynamic_cast" (CAlgorithm * ) def create(config): @@ -79,12 +80,18 @@ def run(i, iterations=0): def get_res_norm(i): cdef CReconstructionAlgorithm2D * pAlg2D + cdef CReconstructionAlgorithm3D * pAlg3D cdef CAlgorithm * alg = getAlg(i) cdef float32 res = 0.0 - pAlg2D = dynamic_cast_recAlg(alg) - if pAlg2D == NULL: - raise Exception("Operation not supported.") - if not pAlg2D.getResidualNorm(res): + pAlg2D = dynamic_cast_recAlg2D(alg) + pAlg3D = dynamic_cast_recAlg3D(alg) + if pAlg2D != NULL: + if not pAlg2D.getResidualNorm(res): + raise Exception("Operation not supported.") + elif pAlg3D != NULL: + if not pAlg3D.getResidualNorm(res): + raise Exception("Operation not supported.") + else: raise Exception("Operation not supported.") return res -- cgit v1.2.3 From 42b5e731a9ac6c3aa4751cee2c09758d58d18427 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 23 Oct 2017 13:57:03 +0200 Subject: Fix usage of cython except --- python/astra/experimental.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/astra/experimental.pyx b/python/astra/experimental.pyx index 0af3118..136165b 100644 --- a/python/astra/experimental.pyx +++ b/python/astra/experimental.pyx @@ -40,8 +40,8 @@ IF HAVE_CUDA==True: bool doBP(CProjector3D *, vector[CFloat32VolumeData3D *], vector[CFloat32ProjectionData3D *]) cdef extern from *: - CFloat32VolumeData3D * dynamic_cast_vol_mem "dynamic_cast" (CFloat32Data3D * ) except NULL - CFloat32ProjectionData3D * dynamic_cast_proj_mem "dynamic_cast" (CFloat32Data3D * ) except NULL + CFloat32VolumeData3D * dynamic_cast_vol_mem "dynamic_cast" (CFloat32Data3D * ) + CFloat32ProjectionData3D * dynamic_cast_proj_mem "dynamic_cast" (CFloat32Data3D * ) cdef extern from "astra/Float32ProjectionData3D.h" namespace "astra": cdef cppclass CFloat32ProjectionData3D: -- cgit v1.2.3 From 642977e9d613d673fbf46e11cb92b6785fe02cc6 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 26 Oct 2017 11:01:36 +0200 Subject: Fix usage of cython except --- python/astra/data3d_c.pyx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/python/astra/data3d_c.pyx b/python/astra/data3d_c.pyx index 78ed620..0717ca0 100644 --- a/python/astra/data3d_c.pyx +++ b/python/astra/data3d_c.pyx @@ -60,7 +60,13 @@ cdef extern from "Python.h": cdef CData3DManager * man3d = PyData3DManager.getSingletonPtr() cdef extern from *: - CFloat32Data3DMemory * dynamic_cast_mem "dynamic_cast" (CFloat32Data3D * ) except NULL + CFloat32Data3DMemory * dynamic_cast_mem "dynamic_cast" (CFloat32Data3D * ) + +cdef CFloat32Data3DMemory * dynamic_cast_mem_safe(CFloat32Data3D *obj) except NULL: + cdef CFloat32Data3DMemory *ret = dynamic_cast_mem(obj) + if not ret: + raise RuntimeError("Not a memory 3D data object") + return ret cdef extern from "CFloat32CustomPython.h": cdef cppclass CFloat32CustomPython: @@ -154,12 +160,12 @@ def create(datatype,geometry,data=None, link=False): raise RuntimeError("Couldn't initialize data object.") if not link: - fillDataObject(dynamic_cast_mem(pDataObject3D), data) + fillDataObject(dynamic_cast_mem_safe(pDataObject3D), data) return man3d.store(pDataObject3D) def get_geometry(i): - cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem(getObject(i)) + cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem_safe(getObject(i)) cdef CFloat32ProjectionData3DMemory * pDataObject2 cdef CFloat32VolumeData3DMemory * pDataObject3 if pDataObject.getType() == THREEPROJECTION: @@ -173,7 +179,7 @@ def get_geometry(i): return geom def change_geometry(i, geom): - cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem(getObject(i)) + cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem_safe(getObject(i)) cdef CFloat32ProjectionData3DMemory * pDataObject2 cdef CFloat32VolumeData3DMemory * pDataObject3 if pDataObject.getType() == THREEPROJECTION: @@ -262,7 +268,7 @@ cdef CFloat32Data3D * getObject(i) except NULL: @cython.boundscheck(False) @cython.wraparound(False) def get(i): - cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem(getObject(i)) + cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem_safe(getObject(i)) outArr = np.empty((pDataObject.getDepth(),pDataObject.getHeight(), pDataObject.getWidth()),dtype=np.float32,order='C') cdef float [:,:,::1] mView = outArr cdef float [:,:,::1] cView = pDataObject.getData3D()[0][0] @@ -270,7 +276,7 @@ def get(i): return outArr def get_shared(i): - cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem(getObject(i)) + cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem_safe(getObject(i)) outArr = np.empty((pDataObject.getDepth(),pDataObject.getHeight(), pDataObject.getWidth()),dtype=np.float32,order='C') cdef np.npy_intp shape[3] shape[0] = pDataObject.getDepth() @@ -283,7 +289,7 @@ def get_single(i): def store(i,data): cdef CFloat32Data3D * pDataObject = getObject(i) - fillDataObject(dynamic_cast_mem(pDataObject), data) + fillDataObject(dynamic_cast_mem_safe(pDataObject), data) def dimensions(i): cdef CFloat32Data3D * pDataObject = getObject(i) -- cgit v1.2.3 From d753de051893698bfd1e107a2d03b1a38b55dd91 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 31 Oct 2017 17:10:56 +0100 Subject: Remove some unnecessary includes --- cuda/2d/algo.h | 3 ++- cuda/2d/astra.h | 1 - cuda/2d/cgls.h | 1 - cuda/2d/darthelper.h | 2 +- cuda/2d/em.h | 1 - cuda/2d/sart.h | 1 - cuda/2d/sirt.h | 1 - cuda/2d/util.h | 16 +--------------- cuda/3d/cgls3d.h | 1 - cuda/3d/darthelper3d.h | 5 +---- cuda/3d/sirt3d.h | 1 - include/astra/CudaFilteredBackProjectionAlgorithm.h | 4 ---- src/CudaFilteredBackProjectionAlgorithm.cpp | 9 --------- 13 files changed, 5 insertions(+), 41 deletions(-) diff --git a/cuda/2d/algo.h b/cuda/2d/algo.h index dc3bb05..4a75907 100644 --- a/cuda/2d/algo.h +++ b/cuda/2d/algo.h @@ -28,7 +28,8 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_ALGO_H #define _CUDA_ALGO_H -#include "util.h" +#include "astra/Globals.h" +#include "dims.h" namespace astraCUDA { diff --git a/cuda/2d/astra.h b/cuda/2d/astra.h index 78d00e3..c9e0762 100644 --- a/cuda/2d/astra.h +++ b/cuda/2d/astra.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_ASTRA_H #define _CUDA_ASTRA_H -#include "fft.h" #include "fbp_filters.h" #include "dims.h" #include "algo.h" diff --git a/cuda/2d/cgls.h b/cuda/2d/cgls.h index 804f943..c45b5a4 100644 --- a/cuda/2d/cgls.h +++ b/cuda/2d/cgls.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_CGLS_H #define _CUDA_CGLS_H -#include "util.h" #include "algo.h" namespace astraCUDA { diff --git a/cuda/2d/darthelper.h b/cuda/2d/darthelper.h index a2f1f45..9a2837c 100644 --- a/cuda/2d/darthelper.h +++ b/cuda/2d/darthelper.h @@ -28,7 +28,7 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_ARITH2_H #define _CUDA_ARITH2_H -#include "util.h" +#include "astra/Globals.h" namespace astraCUDA { diff --git a/cuda/2d/em.h b/cuda/2d/em.h index f99e798..15795f7 100644 --- a/cuda/2d/em.h +++ b/cuda/2d/em.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_EM_H #define _CUDA_EM_H -#include "util.h" #include "algo.h" namespace astraCUDA { diff --git a/cuda/2d/sart.h b/cuda/2d/sart.h index ab99e66..06051ae 100644 --- a/cuda/2d/sart.h +++ b/cuda/2d/sart.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_SART_H #define _CUDA_SART_H -#include "util.h" #include "algo.h" namespace astraCUDA { diff --git a/cuda/2d/sirt.h b/cuda/2d/sirt.h index 488ab0a..7c440d5 100644 --- a/cuda/2d/sirt.h +++ b/cuda/2d/sirt.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_SIRT_H #define _CUDA_SIRT_H -#include "util.h" #include "algo.h" namespace astraCUDA { diff --git a/cuda/2d/util.h b/cuda/2d/util.h index 31fcfbd..6e36b6e 100644 --- a/cuda/2d/util.h +++ b/cuda/2d/util.h @@ -32,21 +32,7 @@ along with the ASTRA Toolbox. If not, see . #include #include -#ifdef _MSC_VER - -#ifdef DLL_EXPORTS -#define _AstraExport __declspec(dllexport) -#define EXPIMP_TEMPLATE -#else -#define _AstraExport __declspec(dllimport) -#define EXPIMP_TEMPLATE extern -#endif - -#else - -#define _AstraExport - -#endif +#include "astra/Globals.h" #include "dims.h" diff --git a/cuda/3d/cgls3d.h b/cuda/3d/cgls3d.h index e09fcfb..2ed2b1d 100644 --- a/cuda/3d/cgls3d.h +++ b/cuda/3d/cgls3d.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_CGLS3D_H #define _CUDA_CGLS3D_H -#include "util3d.h" #include "algo3d.h" namespace astraCUDA3d { diff --git a/cuda/3d/darthelper3d.h b/cuda/3d/darthelper3d.h index 71ea5b0..539fa06 100644 --- a/cuda/3d/darthelper3d.h +++ b/cuda/3d/darthelper3d.h @@ -28,10 +28,7 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_DARTHELPER3_H #define _CUDA_DARTHELPER3_H -#include -#include -#include "util3d.h" -#include "algo3d.h" +#include "dims3d.h" namespace astraCUDA3d { diff --git a/cuda/3d/sirt3d.h b/cuda/3d/sirt3d.h index 69031b8..337ca89 100644 --- a/cuda/3d/sirt3d.h +++ b/cuda/3d/sirt3d.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_SIRT3D_H #define _CUDA_SIRT3D_H -#include "util3d.h" #include "algo3d.h" namespace astraCUDA3d { diff --git a/include/astra/CudaFilteredBackProjectionAlgorithm.h b/include/astra/CudaFilteredBackProjectionAlgorithm.h index 057843e..164b51b 100644 --- a/include/astra/CudaFilteredBackProjectionAlgorithm.h +++ b/include/astra/CudaFilteredBackProjectionAlgorithm.h @@ -70,10 +70,6 @@ public: static int calcIdealRealFilterWidth(int _iDetectorCount); static int calcIdealFourierFilterWidth(int _iDetectorCount); - //debug - static void testGenFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, cufftComplex * _pFilter, int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount); - static int getGPUCount(); - /** Get a description of the class. * * @return description string diff --git a/src/CudaFilteredBackProjectionAlgorithm.cpp b/src/CudaFilteredBackProjectionAlgorithm.cpp index 7e2df79..a5d7b93 100644 --- a/src/CudaFilteredBackProjectionAlgorithm.cpp +++ b/src/CudaFilteredBackProjectionAlgorithm.cpp @@ -517,12 +517,3 @@ E_FBPFILTER CCudaFilteredBackProjectionAlgorithm::_convertStringToFilter(const c return output; } -void CCudaFilteredBackProjectionAlgorithm::testGenFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, cufftComplex * _pFilter, int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount) -{ - genFilter(_eFilter, _fD, _iProjectionCount, _pFilter, _iFFTRealDetectorCount, _iFFTFourierDetectorCount); -} - -int CCudaFilteredBackProjectionAlgorithm::getGPUCount() -{ - return 0; -} -- cgit v1.2.3 From adda34cf902c246a75eb46800949dc15d5e84f37 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 1 Nov 2017 12:27:18 +0100 Subject: Remove unused code --- build/linux/Makefile.in | 3 +- include/astra/Globals.h | 102 ------------------------------------------------ include/astra/swrap.h | 40 ------------------- src/swrap.cpp | 46 ---------------------- 4 files changed, 1 insertion(+), 190 deletions(-) delete mode 100644 include/astra/swrap.h delete mode 100644 src/swrap.cpp diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index c83e9f0..7cff15e 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -179,8 +179,7 @@ BASE_OBJECTS=\ src/VolumeGeometry2D.lo \ src/VolumeGeometry3D.lo \ src/XMLDocument.lo \ - src/XMLNode.lo \ - src/swrap.lo + src/XMLNode.lo CUDA_CXX_OBJECTS=\ src/CudaProjector2D.lo \ diff --git a/include/astra/Globals.h b/include/astra/Globals.h index 8375726..7c1e9a8 100644 --- a/include/astra/Globals.h +++ b/include/astra/Globals.h @@ -120,21 +120,6 @@ namespace astra { //} //} -//---------------------------------------------------------------------------------------- -// errors -namespace astra { - -typedef enum {ASTRA_SUCCESS, - ASTRA_ERROR_NOT_INITIALIZED, - ASTRA_ERROR_INVALID_FILE, - ASTRA_ERROR_OUT_OF_RANGE, - ASTRA_ERROR_DIMENSION_MISMATCH, - ASTRA_ERROR_EXTERNAL_LIBRARY, - ASTRA_ERROR_ALLOCATION, - ASTRA_ERROR_NOT_IMPLEMENTED} AstraError; -} - - //---------------------------------------------------------------------------------------- // variables namespace astra { @@ -147,51 +132,6 @@ namespace astra { extern _AstraExport bool running_in_matlab; } -//---------------------------------------------------------------------------------------- -// math -namespace astra { - - inline float32 cos_73s(float32 x) - { - /* - const float32 c1 = 0.999999953464f; - const float32 c2 = -0.4999999053455f; - const float32 c3 = 0.0416635846769f; - const float32 c4 = -0.0013853704264f; - const float32 c5 = 0.000023233f; - */ - const float c1= (float)0.99940307; - const float c2= (float)-0.49558072; - const float c3= (float)0.03679168; - - float32 x2; - x2 = x * x; - //return (c1 + x2*(c2 + x2*(c3 + x2*(c4 + c5*x2)))); - return (c1 + x2*(c2 + c3 * x2)); - } - - inline float32 fast_cos(float32 x) - { - int quad; - - //x = fmod(x, 2*PI); // Get rid of values > 2* pi - if (x < 0) x = -x; // cos(-x) = cos(x) - quad = int(x/PIdiv2); // Get quadrant # (0 to 3) - switch (quad) { - case 0: return cos_73s(x); - case 1: return -cos_73s(PI-x); - case 2: return -cos_73s(x-PI); - case 3: return cos_73s(2*PI-x); - } - return 0.0f; - } - - inline float32 fast_sin(float32 x){ - return fast_cos(PIdiv2-x); - } - -} - //---------------------------------------------------------------------------------------- // structs namespace astra { @@ -226,47 +166,6 @@ namespace astra { }; } -//---------------------------------------------------------------------------------------- -// functions for testing -template -inline void writeArray(T*** arr, int dim1, int dim2, int dim3, const std::string& filename) -{ - std::ofstream out(filename.c_str()); - int i1, i2, i3; - for (i1 = 0; i1 < dim1; ++i1) { - for (i2 = 0; i2 < dim2; ++i2) { - for (i3 = 0; i3 < dim3; ++i3) { - out << arr[i1][i2][i3] << " "; - } - out << std::endl; - } - out << std::endl; - } - out.close(); -} - -template -inline void writeArray(T** arr, int dim1, int dim2, const std::string& filename) -{ - std::ofstream out(filename.c_str()); - for (int i1 = 0; i1 < dim1; i1++) { - for (int i2 = 0; i2 < dim2; i2++) { - out << arr[i1][i2] << " "; - } - out << std::endl; - } - out.close(); -} - -template -inline void writeArray(T* arr, int dim1, const std::string& filename) -{ - std::ofstream out(filename.c_str()); - for (int i1 = 0; i1 < dim1; i1++) { - out << arr[i1] << " "; - } - out.close(); -} namespace astra { _AstraExport inline int getVersion() { return ASTRA_TOOLBOXVERSION; } _AstraExport inline const char* getVersionString() { return ASTRA_TOOLBOXVERSION_STRING; } @@ -280,7 +179,6 @@ _AstraExport inline bool cudaEnabled() { return false; } // portability between MSVC and Linux/gcc #ifndef _MSC_VER -#include "swrap.h" #define EXPIMP_TEMPLATE #if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) diff --git a/include/astra/swrap.h b/include/astra/swrap.h deleted file mode 100644 index cd479f3..0000000 --- a/include/astra/swrap.h +++ /dev/null @@ -1,40 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp - 2014-2016, CWI, Amsterdam - -Contact: astra@uantwerpen.be -Website: http://www.astra-toolbox.com/ - -This file is part of the ASTRA Toolbox. - - -The ASTRA Toolbox is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -The ASTRA Toolbox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the ASTRA Toolbox. If not, see . - ------------------------------------------------------------------------ -*/ - -#ifndef _INC_ASTRA_SWRAP_H -#define _INC_ASTRA_SWRAP_H - -#ifndef _MSC_VER - -#include - -typedef int errno_t; -errno_t fopen_s(FILE** pFile, const char *filename, const char *mode); - -#endif - -#endif diff --git a/src/swrap.cpp b/src/swrap.cpp deleted file mode 100644 index c970ab5..0000000 --- a/src/swrap.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp - 2014-2016, CWI, Amsterdam - -Contact: astra@uantwerpen.be -Website: http://www.astra-toolbox.com/ - -This file is part of the ASTRA Toolbox. - - -The ASTRA Toolbox is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -The ASTRA Toolbox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the ASTRA Toolbox. If not, see . - ------------------------------------------------------------------------ -*/ - -#ifndef _MSC_VER - -#include "astra/swrap.h" -#include - -errno_t fopen_s(FILE** pFile, const char* filename, const char* mode) -{ - if (!pFile) - return EINVAL; - - FILE* x = fopen(filename, mode); - if (!x) - return errno; - - *pFile = x; - return 0; -} - -#endif -- cgit v1.2.3 From f70f68fcd465f421b566b199e23e66c1f186b01d Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 1 Nov 2017 15:05:13 +0100 Subject: Separate cuda from astra headers further --- cuda/2d/astra.cu | 41 ++++++++++++++++++++++++++++++++++++++ cuda/2d/astra.h | 9 +++++++++ cuda/2d/darthelper.cu | 16 --------------- cuda/2d/darthelper.h | 2 -- cuda/2d/util.cu | 25 ----------------------- cuda/2d/util.h | 4 ---- python/astra/astra_c.pyx | 3 +-- src/CudaDartMaskAlgorithm.cpp | 1 + src/CudaDartSmoothingAlgorithm.cpp | 1 + src/CudaDataOperationAlgorithm.cpp | 1 + src/CudaRoiSelectAlgorithm.cpp | 1 + 11 files changed, 55 insertions(+), 49 deletions(-) diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu index 2ff9230..c0132b2 100644 --- a/cuda/2d/astra.cu +++ b/cuda/2d/astra.cu @@ -986,6 +986,47 @@ bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, } +} + +namespace astraCUDA { + + +_AstraExport std::string getCudaDeviceString(int device) +{ + char buf[1024]; + cudaError_t err; + if (device == -1) { + err = cudaGetDevice(&device); + if (err != cudaSuccess) { + return "Error getting current GPU index"; + } + } + + cudaDeviceProp prop; + err = cudaGetDeviceProperties(&prop, device); + if (err != cudaSuccess) { + snprintf(buf, 1024, "GPU #%d: Invalid device (%d): %s", device, err, cudaGetErrorString(err)); + return buf; + } + + long mem = prop.totalGlobalMem / (1024*1024); + snprintf(buf, 1024, "GPU #%d: %s, with %ldMB", device, prop.name, mem); + return buf; +} + +_AstraExport bool setGPUIndex(int iGPUIndex) +{ + if (iGPUIndex != -1) { + cudaSetDevice(iGPUIndex); + cudaError_t err = cudaGetLastError(); + + // Ignore errors caused by calling cudaSetDevice multiple times + if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) + return false; + } + + return true; +} } diff --git a/cuda/2d/astra.h b/cuda/2d/astra.h index c9e0762..e4cefac 100644 --- a/cuda/2d/astra.h +++ b/cuda/2d/astra.h @@ -224,6 +224,15 @@ _AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, astraCUDA::SFanProjection*& pProjs, float& outputScale); +} + +namespace astraCUDA { + +// Return string with CUDA device number, name and memory size. +// Use device == -1 to get info for the current device. +_AstraExport std::string getCudaDeviceString(int device); + +_AstraExport bool setGPUIndex(int index); } #endif diff --git a/cuda/2d/darthelper.cu b/cuda/2d/darthelper.cu index 744184e..d4b5220 100644 --- a/cuda/2d/darthelper.cu +++ b/cuda/2d/darthelper.cu @@ -356,20 +356,4 @@ void dartSmoothing(float* out, const float* in, float b, unsigned int radius, un } - -_AstraExport bool setGPUIndex(int iGPUIndex) -{ - if (iGPUIndex != -1) { - cudaSetDevice(iGPUIndex); - cudaError_t err = cudaGetLastError(); - - // Ignore errors caused by calling cudaSetDevice multiple times - if (err != cudaSuccess && err != cudaErrorSetOnActiveProcess) - return false; - } - - return true; -} - - } diff --git a/cuda/2d/darthelper.h b/cuda/2d/darthelper.h index 9a2837c..67a6a7d 100644 --- a/cuda/2d/darthelper.h +++ b/cuda/2d/darthelper.h @@ -36,8 +36,6 @@ namespace astraCUDA { void dartMask(float* out, const float* in, unsigned int conn, unsigned int radius, unsigned int threshold, unsigned int width, unsigned int height); void dartSmoothing(float* out, const float* in, float b, unsigned int radius, unsigned int width, unsigned int height); - _AstraExport bool setGPUIndex(int index); - } #endif diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu index 9c1bb28..871e139 100644 --- a/cuda/2d/util.cu +++ b/cuda/2d/util.cu @@ -274,29 +274,4 @@ void reportCudaError(cudaError_t err) } -_AstraExport std::string getCudaDeviceString(int device) -{ - char buf[1024]; - cudaError_t err; - if (device == -1) { - err = cudaGetDevice(&device); - if (err != cudaSuccess) { - return "Error getting current GPU index"; - } - } - - cudaDeviceProp prop; - err = cudaGetDeviceProperties(&prop, device); - if (err != cudaSuccess) { - snprintf(buf, 1024, "GPU #%d: Invalid device (%d): %s", device, err, cudaGetErrorString(err)); - return buf; - } - - long mem = prop.totalGlobalMem / (1024*1024); - snprintf(buf, 1024, "GPU #%d: %s, with %ldMB", device, prop.name, mem); - return buf; -} - - - } diff --git a/cuda/2d/util.h b/cuda/2d/util.h index 6e36b6e..382d862 100644 --- a/cuda/2d/util.h +++ b/cuda/2d/util.h @@ -79,10 +79,6 @@ void reportCudaError(cudaError_t err); float dotProduct2D(float* D_data, unsigned int pitch, unsigned int width, unsigned int height); -// Return string with CUDA device number, name and memory size. -// Use device == -1 to get info for the current device. -_AstraExport std::string getCudaDeviceString(int device); - } #endif diff --git a/python/astra/astra_c.pyx b/python/astra/astra_c.pyx index f39b0a1..f25fc2a 100644 --- a/python/astra/astra_c.pyx +++ b/python/astra/astra_c.pyx @@ -40,9 +40,8 @@ cdef extern from "astra/Globals.h" namespace "astra": bool cudaEnabled() IF HAVE_CUDA==True: - cdef extern from "../cuda/2d/darthelper.h" namespace "astraCUDA": + cdef extern from "../cuda/2d/astra.h" namespace "astraCUDA": bool setGPUIndex(int) - cdef extern from "../cuda/2d/util.h" namespace "astraCUDA": string getCudaDeviceString(int) ELSE: def setGPUIndex(): diff --git a/src/CudaDartMaskAlgorithm.cpp b/src/CudaDartMaskAlgorithm.cpp index 375d565..a2e1ee6 100644 --- a/src/CudaDartMaskAlgorithm.cpp +++ b/src/CudaDartMaskAlgorithm.cpp @@ -29,6 +29,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaDartMaskAlgorithm.h" +#include "../cuda/2d/astra.h" #include "../cuda/2d/darthelper.h" #include "../cuda/2d/algo.h" diff --git a/src/CudaDartSmoothingAlgorithm.cpp b/src/CudaDartSmoothingAlgorithm.cpp index 0759ea0..9e586c0 100644 --- a/src/CudaDartSmoothingAlgorithm.cpp +++ b/src/CudaDartSmoothingAlgorithm.cpp @@ -29,6 +29,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaDartSmoothingAlgorithm.h" +#include "../cuda/2d/astra.h" #include "../cuda/2d/darthelper.h" #include "../cuda/2d/algo.h" diff --git a/src/CudaDataOperationAlgorithm.cpp b/src/CudaDataOperationAlgorithm.cpp index f9466e2..6c6b27c 100644 --- a/src/CudaDataOperationAlgorithm.cpp +++ b/src/CudaDataOperationAlgorithm.cpp @@ -31,6 +31,7 @@ along with the ASTRA Toolbox. If not, see . #include "../cuda/2d/algo.h" #include "../cuda/2d/darthelper.h" +#include "../cuda/2d/astra.h" #include "../cuda/2d/arith.h" #include "astra/AstraObjectManager.h" diff --git a/src/CudaRoiSelectAlgorithm.cpp b/src/CudaRoiSelectAlgorithm.cpp index baf8a6f..2b0ba15 100644 --- a/src/CudaRoiSelectAlgorithm.cpp +++ b/src/CudaRoiSelectAlgorithm.cpp @@ -29,6 +29,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaRoiSelectAlgorithm.h" +#include "../cuda/2d/astra.h" #include "../cuda/2d/darthelper.h" #include "../cuda/2d/algo.h" -- cgit v1.2.3 From fa92fc50355d0cbc185098ef6bcf78fa9dc65623 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 21:05:06 +0200 Subject: Regroup .travis.yml sections to better match travis docs --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1cd7420..b34b1a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,8 @@ before_install: install: - conda install python=$TRAVIS_PYTHON_VERSION six numpy scipy cython - conda info -a + +script: - cd build/linux - ./autogen.sh - if [ x$CLANG == xyes ]; then export CXX=clang++; export CC=clang; fi @@ -67,6 +69,4 @@ install: - make -j 4 - make test - make install - -script: - python -c "import astra" -- cgit v1.2.3 From 355ee14464f76f7a506143ef44a9b5a5319c4951 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 21:06:50 +0200 Subject: Move set_gpu_index, get_gpu_info from astra.astra to astra --- python/astra/__init__.py | 3 ++- samples/python/s020_3d_multiGPU.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/python/astra/__init__.py b/python/astra/__init__.py index b73fff5..d5aac44 100644 --- a/python/astra/__init__.py +++ b/python/astra/__init__.py @@ -27,6 +27,7 @@ from . import matlab as m from .creators import astra_dict,create_vol_geom, create_proj_geom, create_backprojection, create_sino, create_reconstruction, create_projector,create_sino3d_gpu, create_backprojection3d_gpu from .functions import data_op, add_noise_to_sino, clear, move_vol_geom from .extrautils import clipCircle +from .astra import set_gpu_index, get_gpu_info from . import data2d from . import astra from . import data3d @@ -45,4 +46,4 @@ import os if 'ASTRA_GPU_INDEX' in os.environ: L = [ int(x) for x in os.environ['ASTRA_GPU_INDEX'].split(',') ] - astra.set_gpu_index(L) + set_gpu_index(L) diff --git a/samples/python/s020_3d_multiGPU.py b/samples/python/s020_3d_multiGPU.py index 11a1e11..e872870 100644 --- a/samples/python/s020_3d_multiGPU.py +++ b/samples/python/s020_3d_multiGPU.py @@ -28,11 +28,11 @@ import numpy as np # Set up multi-GPU usage. # This only works for 3D GPU forward projection and back projection. -astra.astra.set_gpu_index([0,1]) +astra.set_gpu_index([0,1]) # Optionally, you can also restrict the amount of GPU memory ASTRA will use. # The line commented below sets this to 1GB. -#astra.astra.set_gpu_index([0,1], memory=1024*1024*1024) +#astra.set_gpu_index([0,1], memory=1024*1024*1024) vol_geom = astra.create_vol_geom(1024, 1024, 1024) -- cgit v1.2.3 From 3eaebe8827db8ddf029fdb94ccda2b0af1385bec Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 21:07:28 +0200 Subject: Add basic post-install python tests --- .travis.yml | 2 +- README.md | 11 ++++++ README.txt | 16 ++++++++ python/astra/__init__.py | 1 + python/astra/tests.py | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 python/astra/tests.py diff --git a/.travis.yml b/.travis.yml index b34b1a0..aca9940 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,4 +69,4 @@ script: - make -j 4 - make test - make install - - python -c "import astra" + - python -c "import astra; astra.test_noCUDA()" diff --git a/README.md b/README.md index 5211e69..ddc881c 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,17 @@ Run build_setup.bat to automatically copy the boost headers and libraries. For matlab: Run build_matlab.bat. The .dll and .mexw64 files will be in bin\x64\Release_Cuda. For python 2.7/3.5: Run build_python27.bat or build_python35.bat. Astra will be directly installed into site-packages. +## Testing your installation + +To perform a (very) basic test of your ASTRA installation in Python, you can +run the following Python commands. You can choose if you want to skip the test +of the GPU functionality for systems without a NVIDIA GPU. + +``` +import astra +astra.test_noCUDA() # To skip GPU tests +astra.test_CUDA() # To also perform GPU tests +``` ## References diff --git a/README.txt b/README.txt index 94da3d4..63c9cf5 100644 --- a/README.txt +++ b/README.txt @@ -151,6 +151,22 @@ For matlab: Run build_matlab.bat. The .dll and .mexw64 files will be in bin\x64\ For python 2.7/3.5: Run build_python27.bat or build_python35.bat. Astra will be directly installed into site-packages. +Testing your installation: +--------------------------- + +To perform a (very) basic test of your ASTRA installation in Python, you can +run the following Python commands. You can choose if you want to skip the test +of the GPU functionality for systems without a NVIDIA GPU. + +import astra +astra.test_noCUDA() # To skip GPU tests +astra.test_CUDA() # To also perform GPU tests + + + + + + References: ------------ diff --git a/python/astra/__init__.py b/python/astra/__init__.py index d5aac44..8238a88 100644 --- a/python/astra/__init__.py +++ b/python/astra/__init__.py @@ -39,6 +39,7 @@ from . import plugin from . import plugins from . import log from .optomo import OpTomo +from .tests import test_noCUDA, test_CUDA __version__ = '1.8' diff --git a/python/astra/tests.py b/python/astra/tests.py new file mode 100644 index 0000000..32afd36 --- /dev/null +++ b/python/astra/tests.py @@ -0,0 +1,97 @@ +# ----------------------------------------------------------------------- +# Copyright: 2010-2017, iMinds-Vision Lab, University of Antwerp +# 2013-2017, CWI, Amsterdam +# +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ +# +# This file is part of the ASTRA Toolbox. +# +# +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see . +# +# ----------------------------------------------------------------------- + +from __future__ import print_function, absolute_import + +def _basic_par2d_fp(type): + import astra + import numpy as np + vg = astra.create_vol_geom(2, 32) + pg = astra.create_proj_geom('parallel', 1, 32, [0]) + proj_id = astra.create_projector(type, pg, vg) + vol = np.random.rand(2, 32) + (sino_id, sino) = astra.create_sino(vol, proj_id) + astra.data2d.delete(sino_id) + astra.projector.delete(proj_id) + err = np.max(np.abs(sino[0,:] - np.sum(vol,axis=0))) + return err < 1e-6 + +def _basic_par3d_fp(): + import astra + import numpy as np + vg = astra.create_vol_geom(2, 32, 32) + pg = astra.create_proj_geom('parallel3d', 1, 1, 32, 32, [0]) + vol = np.random.rand(32, 2, 32) + (sino_id, sino) = astra.create_sino3d_gpu(vol, pg, vg) + astra.data3d.delete(sino_id) + err = np.max(np.abs(sino[:,0,:] - np.sum(vol,axis=1))) + return err < 1e-6 + + +def _basic_par2d(): + print("Testing basic CPU 2D functionality... ", end="") + if _basic_par2d_fp('line'): + print("Ok") + return True + else: + print("Error") + return False + +def _basic_par2d_cuda(): + print("Testing basic CUDA 2D functionality... ", end="") + if _basic_par2d_fp('cuda'): + print("Ok") + return True + else: + print("Error") + return False + +def _basic_par3d_cuda(): + print("Testing basic CUDA 3D functionality... ", end="") + if _basic_par3d_fp(): + print("Ok") + return True + else: + print("Error") + return False + +def test_noCUDA(): + """Perform a very basic functionality test, without CUDA""" + + ok = _basic_par2d() + if not ok: + raise RuntimeError("Test failed") + +def test_CUDA(): + """Perform a very basic functionality test, including CUDA""" + + import astra + print("Getting GPU info... ", end="") + print(astra.get_gpu_info()) + ok1 = _basic_par2d() + ok2 = _basic_par2d_cuda() + ok3 = _basic_par3d_cuda() + if not (ok1 and ok2 and ok3): + raise RuntimeError("Test failed") -- cgit v1.2.3 From 84e163009c10f6ac5631cf5f29a4923852542eaf Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 Oct 2017 22:29:52 +0200 Subject: Add basic post-install matlab tests --- README.md | 10 +++++-- README.txt | 8 ++++-- matlab/tools/astra_test_CUDA.m | 59 ++++++++++++++++++++++++++++++++++++++++ matlab/tools/astra_test_noCUDA.m | 32 ++++++++++++++++++++++ 4 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 matlab/tools/astra_test_CUDA.m create mode 100644 matlab/tools/astra_test_noCUDA.m diff --git a/README.md b/README.md index ddc881c..f36bdea 100644 --- a/README.md +++ b/README.md @@ -126,8 +126,8 @@ For python 2.7/3.5: Run build_python27.bat or build_python35.bat. Astra will be ## Testing your installation To perform a (very) basic test of your ASTRA installation in Python, you can -run the following Python commands. You can choose if you want to skip the test -of the GPU functionality for systems without a NVIDIA GPU. +run the following Python commands. You can choose to skip the test of the GPU +functionality for systems without a NVIDIA GPU. ``` import astra @@ -135,6 +135,12 @@ astra.test_noCUDA() # To skip GPU tests astra.test_CUDA() # To also perform GPU tests ``` +To test your ASTRA installation in Matlab, the equivalent commands are: + +``` +astra_test_noCUDA % To skip GPU tests +astra_test_CUDA % To also perform GPU tests +``` ## References diff --git a/README.txt b/README.txt index 63c9cf5..69b3b3b 100644 --- a/README.txt +++ b/README.txt @@ -155,16 +155,18 @@ Testing your installation: --------------------------- To perform a (very) basic test of your ASTRA installation in Python, you can -run the following Python commands. You can choose if you want to skip the test -of the GPU functionality for systems without a NVIDIA GPU. +run the following Python commands. You can choose to skip the test of the GPU +functionality for systems without a NVIDIA GPU. import astra astra.test_noCUDA() # To skip GPU tests astra.test_CUDA() # To also perform GPU tests +To test your ASTRA installation in Matlab, the equivalent commands are: - +astra_test_noCUDA % To skip GPU tests +astra_test_CUDA % To also perform GPU tests References: diff --git a/matlab/tools/astra_test_CUDA.m b/matlab/tools/astra_test_CUDA.m new file mode 100644 index 0000000..4171f20 --- /dev/null +++ b/matlab/tools/astra_test_CUDA.m @@ -0,0 +1,59 @@ +%-------------------------------------------------------------------------- +% Clears and frees memory of all objects (data, projectors, algorithms) +% currently in the astra-library. +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- +% This file is part of the ASTRA Toolbox +% +% Copyright: 2010-2017, iMinds-Vision Lab, University of Antwerp +% 2014-2017, CWI, Amsterdam +% License: Open Source under GPLv3 +% Contact: astra@uantwerpen.be +% Website: http://www.astra-toolbox.com/ +%-------------------------------------------------------------------------- + +%% +fprintf('Getting GPU info...') +astra_get_gpu_info() + +%% +astra_test_noCUDA() + +%% +fprintf('Testing basic CUDA 2D functionality...') + +vg = astra_create_vol_geom(2, 32); +pg = astra_create_proj_geom('parallel', 1, 32, [0]); +proj_id = astra_create_projector('cuda', pg, vg); + +vol = rand(2, 32); +[sino_id, sino] = astra_create_sino(vol, proj_id); +astra_mex_data2d('delete', sino_id); +astra_mex_projector('delete', proj_id); + +err = max(abs(sino - sum(vol))); + +if err < 1e-6 + disp('Ok') +else + disp('Error') +end + +%% +fprintf('Testing basic CUDA 3D functionality...') + +vg = astra_create_vol_geom(2, 32, 32); +pg = astra_create_proj_geom('parallel3d', 1, 1, 32, 32, [0]); + +vol = rand(32, 2, 32); +[sino_id, sino] = astra_create_sino3d_cuda(vol, pg, vg); +astra_mex_data3d('delete', sino_id); + +err = max(max(abs(sino - sum(vol,2)))); + +if err < 1e-6 + disp('Ok') +else + disp('Error') +end + diff --git a/matlab/tools/astra_test_noCUDA.m b/matlab/tools/astra_test_noCUDA.m new file mode 100644 index 0000000..6437661 --- /dev/null +++ b/matlab/tools/astra_test_noCUDA.m @@ -0,0 +1,32 @@ +%-------------------------------------------------------------------------- +% Clears and frees memory of all objects (data, projectors, algorithms) +% currently in the astra-library. +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- +% This file is part of the ASTRA Toolbox +% +% Copyright: 2010-2017, iMinds-Vision Lab, University of Antwerp +% 2014-2017, CWI, Amsterdam +% License: Open Source under GPLv3 +% Contact: astra@uantwerpen.be +% Website: http://www.astra-toolbox.com/ +%-------------------------------------------------------------------------- + +fprintf('Testing basic CPU 2D functionality...') + +vg = astra_create_vol_geom(2, 32); +pg = astra_create_proj_geom('parallel', 1, 32, [0]); +proj_id = astra_create_projector('line', pg, vg); + +vol = rand(2, 32); +[sino_id, sino] = astra_create_sino(vol, proj_id); +astra_mex_data2d('delete', sino_id); +astra_mex_projector('delete', proj_id); + +err = max(abs(sino - sum(vol))); + +if err < 1e-6 + disp('Ok') +else + disp('Error') +end -- cgit v1.2.3 From 1642ceef7cb622e530b30232536b31bb43ac7ed9 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 30 Oct 2017 16:29:04 +0100 Subject: Add libastra/linux-64 conda package variants for cudatoolkit Also upgrade the Docker-based linux release scripts to match. --- python/conda/astra-toolbox/build.sh | 8 ++- python/conda/astra-toolbox/conda_build_config.yaml | 9 +++ python/conda/astra-toolbox/meta.yaml | 8 +-- python/conda/libastra/build.sh | 31 ++++++++-- python/conda/libastra/linux_build_config.yaml | 6 ++ python/conda/libastra/meta.yaml | 11 ++-- python/conda/linux_release/buildenv/Dockerfile | 66 +++++++++++++++++----- python/conda/linux_release/buildenv/build.sh | 13 +++++ python/conda/linux_release/builder/Dockerfile | 17 ------ python/conda/linux_release/release.sh | 16 +++--- 10 files changed, 130 insertions(+), 55 deletions(-) create mode 100644 python/conda/astra-toolbox/conda_build_config.yaml create mode 100644 python/conda/libastra/linux_build_config.yaml create mode 100644 python/conda/linux_release/buildenv/build.sh delete mode 100644 python/conda/linux_release/builder/Dockerfile diff --git a/python/conda/astra-toolbox/build.sh b/python/conda/astra-toolbox/build.sh index 951fd88..0468037 100644 --- a/python/conda/astra-toolbox/build.sh +++ b/python/conda/astra-toolbox/build.sh @@ -1,4 +1,10 @@ #!/bin/sh +case `uname` in + Darwin*) + CC="gcc -stdlib=libstdc++" + ;; +esac + cd $SRC_DIR/python/ -CPPFLAGS="-DASTRA_CUDA -DASTRA_PYTHON $CPPFLAGS -I$SRC_DIR/ -I$SRC_DIR/include -I$CUDA_ROOT/include" CC=$CC python ./builder.py build install +CPPFLAGS="-DASTRA_CUDA -DASTRA_PYTHON $CPPFLAGS -I$SRC_DIR/ -I$SRC_DIR/include" CC=$CC python ./builder.py build install diff --git a/python/conda/astra-toolbox/conda_build_config.yaml b/python/conda/astra-toolbox/conda_build_config.yaml new file mode 100644 index 0000000..bd38ac6 --- /dev/null +++ b/python/conda/astra-toolbox/conda_build_config.yaml @@ -0,0 +1,9 @@ +python: + - 2.7 + - 3.5 + - 3.6 + +numpy: + - 1.11 + - 1.12 + - 1.13 diff --git a/python/conda/astra-toolbox/meta.yaml b/python/conda/astra-toolbox/meta.yaml index 942397e..f3a39be 100644 --- a/python/conda/astra-toolbox/meta.yaml +++ b/python/conda/astra-toolbox/meta.yaml @@ -9,13 +9,11 @@ source: build: number: 0 script_env: - - CC # [not win] - - CUDA_ROOT # [not win] + - CC # [linux] test: imports: - astra - requires: # To avoid large downloads just for testing after build phase - nomkl # [not win] @@ -25,14 +23,14 @@ requirements: - python - cython >=0.13 - nomkl # [not win] - - numpy + - numpy {{ numpy }} - scipy - six - libastra ==1.8 run: - python - - numpy x.x + - {{ pin_compatible('numpy', max_pin='x.x') }} - scipy - six - libastra ==1.8 diff --git a/python/conda/libastra/build.sh b/python/conda/libastra/build.sh index 304c053..aa9a4ce 100644 --- a/python/conda/libastra/build.sh +++ b/python/conda/libastra/build.sh @@ -1,5 +1,19 @@ #!/bin/sh +case `uname` in + Darwin*) + CUDA_ROOT=/usr/local/cuda + CC=gcc + CXX=g++ + ;; + Linux*) + [ -n "$cudatoolkit" ] || exit 1 + CUDA_ROOT=/usr/local/cuda-$cudatoolkit + ;; +esac + +[ -x "$CUDA_ROOT" ] || exit 1 + cd $SRC_DIR/build/linux $SRC_DIR/build/linux/autogen.sh @@ -12,7 +26,11 @@ rm -f $CONDA_PREFIX/test.out $SRC_DIR/build/linux/configure --with-install-type=prefix --with-cuda=$CUDA_ROOT --prefix=$CONDA_PREFIX NVCCFLAGS="-ccbin $CC -I$CONDA_PREFIX/include $EXTRA_NVCCFLAGS" CC=$CC CXX=$CXX CPPFLAGS="-I$CONDA_PREFIX/include" -make install-libraries +# Clean, because we may be re-using this source tree when building +# multiple variants of this conda package. +make clean + +make -j $CPU_COUNT install-libraries test -d $CUDA_ROOT/lib64 && LIBPATH="$CUDA_ROOT/lib64" || LIBPATH="$CUDA_ROOT/lib" @@ -22,8 +40,13 @@ case `uname` in cp -P $LIBPATH/libcudart.*.dylib $CONDA_PREFIX/lib cp -P $LIBPATH/libcufft.*.dylib $CONDA_PREFIX/lib ;; - *) - cp -P $LIBPATH/libcudart.so.* $CONDA_PREFIX/lib - cp -P $LIBPATH/libcufft.so.* $CONDA_PREFIX/lib + Linux*) + if [ "$cudatoolkit" = "7.0" ]; then + # For some reason conda-build adds these symlinks automatically for + # cudatoolkit-5.5 and 6.0, but not 7.0. For 7.5 these symlinks are not + # necessary, and for 8.0 the cudatoolkit packages includes them. + ln -T -s libcudart.so.7.0.28 $CONDA_PREFIX/lib/libcudart.so.7.0 + ln -T -s libcufft.so.7.0.35 $CONDA_PREFIX/lib/libcufft.so.7.0 + fi ;; esac diff --git a/python/conda/libastra/linux_build_config.yaml b/python/conda/libastra/linux_build_config.yaml new file mode 100644 index 0000000..c5d2319 --- /dev/null +++ b/python/conda/libastra/linux_build_config.yaml @@ -0,0 +1,6 @@ +cudatoolkit: + - 5.5 + - 6.0 + - 7.0 + - 7.5 + - 8.0 diff --git a/python/conda/libastra/meta.yaml b/python/conda/libastra/meta.yaml index 68cf47a..6176f30 100644 --- a/python/conda/libastra/meta.yaml +++ b/python/conda/libastra/meta.yaml @@ -9,9 +9,8 @@ source: build: number: 0 script_env: - - CC # [not win] - - CXX # [not win] - - CUDA_ROOT # [not win] + - CC # [linux] + - CXX # [linux] requirements: build: @@ -20,15 +19,13 @@ requirements: - automake # [osx] - autoconf # [osx] - libtool # [osx] + - cudatoolkit {{ cudatoolkit }} # [linux] run: - vs2015_runtime # [win] + - cudatoolkit {{ cudatoolkit }} # [linux] about: home: http://www.astra-toolbox.com license: GPLv3 summary: 'The ASTRA Toolbox is a Python toolbox of high-performance GPU primitives for 2D and 3D tomography.' - -# See -# http://docs.continuum.io/conda/build.html for -# more information about meta.yaml diff --git a/python/conda/linux_release/buildenv/Dockerfile b/python/conda/linux_release/buildenv/Dockerfile index ce0b63b..17e9c5b 100644 --- a/python/conda/linux_release/buildenv/Dockerfile +++ b/python/conda/linux_release/buildenv/Dockerfile @@ -1,15 +1,55 @@ -FROM debian:7 -ENV PATH /root/miniconda3/bin:$PATH +FROM debian:7 AS BUILDBASE ENV DEBIAN_FRONTEND noninteractive -# http://developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_64.run -ADD cuda_5.5.22_linux_64.run /root/ -# https://repo.continuum.io/miniconda/Miniconda3-4.3.27.1-Linux-x86_64.sh -ADD Miniconda3-4.3.27.1-Linux-x86_64.sh /root/ -RUN apt-get update -RUN apt-get install -y perl-modules build-essential autoconf libtool automake libboost-dev git -RUN /bin/bash /root/Miniconda3-4.3.27.1-Linux-x86_64.sh -b -RUN /bin/bash /root/cuda_5.5.22_linux_64.run -toolkit -silent +RUN apt-get update && apt-get install -y perl-modules build-essential autoconf libtool automake libboost-dev git && rm -rf /var/lib/apt/lists/* + +FROM BUILDBASE AS CUDA80 +RUN touch /root/cuda80 +COPY cuda_8.0.61_375.26_linux-run /root +RUN /bin/bash /root/cuda_8.0.61_375.26_linux-run --toolkit --silent && \ + rm -f /root/cuda_8.0.61_375.26_linux-run +COPY cuda_8.0.61.2_linux-run /root +RUN /bin/bash /root/cuda_8.0.61.2_linux-run --silent --accept-eula && \ + rm -f /root/cuda_8.0.61.2_linux-run + +FROM BUILDBASE AS CUDA75 +RUN touch /root/cuda75 +COPY cuda_7.5.18_linux.run /root +RUN /bin/bash /root/cuda_7.5.18_linux.run --toolkit --silent && \ + rm -f /root/cuda_7.5.18_linux.run + +FROM BUILDBASE AS CUDA70 +RUN touch /root/cuda70 +COPY cuda_7.0.28_linux.run /root +RUN /bin/bash /root/cuda_7.0.28_linux.run -toolkit -silent && \ + rm -f /root/cuda_7.0.28_linux.run + +COPY cufft_patch_linux.tar.gz /root +RUN cd /usr/local/cuda-7.0 && \ + tar xf /root/cufft_patch_linux.tar.gz && \ + rm -f /root/cufft_patch_linux.tar.gz + +FROM BUILDBASE AS CUDA60 +RUN touch /root/cuda60 +COPY cuda_6.0.37_linux_64.run /root +RUN /bin/bash /root/cuda_6.0.37_linux_64.run -toolkit -silent && \ + rm -f /root/cuda_6.0.37_linux_64.run + +FROM BUILDBASE AS CUDA55 +RUN touch /root/cuda55 +COPY cuda_5.5.22_linux_64.run /root +RUN /bin/bash /root/cuda_5.5.22_linux_64.run -toolkit -silent && \ + rm /root/cuda_5.5.22_linux_64.run + +FROM BUILDBASE +RUN touch /root/cuda +COPY --from=CUDA80 /usr/local/cuda-8.0 /usr/local/cuda-8.0 +COPY --from=CUDA75 /usr/local/cuda-7.5 /usr/local/cuda-7.5 +COPY --from=CUDA70 /usr/local/cuda-7.0 /usr/local/cuda-7.0 +COPY --from=CUDA60 /usr/local/cuda-6.0 /usr/local/cuda-6.0 +COPY --from=CUDA55 /usr/local/cuda-5.5 /usr/local/cuda-5.5 + +ENV PATH /root/miniconda3/bin:$PATH +COPY Miniconda3-4.3.27.1-Linux-x86_64.sh /root/ +RUN /bin/bash /root/Miniconda3-4.3.27.1-Linux-x86_64.sh -b && \ + rm -f /root/Miniconda3* RUN conda install -y conda-build -ENV CUDA_ROOT /usr/local/cuda -ENV CC gcc -ENV CXX g++ diff --git a/python/conda/linux_release/buildenv/build.sh b/python/conda/linux_release/buildenv/build.sh new file mode 100644 index 0000000..1cc0830 --- /dev/null +++ b/python/conda/linux_release/buildenv/build.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +export CC=gcc +export CXX=g++ + +cd /root +git clone --depth 1 --branch master https://github.com/astra-toolbox/astra-toolbox +[ $# -eq 0 ] || perl -pi -e "s/^(\s*number:\s*)[0-9]+$/\${1}$1/" astra-toolbox/python/conda/libastra/meta.yaml astra-toolbox/python/conda/astra-toolbox/meta.yaml + +conda-build -m astra-toolbox/python/conda/libastra/linux_build_config.yaml astra-toolbox/python/conda/libastra +conda-build astra-toolbox/python/conda/astra-toolbox + +cp /root/miniconda3/conda-bld/linux-64/*astra* /out diff --git a/python/conda/linux_release/builder/Dockerfile b/python/conda/linux_release/builder/Dockerfile deleted file mode 100644 index 2404609..0000000 --- a/python/conda/linux_release/builder/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM astra-build-env -ARG BUILD_NUMBER= -WORKDIR /root -RUN git clone --depth 1 https://github.com/astra-toolbox/astra-toolbox -RUN [ -z $BUILD_NUMBER ] || perl -pi -e "s/^(\s*number:\s*)[0-9]+$/\${1}$BUILD_NUMBER/" astra-toolbox/python/conda/libastra/meta.yaml astra-toolbox/python/conda/astra-toolbox/meta.yaml -RUN conda-build --python=3.5 astra-toolbox/python/conda/libastra -RUN conda-build --python 2.7 --numpy 1.8 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 2.7 --numpy 1.9 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 2.7 --numpy 1.10 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 2.7 --numpy 1.11 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 2.7 --numpy 1.12 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 3.5 --numpy 1.9 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 3.5 --numpy 1.10 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 3.5 --numpy 1.11 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 3.5 --numpy 1.12 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 3.6 --numpy 1.11 astra-toolbox/python/conda/astra-toolbox -RUN conda-build --python 3.6 --numpy 1.12 astra-toolbox/python/conda/astra-toolbox diff --git a/python/conda/linux_release/release.sh b/python/conda/linux_release/release.sh index 089cc7c..91c13e4 100644 --- a/python/conda/linux_release/release.sh +++ b/python/conda/linux_release/release.sh @@ -2,19 +2,19 @@ D=`mktemp -d` -[ -f buildenv/cuda_5.5.22_linux_64.run ] || (cd buildenv; wget http://developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_64.run ) -[ -f buildenv/Miniconda3-4.3.27.1-Linux-x86_64.sh ] || (cd buildenv; wget https://repo.continuum.io/miniconda/Miniconda3-4.3.27.1-Linux-x86_64.sh ) +for F in https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh http://developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_64.run http://developer.download.nvidia.com/compute/cuda/6_0/rel/installers/cuda_6.0.37_linux_64.run http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run http://developer.download.nvidia.com/compute/cuda/7_0/Prod/cufft_update/cufft_patch_linux.tar.gz http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run https://developer.nvidia.com/compute/cuda/8.0/Prod2/patches/2/cuda_8.0.61.2_linux-run; do + [ -f buildenv/`basename $F` ] || (cd buildenv; wget $F ) +done docker build -t astra-build-env buildenv -#docker build --no-cache --build-arg=BUILD_NUMBER=0 -t astra-builder builder -docker build --no-cache -t astra-builder builder -docker run --name astra-build-cnt -v $D:/out:z astra-builder /bin/bash -c "cp /root/miniconda3/conda-bld/linux-64/*astra* /out" +cp buildenv/build.sh $D + +docker run -v $D:/out:z astra-build-env /bin/bash /out/build.sh + +rm -f $D/build.sh mkdir -p pkgs mv $D/* pkgs rmdir $D -docker rm astra-build-cnt -docker rmi astra-builder - -- cgit v1.2.3 From 4637704745849cf60ab951f941d5b81fd6fe55dc Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 6 Nov 2017 14:03:18 +0100 Subject: Add workaround for apparently broken mkl/win-64 conda package --- python/conda/astra-toolbox/meta.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/conda/astra-toolbox/meta.yaml b/python/conda/astra-toolbox/meta.yaml index f3a39be..2b25c44 100644 --- a/python/conda/astra-toolbox/meta.yaml +++ b/python/conda/astra-toolbox/meta.yaml @@ -17,6 +17,8 @@ test: requires: # To avoid large downloads just for testing after build phase - nomkl # [not win] + # import scipy.sparse.linalg fails with mkl-2017.0.4 on Windows + - mkl !=2017.0.4 # [win] requirements: build: -- cgit v1.2.3 From 0c5deb3401d71c6dcaa2124169820f63be970c6b Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 6 Nov 2017 14:34:27 +0100 Subject: Add NEWS for 1.8.3 --- NEWS.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NEWS.txt b/NEWS.txt index 1ba4a31..5dc7fff 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -8,6 +8,15 @@ License: Open Source under GPLv3 Contact: astra@uantwerpen.be Website: http://www.astra-toolbox.com/ ----------------------------------------------------------------------- +1.8.3 (2017-11-06) + * fix geometry memory leak in 3D FP/BP + * fix FDK short scan weighting + * add preliminary support for building on macOS + * add experimental support for using externally managed GPU memory from python + (see samples/python/s021_pygpu.py) + * our Linux conda python packages now have variants depending on the + cudatoolkit version + * add basic post-install tests test_CUDA/test_noCUDA (see README) 1.8 (2016-12-05) * the Windows binary release now requires CUDA 8.0 -- cgit v1.2.3 From 454bb20b5d7eb36f1efbf6659652ace26cc229e0 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 6 Nov 2017 14:53:53 +0100 Subject: Fix matlab interface build --- matlab/mex/astra_mex_c.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/mex/astra_mex_c.cpp b/matlab/mex/astra_mex_c.cpp index c16059f..017946a 100644 --- a/matlab/mex/astra_mex_c.cpp +++ b/matlab/mex/astra_mex_c.cpp @@ -38,7 +38,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/AstraObjectManager.h" #ifdef ASTRA_CUDA -#include "../cuda/2d/darthelper.h" +#include "../cuda/2d/astra.h" #include "../cuda/2d/util.h" #include "astra/CompositeGeometryManager.h" #endif -- cgit v1.2.3 From bfceef4da377c32cd59d1e51efb9aa1a21c7f4bd Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 6 Nov 2017 14:40:01 +0100 Subject: Update version to 1.8.3 --- build/linux/configure.ac | 2 +- build/msvc/build_env.bat | 4 ++-- include/astra/Globals.h | 2 +- python/astra/__init__.py | 2 +- python/builder.py | 2 +- python/conda/astra-toolbox/meta.yaml | 8 ++++---- python/conda/libastra/meta.yaml | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build/linux/configure.ac b/build/linux/configure.ac index b95d94f..0091388 100644 --- a/build/linux/configure.ac +++ b/build/linux/configure.ac @@ -23,7 +23,7 @@ dnl along with the ASTRA Toolbox. If not, see . dnl dnl ----------------------------------------------------------------------- -AC_INIT(astra, 1.8.0) +AC_INIT(astra, 1.8.3) AC_CONFIG_SRCDIR([Makefile.in]) LT_INIT([disable-static]) diff --git a/build/msvc/build_env.bat b/build/msvc/build_env.bat index 8cb7c96..56c811f 100644 --- a/build/msvc/build_env.bat +++ b/build/msvc/build_env.bat @@ -12,5 +12,5 @@ set B_VCREDIST=D:\wjp\vs2015u3_redist\vc_redist.x64.exe set B_README_WP27=C:\WinPython-64bit-%B_WP27%\python-%B_WP27:~0,-2%.amd64\Lib\site-packages set B_README_WP35=C:\WinPython-64bit-%B_WP35%\python-%B_WP35:~0,-2%.amd64\Lib\site-packages -set B_RELEASE_TAG=v1.8 -set B_RELEASE=1.8 +set B_RELEASE_TAG=v1.8.3 +set B_RELEASE=1.8.3 diff --git a/include/astra/Globals.h b/include/astra/Globals.h index 7c1e9a8..f447fd8 100644 --- a/include/astra/Globals.h +++ b/include/astra/Globals.h @@ -60,7 +60,7 @@ along with the ASTRA Toolbox. If not, see . #define ASTRA_TOOLBOXVERSION_MAJOR 1 #define ASTRA_TOOLBOXVERSION_MINOR 8 #define ASTRA_TOOLBOXVERSION ((ASTRA_TOOLBOXVERSION_MAJOR)*100 + (ASTRA_TOOLBOXVERSION_MINOR)) -#define ASTRA_TOOLBOXVERSION_STRING "1.8" +#define ASTRA_TOOLBOXVERSION_STRING "1.8.3" #define ASTRA_ASSERT(a) assert(a) diff --git a/python/astra/__init__.py b/python/astra/__init__.py index 8238a88..5e52a1c 100644 --- a/python/astra/__init__.py +++ b/python/astra/__init__.py @@ -41,7 +41,7 @@ from . import log from .optomo import OpTomo from .tests import test_noCUDA, test_CUDA -__version__ = '1.8' +__version__ = '1.8.3' import os diff --git a/python/builder.py b/python/builder.py index ec0bd23..01f4203 100644 --- a/python/builder.py +++ b/python/builder.py @@ -71,7 +71,7 @@ for m in ext_modules: 'PythonPluginAlgorithm.cpp')) setup(name='astra-toolbox', - version='1.8', + version='1.8.3', description='Python interface to the ASTRA Toolbox', author='D.M. Pelt', author_email='D.M.Pelt@cwi.nl', diff --git a/python/conda/astra-toolbox/meta.yaml b/python/conda/astra-toolbox/meta.yaml index 2b25c44..88a9172 100644 --- a/python/conda/astra-toolbox/meta.yaml +++ b/python/conda/astra-toolbox/meta.yaml @@ -1,10 +1,10 @@ package: name: astra-toolbox - version: '1.8' + version: '1.8.3' source: git_url: https://github.com/astra-toolbox/astra-toolbox.git - git_tag: v1.8 + git_tag: v1.8.3 build: number: 0 @@ -28,14 +28,14 @@ requirements: - numpy {{ numpy }} - scipy - six - - libastra ==1.8 + - libastra ==1.8.3 run: - python - {{ pin_compatible('numpy', max_pin='x.x') }} - scipy - six - - libastra ==1.8 + - libastra ==1.8.3 about: diff --git a/python/conda/libastra/meta.yaml b/python/conda/libastra/meta.yaml index 6176f30..e4622b7 100644 --- a/python/conda/libastra/meta.yaml +++ b/python/conda/libastra/meta.yaml @@ -1,10 +1,10 @@ package: name: libastra - version: '1.8' + version: '1.8.3' source: git_url: https://github.com/astra-toolbox/astra-toolbox.git - git_tag: v1.8 + git_tag: v1.8.3 build: number: 0 -- cgit v1.2.3 From bd2798bed2fddfe00dac006013a9fb1363417f20 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 14 Nov 2017 14:56:02 +0100 Subject: Remove unused code --- include/astra/Float32Data3DMemory.h | 33 ++------------------------------- python/astra/PyIncludes.pxd | 1 - python/astra/data3d_c.pyx | 6 +++--- src/Float32Data3DMemory.cpp | 33 --------------------------------- 4 files changed, 5 insertions(+), 68 deletions(-) diff --git a/include/astra/Float32Data3DMemory.h b/include/astra/Float32Data3DMemory.h index 876aa37..4ebe60b 100644 --- a/include/astra/Float32Data3DMemory.h +++ b/include/astra/Float32Data3DMemory.h @@ -52,22 +52,10 @@ protected: */ float32* m_pfData; - /** Array of float32 pointers, each pointing to a single row - * in the m_pfData memory block. - * To access element (ix, iy, iz) internally, use m_ppfDataRowInd[iz * m_iHeight + iy][ix] - */ - float32** m_ppfDataRowInd; - - /** Array of float32 pointers, each pointing to a single slice - * in the m_pfData memory block. - * To access element (ix, iy, iz) internally, use m_pppfDataSliceInd[iz][iy][ix] - */ - float32*** m_pppfDataSliceInd; - float32 m_fGlobalMin; ///< minimum value of the data float32 m_fGlobalMax; ///< maximum value of the data - /** Allocate memory for m_pfData, m_ppfDataRowInd and m_pppfDataSliceInd arrays. + /** Allocate memory for m_pfData. * * The allocated block consists of m_iSize float32s. The block is * not cleared after allocation and its contents is undefined. @@ -75,7 +63,7 @@ protected: */ void _allocateData(); - /** Free memory for m_pfData, m_ppfDataRowInd and m_pppfDataSliceInd arrays. + /** Free memory for m_pfData. * * This function may ONLY be called if the memory for both blocks has been * allocated before. @@ -299,23 +287,6 @@ inline const float32* CFloat32Data3DMemory::getDataConst() const return (const float32*)m_pfData; } -//---------------------------------------------------------------------------------------- -// Get a float32** to the data block, represented as a 3-dimensional array of float32 values. -inline float32*** CFloat32Data3DMemory::getData3D() -{ - ASTRA_ASSERT(m_bInitialized); - return m_pppfDataSliceInd; -} - -//---------------------------------------------------------------------------------------- -// Get a const float32** to the data block, represented as a 3-dimensional array of float32 values. -inline const float32*** CFloat32Data3DMemory::getData3DConst() const -{ - ASTRA_ASSERT(m_bInitialized); - return (const float32***)m_pppfDataSliceInd; -} -//---------------------------------------------------------------------------------------- - } // end namespace astra #endif // _INC_ASTRA_FLOAT32DATA2D diff --git a/python/astra/PyIncludes.pxd b/python/astra/PyIncludes.pxd index 512b82f..ec37d0a 100644 --- a/python/astra/PyIncludes.pxd +++ b/python/astra/PyIncludes.pxd @@ -211,7 +211,6 @@ cdef extern from "astra/Float32Data3DMemory.h" namespace "astra": CFloat32Data3DMemory() void updateStatistics() float32 *getData() - float32 ***getData3D() THREEEDataType getType() diff --git a/python/astra/data3d_c.pyx b/python/astra/data3d_c.pyx index 0717ca0..897634b 100644 --- a/python/astra/data3d_c.pyx +++ b/python/astra/data3d_c.pyx @@ -254,7 +254,7 @@ cdef fillDataObjectScalar(CFloat32Data3DMemory * obj, float s): @cython.boundscheck(False) @cython.wraparound(False) cdef fillDataObjectArray(CFloat32Data3DMemory * obj, float [:,:,::1] data): - cdef float [:,:,::1] cView = obj.getData3D()[0][0] + cdef float [:,:,::1] cView = obj.getData() cView[:] = data cdef CFloat32Data3D * getObject(i) except NULL: @@ -271,7 +271,7 @@ def get(i): cdef CFloat32Data3DMemory * pDataObject = dynamic_cast_mem_safe(getObject(i)) outArr = np.empty((pDataObject.getDepth(),pDataObject.getHeight(), pDataObject.getWidth()),dtype=np.float32,order='C') cdef float [:,:,::1] mView = outArr - cdef float [:,:,::1] cView = pDataObject.getData3D()[0][0] + cdef float [:,:,::1] cView = pDataObject.getData() mView[:] = cView return outArr @@ -282,7 +282,7 @@ def get_shared(i): shape[0] = pDataObject.getDepth() shape[1] = pDataObject.getHeight() shape[2] = pDataObject.getWidth() - return np.PyArray_SimpleNewFromData(3,shape,np.NPY_FLOAT32,pDataObject.getData3D()[0][0]) + return np.PyArray_SimpleNewFromData(3,shape,np.NPY_FLOAT32,pDataObject.getData()) def get_single(i): raise NotImplementedError("Not yet implemented") diff --git a/src/Float32Data3DMemory.cpp b/src/Float32Data3DMemory.cpp index 5c5c310..017625b 100644 --- a/src/Float32Data3DMemory.cpp +++ b/src/Float32Data3DMemory.cpp @@ -71,8 +71,6 @@ bool CFloat32Data3DMemory::_initialize(int _iWidth, int _iHeight, int _iDepth) // allocate memory for the data, but do not fill it m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; m_pCustomMemory = 0; _allocateData(); @@ -103,8 +101,6 @@ bool CFloat32Data3DMemory::_initialize(int _iWidth, int _iHeight, int _iDepth, c // allocate memory for the data, but do not fill it m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; m_pCustomMemory = 0; _allocateData(); @@ -140,8 +136,6 @@ bool CFloat32Data3DMemory::_initialize(int _iWidth, int _iHeight, int _iDepth, f // allocate memory for the data, but do not fill it m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; m_pCustomMemory = 0; _allocateData(); @@ -178,8 +172,6 @@ bool CFloat32Data3DMemory::_initialize(int _iWidth, int _iHeight, int _iDepth, C // allocate memory for the data, but do not fill it m_pCustomMemory = _pCustomMemory; m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; _allocateData(); // initialization complete @@ -198,8 +190,6 @@ void CFloat32Data3DMemory::_allocateData() ASTRA_ASSERT(m_iSize > 0); ASTRA_ASSERT(m_iSize == (size_t)m_iWidth * m_iHeight * m_iDepth); ASTRA_ASSERT(m_pfData == NULL); - ASTRA_ASSERT(m_ppfDataRowInd == NULL); - ASTRA_ASSERT(m_pppfDataSliceInd == NULL); if (!m_pCustomMemory) { // allocate contiguous block @@ -213,20 +203,6 @@ void CFloat32Data3DMemory::_allocateData() } else { m_pfData = m_pCustomMemory->m_fPtr; } - - // create array of pointers to each row of the data block - m_ppfDataRowInd = new float32*[m_iHeight*m_iDepth]; - for (int iy = 0; iy < m_iHeight*m_iDepth; iy++) - { - m_ppfDataRowInd[iy] = &(m_pfData[iy * m_iWidth]); - } - - // create array of pointers to each row of the data block - m_pppfDataSliceInd = new float32**[m_iDepth]; - for (int iy = 0; iy < m_iDepth; iy++) - { - m_pppfDataSliceInd[iy] = &(m_ppfDataRowInd[iy * m_iHeight]); - } } //---------------------------------------------------------------------------------------- @@ -235,13 +211,6 @@ void CFloat32Data3DMemory::_freeData() { // basic checks ASTRA_ASSERT(m_pfData != NULL); - ASTRA_ASSERT(m_ppfDataRowInd != NULL); - ASTRA_ASSERT(m_pppfDataSliceInd != NULL); - - // free memory for index table - delete[] m_pppfDataSliceInd; - // free memory for index table - delete[] m_ppfDataRowInd; if (!m_pCustomMemory) { // free memory for data block @@ -266,8 +235,6 @@ void CFloat32Data3DMemory::_clear() m_iSize = 0; m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; m_pCustomMemory = NULL; } -- cgit v1.2.3