diff --git a/CUDACore/Project.toml b/CUDACore/Project.toml index 5072209b66..6b3ab8903c 100644 --- a/CUDACore/Project.toml +++ b/CUDACore/Project.toml @@ -27,6 +27,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Random123 = "74087812-796a-5b5d-8853-05524746bad3" RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143" +Republic = "27243419-9dde-4721-b67c-fd63626fea7f" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [weakdeps] @@ -66,6 +67,7 @@ Printf = "1" Random = "1" Random123 = "1.2" RandomNumbers = "1.5.3" +Republic = "2" SpecialFunctions = "1.3, 2" StaticArrays = "1.9.8" julia = "1.10" diff --git a/CUDACore/src/CUDACore.jl b/CUDACore/src/CUDACore.jl index 94bb4d8e95..3aec01567d 100644 --- a/CUDACore/src/CUDACore.jl +++ b/CUDACore/src/CUDACore.jl @@ -1,6 +1,7 @@ module CUDACore -include("utils/public.jl") +using Republic: @public +export @public using GPUCompiler using GPUCompiler: InvalidIRError, KernelError diff --git a/CUDACore/src/utils/public.jl b/CUDACore/src/utils/public.jl deleted file mode 100644 index ee5e24427d..0000000000 --- a/CUDACore/src/utils/public.jl +++ /dev/null @@ -1,27 +0,0 @@ -# public keyword support for Julia < 1.11 - -_public_symbol(s::Symbol) = s -_public_symbol(e::Expr) = e.args[1] # macrocall: @foo → :@foo -_public_symbols(s::Symbol) = [s] -function _public_symbols(e::Expr) - if e.head == :tuple - Symbol[_public_symbol(a) for a in e.args] - else - # single macrocall like @foo - [_public_symbol(e)] - end -end - -# Track public names so they can be discovered on Julia < 1.11 -const PUBLIC_NAMES = Symbol[] - -macro public(symbols_expr) - syms = _public_symbols(symbols_expr) - append!(PUBLIC_NAMES, syms) - if VERSION >= v"1.11.0-DEV.469" - esc(Expr(:public, syms...)) - else - nothing - end -end -export @public diff --git a/CUDATools/Project.toml b/CUDATools/Project.toml index a8ef8aad4d..0ac2ba5859 100644 --- a/CUDATools/Project.toml +++ b/CUDATools/Project.toml @@ -16,6 +16,7 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Preferences = "21216c6a-2e73-6563-6e65-726566657250" PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" +Republic = "27243419-9dde-4721-b67c-fd63626fea7f" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" demumble_jll = "1e29f10c-031c-5a83-9565-69cddfc27673" @@ -36,6 +37,7 @@ PrecompileTools = "1" Preferences = "1" PrettyTables = "3" Printf = "1" +Republic = "2" Statistics = "1" demumble_jll = "1.3" julia = "1.10" diff --git a/CUDATools/src/CUDATools.jl b/CUDATools/src/CUDATools.jl index 3541a82d97..db43ef070e 100644 --- a/CUDATools/src/CUDATools.jl +++ b/CUDATools/src/CUDATools.jl @@ -2,22 +2,7 @@ module CUDATools using CUDACore -# Define our own PUBLIC_NAMES for the Julia 1.10 fallback path in the CUDA.jl shim. -# Mirrors CUDACore's @public but keeps a separate registry (and doesn't export @public). -const PUBLIC_NAMES = Symbol[] -_public_sym(s::Symbol) = s -_public_sym(e::Expr) = e.args[1] # macrocall: @foo → :@foo -macro public(symbols_expr) - syms = symbols_expr isa Symbol ? [symbols_expr] : - symbols_expr.head == :tuple ? Symbol[_public_sym(a) for a in symbols_expr.args] : - [_public_sym(symbols_expr)] - append!(PUBLIC_NAMES, syms) - if VERSION >= v"1.11.0-DEV.469" - esc(Expr(:public, syms...)) - else - nothing - end -end +using Republic: @public using GPUCompiler using GPUCompiler: CompilerJob, methodinstance diff --git a/Project.toml b/Project.toml index c84229764e..fc3be09a5c 100644 --- a/Project.toml +++ b/Project.toml @@ -13,7 +13,7 @@ projects = ["test", "docs", "perf", "examples", [deps] CUDACore = "bd0ed864-bdfe-4181-a5ed-ce625a5fdea2" CUDATools = "9ec180c6-1c07-47c7-9e6e-ebefa4d1f6d0" -Reexport = "189a3867-3050-52da-a836-e630ba90ab69" +Republic = "27243419-9dde-4721-b67c-fd63626fea7f" cuBLAS = "182d3088-87b7-4494-8cad-fc6afaa545bc" cuFFT = "533571aa-0936-420e-b4be-9c66f5f626ca" cuRAND = "20fd9a0b-12d5-4c2f-a8af-7c34e9e60431" @@ -35,7 +35,7 @@ CUDA_Runtime_jll = "76a88914-d11a-5bdc-97e0-2f5a05c973a2" [compat] CUDACore = "=6.0.0" CUDATools = "=6.0.0" -Reexport = "1.0" +Republic = "2.1" cuBLAS = "=6.0.0" cuFFT = "=6.0.0" cuRAND = "=6.0.0" diff --git a/lib/cufft/Project.toml b/lib/cufft/Project.toml index 82e4a46871..6c189481de 100644 --- a/lib/cufft/Project.toml +++ b/lib/cufft/Project.toml @@ -14,7 +14,7 @@ CUDA_Runtime_Discovery = "1af6417a-86b4-443c-805f-a4643ffb695f" CUDA_Runtime_jll = "76a88914-d11a-5bdc-97e0-2f5a05c973a2" GPUToolbox = "096a3bc2-3ced-46d0-87f4-dd12716f4bfc" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Reexport = "189a3867-3050-52da-a836-e630ba90ab69" +Republic = "27243419-9dde-4721-b67c-fd63626fea7f" [compat] AbstractFFTs = "0.5, 1.0" @@ -24,5 +24,5 @@ CUDA_Runtime_Discovery = "1" CUDA_Runtime_jll = "0.21" GPUToolbox = "0.3, 1" LinearAlgebra = "1" -Reexport = "1.0" +Republic = "2.1" julia = "1.10" diff --git a/lib/cufft/src/cuFFT.jl b/lib/cufft/src/cuFFT.jl index 0c21b59a36..e860726b1f 100644 --- a/lib/cufft/src/cuFFT.jl +++ b/lib/cufft/src/cuFFT.jl @@ -7,7 +7,7 @@ using CUDACore: unsafe_free!, retry_reclaim, initialize_context using CEnum: @cenum -using Reexport: @reexport +using Republic if CUDACore.local_toolkit using CUDA_Runtime_Discovery diff --git a/src/CUDA.jl b/src/CUDA.jl index 853287e123..46489efd24 100644 --- a/src/CUDA.jl +++ b/src/CUDA.jl @@ -1,42 +1,11 @@ module CUDA +using Republic -using Reexport - -@reexport using CUDACore -@reexport using CUDATools - -# Forward public names so CUDA.xyz works (exported names handled by @reexport) -if VERSION >= v"1.11.0-DEV.469" - # On 1.11+, `names` returns public names, so we can forward just those - for mod in (CUDACore, CUDATools) - modname = nameof(mod) - for n in names(mod) - Base.isexported(mod, n) && continue - n === modname && continue - isdefined(mod, n) || continue - @eval using $modname: $n - @eval $(Expr(:public, n)) - end - end -else - # On 1.10, there's no `public` keyword. Use PUBLIC_NAMES for names registered - # by @public, and scan names(; all=true) for public enum values created by - # @enum_without_prefix (which bypasses @public but creates const bindings). - for mod in (CUDACore, CUDATools) - modname = nameof(mod) - public_names = Set{Symbol}(mod.PUBLIC_NAMES) - for n in names(mod; all=true) - isdefined(mod, n) || continue - val = try getfield(mod, n) catch; continue end - val isa CUDACore.CEnum.Cenum && Symbol(val) !== n && push!(public_names, n) - end - for n in public_names - Base.isexported(mod, n) && continue - isdefined(mod, n) || continue - @eval using $modname: $n - end - end +# Re-export exported names and re-public public names (bringing them into CUDA) +@reexport inherit=true begin + using CUDACore + using CUDATools end # Load math libraries so their methods (matmul, rand, etc.) are available