JuliaGPU / CUDA.jl

CUDA programming in Julia.
https://juliagpu.org/cuda/
Other
1.16k stars 206 forks source link

Mark cuarray as noalias #2395

Closed wsmoses closed 1 month ago

wsmoses commented 1 month ago

@vchuravy @maleadt I don't suppose you know a better way to get this info from julia effects a priori.

Has corresponding EnzymeCore update.

Note this is part of an ongoing effort for Enzyme to successfully differentiate (in fwd mode to start with) Cuda broadcasts/etc

maleadt commented 1 month ago

I don't suppose you know a better way to get this info from julia effects a priori.

I have no idea what Enzyme.noalias means or what you're asking. If you're asserting here that CuArrays can't alias, that's wrong, because they can (views/reshapes/etc are materialized as CuArrays).

wsmoses commented 1 month ago

Partially, so I'm hoping to make something which generates an llvm noalias on the result of a call (which permits optimizations -- which are particularly helpul for broadcasting).

Specifically, here I'd like to provide the semantics a fresh allocation of a CuArray doesn't alias any other memory in the system (but of course a view taken of that variable may alias the original variable).

wsmoses commented 1 month ago

And yeah I'm looking to add it (https://github.com/EnzymeAD/Enzyme.jl/pull/1467) as a companion to this PR to be able to propagate this information.

In contrast jl_alloc_array_1d we are able to add LLVM-level noalias this ourselves, but to add noalias for codes out of Julia base requires an interface function was my thought.

I'd love to alternatively read this in thorugh Julia effects, but I don't know if that has something helpful here.

wsmoses commented 1 month ago

@vchuravy with this passing, mind approving/merging?

maleadt commented 1 month ago

with this passing

It did not:

extensions/enzyme: Error During Test at /var/lib/buildkite-agent/builds/gpuci-4/julialang/cuda-dot-jl/test/extensions/enzyme.jl:74
  Got exception outside of a @test
  UndefVarError: `f` not defined

Changing f to firstsum triggers a scalar iteration warning. I'm reverting the PR.


Can you please verify the Enzyme tests pass locally before marking a PR ready for review? We don't have the capacity for CI-driven development. Also please include [skip julia] [skip cuda] etc tags to avoid running unnecessary tests.

wsmoses commented 1 month ago

Oh rip sorry I saw the green on CI and assumed it was fine, I guess it just didn't run