Skip to content

Commit e499979

Browse files
bors[bot]vchuravy
andauthored
Merge #225
225: Forward port of #224 r=vchuravy a=vchuravy (cherry picked from commit 7318a2c) bors r+ Co-authored-by: Valentin Churavy <[email protected]>
2 parents e08b87d + fa96bef commit e499979

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/compiler.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,7 @@ function generate_overdubs(mod, Ctx)
6060
end
6161
Base.steprangelen_hp(T, start, step, 0, len, 1)
6262
end
63+
64+
@inline Cassette.overdub(::$Ctx, ::typeof(Base.literal_pow), f::F, x, p) where F = Base.literal_pow(f, x, p)
6365
end
6466
end

test/compiler.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ import KernelAbstractions.NDIteration: NDRange, StaticSize, DynamicSize
88
@show A[I...]
99
end
1010

11+
@kernel function literal_pow(A)
12+
A[1] = 2^11
13+
end
14+
1115
function compiler_testsuite()
1216
kernel = index(CPU(), DynamicSize(), DynamicSize())
1317
iterspace = NDRange{1, StaticSize{(128,)}, StaticSize{(8,)}}();
1418
ctx = KernelAbstractions.mkcontext(kernel, 1, nothing, iterspace, Val(KernelAbstractions.NoDynamicCheck()))
1519

1620
@test KernelAbstractions.Cassette.overdub(ctx, KernelAbstractions.__index_Global_NTuple, CartesianIndex(1)) == (1,)
21+
22+
CI, rt = @ka_code_typed literal_pow(CPU())(zeros(Int,1), ndrange=1)
23+
# test that there is no invoke of overdub
24+
@test !any(stmt->(stmt isa Expr) && stmt.head == :invoke, CI.code)
1725
end
26+

0 commit comments

Comments
 (0)