You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
promote_maxsize(maxsize) =@ModuleInternalError("maxsize must be a Tuple of Integer of size 1, 2 or 3 (obtained: $maxsize; its type is: $(typeof(maxsize))).")
369
369
370
+
maxsize(A::T) where T<:AbstractArray= (size(A,1),size(A,2),size(A,3)) # NOTE: using size(A,dim) three times instead of size(A) ensures to have a tuple of length 3.
371
+
maxsize(a::T) where T<:Number= (1, 1, 1)
372
+
maxsize(x) =@ArgumentError("automatic detection of ranges not possible in @parallel call: some kernel arguments are neither arrays nor scalars. Specify ranges or nthreads and nblocks manually.")
373
+
maxsize(x, args...) =merge(maxsize(x), maxsize(args...)) # NOTE: maxsize is implemented as a recursive function, which results in optimal code; otherwise, the function is not performance-negligable for small problems.
374
+
merge(a::Tuple, b::Tuple) =max.(a,b)
375
+
370
376
functionget_ranges(args...)
371
-
complex_args = [x for x in args if!(isa(x, AbstractArray) ||isa(x, Number))]
372
-
iflength(complex_args) >0@ArgumentError("automatic detection of ranges not possible in @parallel call: some kernel arguments are neither arrays nor scalars. Specify ranges or nthreads and nblocks manually.") end
373
-
arrays = [x for x in args ifisa(x, AbstractArray)];
374
-
if (length(arrays) ==0) @ArgumentError("automatic detection of ranges not possible: no arrays detected in kernel arguments. Specify ranges or nthreads and nblocks manually.") end
375
-
maxsize = ( maximum([size(A,1) for A in arrays]), maximum([size(A,2) for A in arrays]), maximum([size(A,3) for A in arrays]) )
0 commit comments