Skip to content

Commit

Permalink
old julia versions
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Jun 18, 2024
1 parent 1fb6c32 commit a5f33c1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/host/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ end
(isa(IndexStyle(dest), IndexLinear) &&
isa(IndexStyle(bc), IndexLinear))
function (ctx, dest, bcstyle, bcf, bcaxes, nelem, bcargs...)
@static if VERSION >= v"1.10-"
bc2 = Base.Broadcast.Broadcasted(bcstyle, bcf, bcargs, bcaxes)
else
bc2 = Base.Broadcast.Broadcasted{bcstyle}(bcf, bcargs, bcaxes)
end
i = 1
while i <= nelem
I = @linearidx(dest, i)
Expand All @@ -64,7 +68,11 @@ end
end
else
function (ctx, dest, bcstyle, bcf, bcaxes, nelem, bcargs...)
@static if VERSION >= v"1.10-"
bc2 = Base.Broadcast.Broadcasted(bcstyle, bcf, bcargs, bcaxes)
else
bc2 = Base.Broadcast.Broadcasted{bcstyle}(bcf, bcargs, bcaxes)
end
i = 0
while i < nelem
i += 1
Expand All @@ -77,11 +85,16 @@ end

elements = length(dest)
elements_per_thread = typemax(Int)
heuristic = launch_heuristic(backend(dest), broadcast_kernel, dest, bc.style, bc.f, bc.axes, 1, bc.args...;
@static if VERSION >= v"1.10-"
style = bc.style
else
style = Base.Broadcast.BroadcastStyle(typeof(bc))
end
heuristic = launch_heuristic(backend(dest), broadcast_kernel, dest, style, bc.f, bc.axes, 1, bc.args...;
elements, elements_per_thread)
config = launch_configuration(backend(dest), heuristic;
elements, elements_per_thread)
gpu_call(broadcast_kernel, dest, bc.style, bc.f, bc.axes, config.elements_per_thread, bc.args...;
gpu_call(broadcast_kernel, dest, style, bc.f, bc.axes, config.elements_per_thread, bc.args...;
threads=config.threads, blocks=config.blocks)

if eltype(dest) <: BrokenBroadcast
Expand Down

0 comments on commit a5f33c1

Please sign in to comment.