Commit e86181b0 authored by Simon Maretzke's avatar Simon Maretzke
Browse files

Removed redundant function gatherIfOnGPU (can be replaced by gather)

parent dba721f2
function arrayOnHost = gatherIfOnGPU(array)
% GATHERIFONGPU copies a given array back to CPU if it is a GPU array.
%
% ``arrayOnHost = gatherIfOnGPU(array)``
%
% Parameters
% ----------
% array : numerical array
% array to be copied back to CPU
%
% Returns
% -------
% arrayOnHost : numerical array
% input array copied back to CPU
%
% HoloTomoToolbox
% Copyright (C) 2019 Institut fuer Roentgenphysik, Universitaet Goettingen
%
% This program 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.
%
% This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
arrayOnHost = gatherIf(array, isOnGPU(array));
end
......@@ -280,7 +280,7 @@ end
% Undo optional padding
result = gatherIfOnGPU(croparray(result, [settings.pady, settings.padx]));
result = gather(croparray(result, [settings.pady, settings.padx]));
end
......
......@@ -121,8 +121,8 @@ function result = phaserec_nonlinTikhonov(holograms, fresnelNumbers, settings)
% Default parameters (widely identical to phaserec_ctf)
defaults = phaserec_ctf;
defaults.optimPar = struct;
defaults.optimPar.maxIt = 30;
defaults.optimPar.tol = 1e-3;
defaults.optimPar.maxIt = 50;
defaults.optimPar.tol = 1e-2;
% Return default parameters if called without argument
if (nargin == 0)
......@@ -283,7 +283,7 @@ if settings.betaDeltaRatio == 0
else
gradRef = F.adjoint(holograms - mean(mean(holograms,1),2));
end
optimPar.resiGradRef = gatherIfOnGPU(norm(gradRef(:)));
optimPar.resiGradRef = gather(norm(gradRef(:)));
%
[result, stats] = projectedGradientDescent(TikhonovFunctional, initialGuess, optimPar);
......@@ -297,7 +297,7 @@ end
% Undo optional padding
result = gatherIfOnGPU(croparray(result, [settings.pady, settings.padx]));
result = gather(croparray(result, [settings.pady, settings.padx]));
end
......
......@@ -115,7 +115,7 @@ for it = 1:settings.maxIt
% Save new iterate and updated functional value
x = xNew;
value = gatherIfOnGPU(valueNew);
value = gather(valueNew);
% Compute new gradient
grad = F.getGradient();
......@@ -150,7 +150,7 @@ function resiGrad = computeGradientResidual(grad, xhat, x, projection, stepsize)
if ~isempty(projection)
gradProj = gradProj + (xhat - x) ./ stepsize;
end
resiGrad = gatherIfOnGPU(norm(gradProj(:)));
resiGrad = gather(norm(gradProj(:)));
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment