Skip to content

Commit 99a57d0

Browse files
committed
Fixes for 1.10.
1 parent fa56acd commit 99a57d0

4 files changed

Lines changed: 35 additions & 9 deletions

File tree

CUDACore/src/utils/public.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ function _public_symbols(e::Expr)
1111
[_public_symbol(e)]
1212
end
1313
end
14+
15+
# Track public names so they can be discovered on Julia < 1.11
16+
const PUBLIC_NAMES = Symbol[]
17+
1418
macro public(symbols_expr)
19+
syms = _public_symbols(symbols_expr)
20+
append!(PUBLIC_NAMES, syms)
1521
if VERSION >= v"1.11.0-DEV.469"
16-
esc(Expr(:public, _public_symbols(symbols_expr)...))
22+
esc(Expr(:public, syms...))
23+
else
24+
nothing
1725
end
1826
end
1927
export @public

src/CUDA.jl

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,30 @@ using Reexport
66
@reexport using CUDACore
77

88
# Forward public names from CUDACore so CUDA.xyz works (exported names handled by @reexport)
9-
for n in names(CUDACore)
10-
Base.isexported(CUDACore, n) && continue
11-
n === :CUDACore && continue
12-
isdefined(CUDACore, n) || continue
13-
@eval using CUDACore: $n
14-
@eval $(Expr(:public, n))
9+
if VERSION >= v"1.11.0-DEV.469"
10+
# On 1.11+, `names` returns public names, so we can forward just those
11+
for n in names(CUDACore)
12+
Base.isexported(CUDACore, n) && continue
13+
n === :CUDACore && continue
14+
isdefined(CUDACore, n) || continue
15+
@eval using CUDACore: $n
16+
@eval $(Expr(:public, n))
17+
end
18+
else
19+
# On 1.10, there's no `public` keyword. Use PUBLIC_NAMES for names registered
20+
# by @public, and scan names(; all=true) for public enum values created by
21+
# @enum_without_prefix (which bypasses @public but creates const bindings).
22+
public_names = Set{Symbol}(CUDACore.PUBLIC_NAMES)
23+
for n in names(CUDACore; all=true)
24+
isdefined(CUDACore, n) || continue
25+
val = try getfield(CUDACore, n) catch; continue end
26+
val isa CUDACore.CEnum.Cenum && Symbol(val) !== n && push!(public_names, n)
27+
end
28+
for n in public_names
29+
Base.isexported(CUDACore, n) && continue
30+
isdefined(CUDACore, n) || continue
31+
@eval using CUDACore: $n
32+
end
1533
end
1634

1735
# Load math libraries so their methods (matmul, rand, etc.) are available

test/core/device/intrinsics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@on_device blockIdx().z
1515
@on_device gridDim().z
1616

17-
if capability(device()) >= v"9.0"
17+
if capability(device()) >= v"9.0" && VERSION >= v"1.11-"
1818
@on_device clusterIdx().x
1919
@on_device clusterIdx().y
2020
@on_device clusterIdx().z

test/core/device/intrinsics/clusters.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@testset "thread block clusters" begin
2-
if capability(device()) >= v"9.0"
2+
if capability(device()) >= v"9.0" && VERSION >= v"1.11-"
33

44
###########################################################################################
55

0 commit comments

Comments
 (0)