Skip to content

Commit 5a141fe

Browse files
authored
Support using a local compiler through CUDA_Runtime_Discovery (#3080)
1 parent 831c29b commit 5a141fe

16 files changed

Lines changed: 32 additions & 20 deletions

File tree

CUDACore/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ BFloat16s = "0.5, 0.6"
4545
CEnum = "0.2, 0.3, 0.4, 0.5"
4646
CUDA_Compiler_jll = "0.3, 0.4"
4747
CUDA_Driver_jll = "13"
48-
CUDA_Runtime_Discovery = "1"
48+
CUDA_Runtime_Discovery = "2"
4949
CUDA_Runtime_jll = "0.21"
5050
ChainRulesCore = "1"
5151
EnzymeCore = "0.8.2"

CUDACore/lib/cudadrv/version.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ other tools. This is version separately from the CUDA Runtime, in order to ensur
100100
compatibility with the driver, and make sure we use the latest compatible version regardless
101101
of the selected runtime.
102102
"""
103-
compiler_version() = CUDA_Compiler_jll.cuda_version
103+
compiler_version() = CUDA_Compiler.cuda_version
104104

105105

106106
## helpers

CUDACore/src/CUDACore.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ using LLVMLoopInfo
3131

3232
using CUDA_Driver_jll
3333

34-
using CUDA_Compiler_jll
35-
3634
import CUDA_Runtime_jll
3735
const local_toolkit = CUDA_Runtime_jll.host_platform["cuda_local"] == "true"
3836
if local_toolkit
@@ -44,6 +42,15 @@ else
4442
end
4543

4644
import Preferences
45+
const local_compiler = Preferences.@load_preference("local_compiler", "false") == "true"
46+
47+
if local_compiler
48+
using CUDA_Runtime_Discovery
49+
const CUDA_Compiler = CUDA_Runtime_Discovery
50+
else
51+
import CUDA_Compiler_jll
52+
const CUDA_Compiler = CUDA_Compiler_jll
53+
end
4754

4855
using Libdl
4956

CUDACore/src/compiler/compilation.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function GPUCompiler.link_libraries!(@nospecialize(job::CUDACompilerJob), mod::L
3232
return
3333
end
3434

35-
lib = parse(LLVM.Module, read(libdevice))
35+
lib = parse(LLVM.Module, read(CUDA_Compiler.libdevice))
3636

3737
# override libdevice's triple and datalayout to avoid warnings
3838
triple!(lib, triple(mod))
@@ -339,7 +339,7 @@ function compile(@nospecialize(job::CompilerJob))
339339
"--output-file", ptxas_output,
340340
ptx_input
341341
])
342-
proc, log = run_and_collect(`$(ptxas()) $ptxas_opts`)
342+
proc, log = run_and_collect(`$(CUDA_Compiler.ptxas()) $ptxas_opts`)
343343
log = strip(log)
344344
if !success(proc)
345345
reason = proc.termsignal > 0 ? "ptxas received signal $(proc.termsignal)" :
@@ -370,12 +370,12 @@ function compile(@nospecialize(job::CompilerJob))
370370
append!(nvlink_opts, [
371371
"--verbose", "--extra-warnings",
372372
"--arch", arch,
373-
"--library-path", dirname(libcudadevrt),
373+
"--library-path", dirname(CUDA_Compiler.libcudadevrt),
374374
"--library", "cudadevrt",
375375
"--output-file", nvlink_output,
376376
ptxas_output
377377
])
378-
proc, log = run_and_collect(`$(nvlink()) $nvlink_opts`)
378+
proc, log = run_and_collect(`$(CUDA_Compiler.nvlink()) $nvlink_opts`)
379379
log = strip(log)
380380
if !success(proc)
381381
reason = proc.termsignal > 0 ? "nvlink received signal $(proc.termsignal)" :

CUDATools/src/reflection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function disassemble_cubin(io::IO, cubin::Vector{Cchar}; raw::Bool)
126126
write(cubin_io, cubin)
127127
flush(cubin_io)
128128

129-
cmd = `$(CUDA_Compiler_jll.nvdisasm()) --print-code --print-line-info $cubin_path`
129+
cmd = `$(CUDACore.CUDA_Compiler.nvdisasm()) --print-code --print-line-info $cubin_path`
130130
for line in readlines(cmd)
131131
if !raw
132132
# nvdisasm output is pretty verbose;

CUDATools/src/utilities.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ function versioninfo(io::IO=stdout)
2121
print(io, "- unknown driver")
2222
end
2323
println(io, " for $(driver_version().major).$(driver_version().minor)")
24-
println(io, "- compiler $(compiler_version().major).$(compiler_version().minor)")
24+
print(io, "- compiler $(compiler_version().major).$(compiler_version().minor), ")
25+
if CUDACore.local_compiler
26+
println(io, "local installation")
27+
else
28+
println(io, "artifact installation")
29+
end
2530
println(io)
2631

2732
println(io, "CUDA libraries: ")

lib/cublas/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Adapt = "4.4"
2929
BFloat16s = "0.5, 0.6"
3030
CEnum = "0.2, 0.3, 0.4, 0.5"
3131
CUDACore = "=6.0.0"
32-
CUDA_Runtime_Discovery = "1"
32+
CUDA_Runtime_Discovery = "2"
3333
CUDA_Runtime_jll = "0.21"
3434
EnzymeCore = "0.8.2"
3535
GPUArrays = "11.4.1"

lib/cudnn/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ CUDNN_jll = "62b44479-cb7b-5706-934f-f13b2eb2e645"
1515
[compat]
1616
CEnum = "0.2, 0.3, 0.4, 0.5"
1717
CUDACore = "=6.0.0"
18-
CUDA_Runtime_Discovery = "0.2, 0.3, 1"
18+
CUDA_Runtime_Discovery = "2"
1919
CUDNN_jll = "9.20"
2020
julia = "1.10"

lib/cufft/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2020
AbstractFFTs = "0.5, 1.0"
2121
CEnum = "0.2, 0.3, 0.4, 0.5"
2222
CUDACore = "=6.0.0"
23-
CUDA_Runtime_Discovery = "1"
23+
CUDA_Runtime_Discovery = "2"
2424
CUDA_Runtime_jll = "0.21"
2525
GPUToolbox = "0.3, 1"
2626
LinearAlgebra = "1"

lib/cupti/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ GPUToolbox = "096a3bc2-3ced-46d0-87f4-dd12716f4bfc"
1313
[compat]
1414
CEnum = "0.2, 0.3, 0.4, 0.5"
1515
CUDACore = "=6.0.0"
16-
CUDA_Runtime_Discovery = "1"
16+
CUDA_Runtime_Discovery = "2"
1717
CUDA_Runtime_jll = "0.21"
1818
GPUToolbox = "1.1"
1919
julia = "1.10"

0 commit comments

Comments
 (0)