Skip to content

Commit 1e1f4ef

Browse files
authored
Use at-consistent_overlay for 1.11 compatibility. (#2492)
1 parent 991e23a commit 1e1f4ef

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/device/utils.jl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@ end
1515

1616
macro device_override(ex)
1717
ex = macroexpand(__module__, ex)
18-
esc(quote
19-
Base.Experimental.@overlay(CUDA.method_table, $ex)
20-
end)
18+
if VERSION >= v"1.12.0-DEV.745" || v"1.11-rc1" <= VERSION < v"1.12-"
19+
# this requires that the overlay method f′ is consistent with f, i.e.,
20+
# - if f(x) returns a value, f′(x) must return the identical value.
21+
# - if f(x) throws an exception, f′(x) must also throw an exception
22+
# (although the exceptions do not need to be identical).
23+
esc(quote
24+
Base.Experimental.@consistent_overlay(CUDA.method_table, $ex)
25+
end)
26+
else
27+
esc(quote
28+
Base.Experimental.@overlay(CUDA.method_table, $ex)
29+
end)
30+
end
2131
end
2232

2333
macro device_function(ex)
@@ -31,7 +41,9 @@ macro device_function(ex)
3141

3242
esc(quote
3343
$(combinedef(def))
34-
@device_override $ex
44+
45+
# NOTE: no use of `@consistent_overlay` here because the regular function errors
46+
Base.Experimental.@overlay(CUDA.method_table, $ex)
3547
end)
3648
end
3749

0 commit comments

Comments
 (0)