Skip to content

Commit b621122

Browse files
authored
Merge pull request #680 from danfortunato/fix-matlab-isgpuarray
Improve gpuArray checking in MATLAB interface
2 parents d315604 + 6f11f12 commit b621122

7 files changed

+13
-26
lines changed

matlab/cufinufft.mw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ classdef cufinufft_plan < handle
216216
% EXECUTE execute single or many-vector GPU FINUFFT transforms in a plan.
217217

218218
% check if data_in is gpuArray
219-
if ~finufft_isgpuarray(data_in)
219+
if ~isa(data_in, 'gpuArray')
220220
error('FINUFFT:badDataDevice','input data must be a gpuArray');
221221
end
222222

matlab/cufinufft_plan.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function setpts(plan, xj, yj, zj, s, t, u)
123123
% EXECUTE execute single or many-vector GPU FINUFFT transforms in a plan.
124124

125125
% check if data_in is gpuArray
126-
if ~finufft_isgpuarray(data_in)
126+
if ~isa(data_in, 'gpuArray')
127127
error('FINUFFT:badDataDevice','input data must be a gpuArray');
128128
end
129129

matlab/finufft.mw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ classdef finufft_plan < handle
234234
% EXECUTE execute single or many-vector FINUFFT transforms in a plan.
235235

236236
% check if data_in is gpuArray
237-
if finufft_isgpuarray(data_in)
237+
if isa(data_in, 'gpuArray')
238238
error('FINUFFT:badDataDevice','input data must be a cpuArray');
239239
end
240240

matlab/finufft_isgpuarray.m

Lines changed: 0 additions & 13 deletions
This file was deleted.

matlab/finufft_plan.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function setpts(plan, xj, yj, zj, s, t, u)
125125
% EXECUTE execute single or many-vector FINUFFT transforms in a plan.
126126

127127
% check if data_in is gpuArray
128-
if finufft_isgpuarray(data_in)
128+
if isa(data_in, 'gpuArray')
129129
error('FINUFFT:badDataDevice','input data must be a cpuArray');
130130
end
131131

matlab/valid_ntr.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function n_transf = valid_ntr(x,c);
1+
function n_transf = valid_ntr(x,c)
22
% VALID_NTR deduce n_transforms and validate the size of c, for types 1 and 3.
33
% also check for array device consistency.
44

5-
if finufft_isgpuarray(x) ~= finufft_isgpuarray(c)
5+
if isa(x, 'gpuArray') ~= isa(c, 'gpuArray')
66
error('FINUFFT:mixedDevice','FINUFFT: x and c must be both on GPU or CPU');
77
end
88

matlab/valid_setpts.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,34 @@
1212

1313
% Barnett 6/19/20, split out from guru so simple ints can check before plan.
1414
% s,t,u are only checked for type 3.
15-
% note that isvector([]) is false, finufft_isgpuarray([]) is false, finufft_isgpuarray(gpuArray([])) is true.
15+
% note that isvector([]) is false, isa([], 'gpuArray') is false, isa(gpuArray([]), 'gpuArray') is true.
1616
if ~isvector(x), error('FINUFFT:badXshape','FINUFFT x must be a vector'); end
17-
if finufft_isgpuarray(x) ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
17+
if isa(x, 'gpuArray') ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
1818
nj = numel(x);
1919
if type==3
2020
nk = numel(s);
2121
if ~isvector(s), error('FINUFFT:badSshape','FINUFFT s must be a vector'); end
22-
if finufft_isgpuarray(s) ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
22+
if isa(s, 'gpuArray') ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
2323
else
2424
nk = 0; % dummy output
2525
end
2626
if dim>1
2727
if ~isvector(y), error('FINUFFT:badYshape','FINUFFT y must be a vector'); end
28-
if finufft_isgpuarray(y) ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
28+
if isa(y, 'gpuArray') ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
2929
if numel(y)~=nj, error('FINUFFT:badYlen','FINUFFT y must have same length as x'); end
3030
if type==3
3131
if ~isvector(t), error('FINUFFT:badTshape','FINUFFT t must be a vector'); end
32-
if finufft_isgpuarray(t) ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
32+
if isa(t, 'gpuArray') ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
3333
if numel(t)~=nk, error('FINUFFT:badTlen','FINUFFT t must have same length as s'); end
3434
end
3535
end
3636
if dim>2
3737
if ~isvector(z), error('FINUFFT:badZshape','FINUFFT z must be a vector'); end
38-
if finufft_isgpuarray(z) ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
38+
if isa(z, 'gpuArray') ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
3939
if numel(z)~=nj, error('FINUFFT:badZlen','FINUFFT z must have same length as x'); end
4040
if type==3
4141
if ~isvector(u), error('FINUFFT:badUshape','FINUFFT u must be a vector'); end
42-
if finufft_isgpuarray(u) ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
42+
if isa(u, 'gpuArray') ~= is_gpuarray, error('FINUFFT:badDataDevice', 'input data must be on the specified device'); end
4343
if numel(u)~=nk, error('FINUFFT:badUlen','FINUFFT u must have same length as s'); end
4444
end
4545
end

0 commit comments

Comments
 (0)