Skip to content

Commit c539afa

Browse files
authored
Broadcast benchmark (#2629)
1 parent 0928441 commit c539afa

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

benchmark/benchmarks.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,36 @@ x = MyStruct(1.0, zeros(3))
3232

3333
SUITE["basics"]["make_zero"]["struct"] = @benchmarkable Enzyme.make_zero($x)
3434
SUITE["basics"]["remake_zero!"]["struct"] = @benchmarkable Enzyme.remake_zero!(dx) setup = (dx = Enzyme.make_zero(x))
35+
36+
37+
38+
@noinline function sass(σ, x)
39+
z = σ / x
40+
return z
41+
end
42+
43+
@noinline function multidim_sum_bcast0(dist, x, res)
44+
broadcasted = Broadcast.broadcasted(sass, dist, x)
45+
lp = sum(Broadcast.instantiate(broadcasted))
46+
res[] = lp
47+
nothing
48+
end
49+
50+
function multidim_sum_bcast(dist, y)
51+
tmp = Ref{Float64}(0.0)
52+
multidim_sum_bcast0(dist, y, tmp)
53+
return tmp[]::Float64
54+
end
55+
56+
57+
y1d = rand(10, 40);
58+
dist1d = fill(10.0, 40);
59+
60+
SUITE["fold_broadcast"]["multidim_sum_bcast"]["1D"] = @benchmarkable multidim_sum_bcast($dist1d, $y1d)
61+
62+
y2d = rand(10, 4);
63+
dist2d = fill(10.0, 10, 4);
64+
65+
SUITE["fold_broadcast"]["multidim_sum_bcast"]["2D"] = @benchmarkable multidim_sum_bcast($dist2d, $y2d)
66+
67+

0 commit comments

Comments
 (0)