Skip to content

Commit 684e80f

Browse files
committed
Speed up gpuArray check in MATLAB interface
1 parent cdbb318 commit 684e80f

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

matlab/finufft_isgpuarray.m

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
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
12+
13+
% % check if the isgpuarray function is available
14+
% if exist('isgpuarray') == 0
15+
% % return 0, since no parallel computing toolbox, can not use gpuarray
16+
% is_gpuarray = logical(0);
17+
% else
18+
% % call the parallel computing toolbox isgpuarray function
19+
% is_gpuarray = isgpuarray(input);
20+
% end
621

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
1522
end

0 commit comments

Comments
 (0)