Skip to content

Commit

Permalink
Remove zefunc.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed May 4, 2021
1 parent e3c9db9 commit bcf2d06
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
26 changes: 0 additions & 26 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,3 @@ Base.similar(bc::Broadcasted{oneArrayStyle{N}}, ::Type{T}) where {N,T} =

Base.similar(bc::Broadcasted{oneArrayStyle{N}}, ::Type{T}, dims...) where {N,T} =
oneArray{T}(undef, dims...)


## replace base functions with libdevice alternatives

zefunc(f) = f
zefunc(::Type{T}) where T = (x...) -> T(x...) # broadcasting type ctors isn't GPU compatible

Broadcast.broadcasted(::oneArrayStyle{N}, f, args...) where {N} =
Broadcasted{oneArrayStyle{N}}(zefunc(f), args, nothing)

const device_intrinsics = :[
# math
acos, acosh, acospi, asin, asinh, asinpi, atan, atan2, atan2pi, atanh, atanpi, cbrt,
ceil, copysign, cos, cosh, cospi, erf, erfc, exp, exp10, exp2, expm1, abs, fdim,
floor, fma, fmax, fmax, fmax, fmin, fmin, fmin, fmod, hypot, ilogb, ilogb,
ldexp, lgamma, log, log10, log1p, log2, logb, mad, maxmag, minmag, nan, nextafter,
pow, pown, powr, remainder, rint, rootn, round, rsqrt, sin, sinh, sinpi, sqrt,
tan, tanh, tanpi, tgamma, trunc,
# integer
abs_diff, add_sat, hadd, rhadd, clz, mad_hi, mad_sat, mul_hi, rotate,
sub_sat, popcount].args

for f in device_intrinsics
isdefined(Base, f) || continue
@eval zefunc(::typeof(Base.$f)) = $f
end
3 changes: 0 additions & 3 deletions src/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ function GPUArrays.mapreducedim!(f::F, op::OP, R::oneWrappedArray{T},
Base.check_reducedims(R, A)
length(A) == 0 && return R # isempty(::Broadcasted) iterates

f = zefunc(f)
op = zefunc(op)

# add singleton dimensions to the output container, if needed
if ndims(R) < ndims(A)
dims = Base.fill_to_length(size(R), 1, Val(ndims(A)))
Expand Down

0 comments on commit bcf2d06

Please sign in to comment.