Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve AD module #176

Merged
merged 7 commits into from
Dec 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update autodiff_gpu
omlins committed Oct 29, 2024
commit dc5b65f5789472ea015fe32df902f96cf10c2d85
9 changes: 5 additions & 4 deletions src/ParallelKernel/EnzymeExt/autodiff_gpu.jl
Original file line number Diff line number Diff line change
@@ -2,16 +2,17 @@ import ParallelStencil
import ParallelStencil: PKG_THREADS, PKG_POLYESTER
import Enzyme

# NOTE: package specific initialization of Enzyme could be done as follows (not needed in the currently supported versions of Enzyme)
# function ParallelStencil.ParallelKernel.AD.init_AD(package::Symbol)
# if iscpu(package)
# Enzyme.API.runtimeActivity!(true) # NOTE: this is currently required for Enzyme to work correctly with threads
# end
# end

# ParallelStencil injects a configuration parameter at the end, for Enzyme we need to wrap that parameter as a Annotation
# for all purposes this ought to be Const. This is not ideal since we might accidentially wrap other parameters the user
# provided as well. This is needed to support @parallel autodiff_deferred(...)
function promote_to_const(args::Vararg{Any,N}) where N
# NOTE: @parallel injects four parameters at the end, which need to be wrapped as Annotations. The current solution is to wrap all
# arguments which are not already Annotations (all the other arguments must be Annotations). Should this change, then one could
# explicitly wrap just the injected parameters.
function promote_to_const(args::Vararg{Any,N}) where N
ntuple(Val(N)) do i
@inline
if !(args[i] isa Enzyme.Annotation ||