Enzyme.jl icon indicating copy to clipboard operation
Enzyme.jl copied to clipboard

Unsafe wrap is not supported fully

Open vchuravy opened this issue 10 months ago • 4 comments

The added test currently fails with:

cannot find shadow for   %19 = call nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* @ijl_ptr_to_array({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 139992576232976 to {}*) to {} addrspace(10)*), i64 %16, {} addrspace(10)* noundef nonnull %17, i32 noundef 0) #27, !dbg !75

Caused by:
Stacktrace:
 [1] #unsafe_wrap#115
   @ ./pointer.jl:110
 [2] unsafe_wrap
   @ ./pointer.jl:108
 [3] Container

Follow-up to #2257

vchuravy avatar Feb 18 '25 14:02 vchuravy

@wsmoses how do I best go about fixing this?

vchuravy avatar Feb 18 '25 14:02 vchuravy

Benchmark Results

main decf3a7b327c7b... main/decf3a7b327c7b...
basics/overhead 4.33 ± 0.01 ns 4.34 ± 0.01 ns 0.998
time_to_load 1.22 ± 0.03 s 1.24 ± 0.013 s 0.981

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

github-actions[bot] avatar Feb 18 '25 14:02 github-actions[bot]

I would like look at the rule we have for that and make sure we initialize/store the shadow.

note that I’m not sure we implemented this so far, partially due to a semantics question. If the function copies in reverse we need to do the reverse += copy, but if not it should have an empty reverse pass

wsmoses avatar Feb 19 '25 00:02 wsmoses

ijl_ptr_to_array is not a copy, but it is an "aliasing" operation. It wraps a pointer in an Julia array.

vchuravy avatar Feb 20 '25 10:02 vchuravy