Skip to content

Commit

Permalink
Use at-consistent_overlay for 1.11 compatibility. (JuliaGPU#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt authored and amontoison committed Sep 18, 2024
1 parent 41a5603 commit ec70c06
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/device/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,19 @@ end

macro device_override(ex)
ex = macroexpand(__module__, ex)
esc(quote
Base.Experimental.@overlay(CUDA.method_table, $ex)
end)
if VERSION >= v"1.12.0-DEV.745" || v"1.11-rc1" <= VERSION < v"1.12-"
# this requires that the overlay method f′ is consistent with f, i.e.,
# - if f(x) returns a value, f′(x) must return the identical value.
# - if f(x) throws an exception, f′(x) must also throw an exception
# (although the exceptions do not need to be identical).
esc(quote
Base.Experimental.@consistent_overlay(CUDA.method_table, $ex)
end)
else
esc(quote
Base.Experimental.@overlay(CUDA.method_table, $ex)
end)
end
end

macro device_function(ex)
Expand All @@ -31,7 +41,9 @@ macro device_function(ex)

esc(quote
$(combinedef(def))
@device_override $ex

# NOTE: no use of `@consistent_overlay` here because the regular function errors
Base.Experimental.@overlay(CUDA.method_table, $ex)
end)
end

Expand Down

0 comments on commit ec70c06

Please sign in to comment.