Skip to content

Commit

Permalink
Batched no jlcall (#2226)
Browse files Browse the repository at this point in the history
* Batched no jlcall

* fix
  • Loading branch information
wsmoses authored Dec 24, 2024
1 parent a2db43b commit 1ee964a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/llvm/attributes.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const nofreefns = Set{String}((
"jl_egal__unboxed", "ijl_egal__unboxed",
"jl_restore_excstack",
"ijl_restore_excstack",
"ClientGetDevice",
Expand Down Expand Up @@ -154,6 +155,7 @@ const nofreefns = Set{String}((
))

const inactivefns = Set{String}((
"jl_egal__unboxed", "ijl_egal__unboxed",
"ClientGetDevice",
"BufferOnCPU",
"pcre2_match_data_create_from_pattern_8",
Expand Down
24 changes: 22 additions & 2 deletions src/rules/llvmrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,17 @@ include("parallelrules.jl")
normal =
(unsafe_load(normalR) != C_NULL) ? LLVM.Instruction(unsafe_load(normalR)) : nothing
if shadowR != C_NULL && normal !== nothing
unsafe_store!(shadowR, normal.ref)
t_shadow = normal
width = get_width(gutils)
if width != 1
t_shadow = UndefValue(
LLVM.LLVMType(API.EnzymeGetShadowType(width, value_type(normal))),
)
for idx = 1:width
t_shadow = insert_value!(B, t_shadow, normal, idx - 1)
end
end
unsafe_store!(shadowR, t_shadow.ref)
end
# Delete the primal code
if normal !== nothing
Expand Down Expand Up @@ -246,7 +256,17 @@ end
normal =
(unsafe_load(normalR) != C_NULL) ? LLVM.Instruction(unsafe_load(normalR)) : nothing
if shadowR != C_NULL && normal !== nothing
unsafe_store!(shadowR, normal.ref)
t_shadow = normal
width = get_width(gutils)
if width != 1
t_shadow = UndefValue(
LLVM.LLVMType(API.EnzymeGetShadowType(width, value_type(normal))),
)
for idx = 1:width
t_shadow = insert_value!(B, t_shadow, normal, idx - 1)
end
end
unsafe_store!(shadowR, t_shadow.ref)
end
# Delete the primal code
if normal !== nothing
Expand Down

0 comments on commit 1ee964a

Please sign in to comment.