Skip to content

Commit d315604

Browse files
authored
Merge pull request #676 from danfortunato/fix-matlab-isgpuarray
Speed up gpuArray check in MATLAB interface
2 parents cdbb318 + 2555f04 commit d315604

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

matlab/finufft_isgpuarray.m

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
function is_gpuarray = finufft_isgpuarray(input)
2-
% FINUFFT_ISGPUARRAY check if an array is an gpuArray.
3-
%
4-
% Note: this is currently unused since GPU codes have distinct cufinufft*
5-
% names.
2+
%FINUFFT_ISGPUARRAY Check if an array is a gpuArray.
3+
4+
try
5+
% Try calling MATLAB's built-in isgpuarray routine. If isgpuarray does
6+
% not exist (e.g., because we're in Octave) then this will throw an
7+
% error, which we catch below.
8+
is_gpuarray = isgpuarray(input);
9+
catch
10+
is_gpuarray = false;
11+
end
612

7-
% check if the isgpuarray function is available
8-
if exist('isgpuarray') == 0
9-
% return 0, since no parallel computing toolbox, can not use gpuarray
10-
is_gpuarray = logical(0);
11-
else
12-
% call the parallel computing toolbox isgpuarray function
13-
is_gpuarray = isgpuarray(input);
14-
end
1513
end

0 commit comments

Comments
 (0)