You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/AD.jl
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,8 @@ Provides GPU-compatible wrappers for automatic differentiation functions of the
7
7
import ParallelStencil.AD
8
8
9
9
# Functions
10
-
- `autodiff_deferred!(mode, f, args...)`: wraps function `Enzyme.autodiff_deferred`, calling it as `Enzyme.autodiff_deferred(mode, f, Const, args...)`, promoting all arguments of `args` and `f` that are not `Enzyme.Annotation` to `Enzyme.Const`. Important: the return type activity is automatically inserted as 3rd argument as it is always `Enzyme.Const`, given that `@parallel` and `@parallel_indices` functions must return nothing.
11
-
- `autodiff_deferred_thunk!(mode, f, args...)`: wraps function `Enzyme.autodiff_deferred_thunk`, calling it as `Enzyme.autodiff_deferred_thunk(mode, f, Const, args...)`, promoting all arguments of `args` and `f` that are not `Enzyme.Annotation` to `Enzyme.Const`. Important: the return type activity is automatically inserted as 3rd argument as it is always `Enzyme.Const`, given that `@parallel` and `@parallel_indices` functions must return nothing.
10
+
- `autodiff_deferred!`: wraps function `Enzyme.autodiff_deferred`, and supports the same arguments. Additionally, it promotes all arguments that are not `Enzyme.Annotation` to `Enzyme.Const` and automatically inserts the return type activity as 3rd argument if omitted; as a result, the function can be called also as, e.g., `autodiff_deferred!(Enzyme.Reverse, f!,...)`, besides the fully explicit form, e.g., `autodiff_deferred!(Enzyme.Reverse, Enzyme.Const(f!), Enzyme.Const,...)`.
11
+
- `autodiff_deferred_thunk!`: wraps function `Enzyme.autodiff_deferred_thunk`, and supports the same arguments. Additionally, it applies the same argument promotion and return type activity insertion as `autodiff_deferred!` (see above).
Copy file name to clipboardExpand all lines: src/ParallelKernel/EnzymeExt/AD.jl
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,8 @@ Provides GPU-compatible wrappers for automatic differentiation functions of the
7
7
import ParallelKernel.AD
8
8
9
9
# Functions
10
-
- `autodiff_deferred!(mode, f, args...)`: wraps function `Enzyme.autodiff_deferred`, calling it as `Enzyme.autodiff_deferred(mode, f, Const, args...)`, promoting all arguments of `args` and `f` that are not `Enzyme.Annotation` to `Enzyme.Const`. Important: the return type activity is automatically inserted as 3rd argument as it is always `Enzyme.Const`, given that `@parallel` and `@parallel_indices` functions must return nothing.
11
-
- `autodiff_deferred_thunk!(mode, f, args...)`: wraps function `Enzyme.autodiff_deferred_thunk`, calling it as `Enzyme.autodiff_deferred_thunk(mode, f, Const, args...)`, promoting all arguments of `args` and `f` that are not `Enzyme.Annotation` to `Enzyme.Const`. Important: the return type activity is automatically inserted as 3rd argument as it is always `Enzyme.Const`, given that `@parallel` and `@parallel_indices` functions must return nothing.
10
+
- `autodiff_deferred!`: wraps function `Enzyme.autodiff_deferred`, and supports the same arguments. Additionally, it promotes all arguments that are not `Enzyme.Annotation` to `Enzyme.Const` and automatically inserts the return type activity as 3rd argument if omitted; as a result, the function can be called also as, e.g., `autodiff_deferred!(Enzyme.Reverse, f!,...)`, besides the fully explicit form, e.g., `autodiff_deferred!(Enzyme.Reverse, Enzyme.Const(f!), Enzyme.Const,...)`.
11
+
- `autodiff_deferred_thunk!`: wraps function `Enzyme.autodiff_deferred_thunk`, and supports the same arguments. Additionally, it applies the same argument promotion and return type activity insertion as `autodiff_deferred!` (see above).
12
12
13
13
To see a description of a function type `?<functionname>`.
Copy file name to clipboardExpand all lines: src/ParallelKernel/EnzymeExt/autodiff_gpu.jl
+29-13Lines changed: 29 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -25,19 +25,35 @@ function promote_to_const(args::Vararg{Any,N}) where N
25
25
end
26
26
end
27
27
28
-
function ParallelStencil.ParallelKernel.AD.autodiff_deferred!(mode, f, args::Vararg{Any,N}) where N # NOTE: minimal specialization is required to avoid overwriting the default method
function ParallelStencil.ParallelKernel.AD.autodiff_deferred_thunk!(mode, f, args::Vararg{Any,N}) where N # NOTE: minimal specialization is required to avoid overwriting the default method
function ParallelStencil.ParallelKernel.AD.autodiff_deferred!(mode, f, ::Type{T}, args::Vararg{Any,N}) where {T<:Enzyme.Annotation, N} # NOTE: minimal specialization is required to avoid overwriting the default method
30
+
f =promote_to_const(f)[1]
31
+
args =promote_to_const(args...)
32
+
Enzyme.autodiff_deferred(mode, f, T, args...)
33
+
return
34
+
end
35
+
36
+
function ParallelStencil.ParallelKernel.AD.autodiff_deferred!(mode, f, args::Vararg{Any,N}) where N # NOTE: minimal specialization is required to avoid overwriting the default method
function ParallelStencil.ParallelKernel.AD.autodiff_deferred_thunk!(mode, f, ::Type{T}, args::Vararg{Any,N}) where {T<:Enzyme.Annotation, N} # NOTE: minimal specialization is required to avoid overwriting the default method
function ParallelStencil.ParallelKernel.AD.autodiff_deferred_thunk!(mode, f, args::Vararg{Any,N}) where N # NOTE: minimal specialization is required to avoid overwriting the default method
@parallel configcall=f!(A, B, a) AD.autodiff_deferred!(Enzyme.Reverse, f!, DuplicatedNoNeed(A, Ā), DuplicatedNoNeed(B, B̄), Const(a)) # NOTE: f! is automatically promoted to Const(f!) and the return type Const is inserted.
139
+
@testArray(Ā) ≈ Ā_ref
140
+
@testArray(B̄) ≈ B̄_ref
141
+
Ā =@ones(N)
142
+
B̄ =@ones(N)
143
+
@parallel configcall=f!(A, B, a) AD.autodiff_deferred!(Enzyme.Reverse, f!, Const, DuplicatedNoNeed(A, Ā), DuplicatedNoNeed(B, B̄), Const(a)) # NOTE: f! is automatically promoted to Const(f!)
144
+
@testArray(Ā) ≈ Ā_ref
145
+
@testArray(B̄) ≈ B̄_ref
146
+
Ā =@ones(N)
147
+
B̄ =@ones(N)
148
+
@parallel configcall=f!(A, B, a) AD.autodiff_deferred!(Enzyme.Reverse, Const(f!), Const, DuplicatedNoNeed(A, Ā), DuplicatedNoNeed(B, B̄), Const(a)) # NOTE: no automatic promotion or insertion here.
149
+
@testArray(Ā) ≈ Ā_ref
150
+
@testArray(B̄) ≈ B̄_ref
151
+
end;
152
+
@testset"@parallel ∇ (numerical)"begin
153
+
Ā =@ones(N)
154
+
B̄ =@ones(N)
155
+
@parallel ∇=(A->Ā, B->B̄) f!(A, B, a) # NOTE: expands to the same as above
println("Test Error: an exception occurred while running the test file $f :")
60
+
println("Test Abort: a system-level exception occurred while running the test file $f :")
59
61
println(ex)
62
+
nabort +=1
63
+
push!(abortfiles, f)
64
+
continue
60
65
finally
61
66
ifispath(stdout_path)
62
67
rm(stdout_path; force=true)
@@ -66,21 +71,32 @@ function runtests(testfiles=String[])
66
71
end
67
72
end
68
73
if!occursin(r"(?i)test summary", stdout_content)
69
-
nerror +=1
70
-
push!(errorfiles, f)
74
+
nabort +=1
75
+
push!(abortfiles, f)
76
+
elseif proc !==nothing&&!success(proc)
77
+
nfail +=1
78
+
push!(failfiles, f)
71
79
end
72
80
end
73
81
println("")
74
-
ifnerror==0
75
-
printstyled("Test suite: all selected test files executed (see above for results).\n"; bold=true, color=:green)
82
+
ifnabort ==0&& nfail==0
83
+
printstyled("Test suite: all selected test files executed and all tests passed.\n"; bold=true, color=:green)
76
84
else
77
-
printstyled("Test suite: $nerror test file(s) aborted execution due to error (see above for details); files aborting execution:\n"; bold=true, color=:red)
78
-
for f in errorfiles
79
-
println(" - $f")
85
+
if nfail >0
86
+
printstyled("Test suite: $nfail test files(s) have tests that failed or errored (see above for results); files with failed/errored tests:\n"; bold=true, color=:red)
87
+
for f in failfiles
88
+
println(" - $f")
89
+
end
90
+
end
91
+
if nabort >0
92
+
printstyled("Test suite: $nabort test file(s) aborted execution due to fatal error (see above for details); files aborting execution:\n"; bold=true, color=:red)
0 commit comments