Skip to content

Commit e561e7a

Browse files
authored
Separately version the CUDA compiler (#2801)
1 parent fb0a528 commit e561e7a

File tree

7 files changed

+38
-27
lines changed

7 files changed

+38
-27
lines changed

Project.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
88
BFloat16s = "ab4f0b2a-ad5b-11e8-123f-65d77653426b"
99
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
10+
CUDA_Compiler_jll = "d1e2174e-dfdc-576e-b43e-73b79eb1aca8"
1011
CUDA_Driver_jll = "4ee394cb-3365-5eb0-8335-949819d2adfc"
1112
CUDA_Runtime_Discovery = "1af6417a-86b4-443c-805f-a4643ffb695f"
1213
CUDA_Runtime_jll = "76a88914-d11a-5bdc-97e0-2f5a05c973a2"
@@ -40,23 +41,24 @@ demumble_jll = "1e29f10c-031c-5a83-9565-69cddfc27673"
4041
[weakdeps]
4142
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
4243
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"
43-
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
4444
SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
45+
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
4546

4647
[extensions]
4748
ChainRulesCoreExt = "ChainRulesCore"
4849
EnzymeCoreExt = "EnzymeCore"
49-
SpecialFunctionsExt = "SpecialFunctions"
5050
SparseMatricesCSRExt = "SparseMatricesCSR"
51+
SpecialFunctionsExt = "SpecialFunctions"
5152

5253
[compat]
5354
AbstractFFTs = "0.4, 0.5, 1.0"
5455
Adapt = "4"
5556
BFloat16s = "0.2, 0.3, 0.4, 0.5"
5657
CEnum = "0.2, 0.3, 0.4, 0.5"
57-
CUDA_Driver_jll = "0.13"
58-
CUDA_Runtime_Discovery = "0.3.3"
59-
CUDA_Runtime_jll = "0.17"
58+
CUDA_Compiler_jll = "0.1.0"
59+
CUDA_Driver_jll = "12"
60+
CUDA_Runtime_Discovery = "1"
61+
CUDA_Runtime_jll = "0.18"
6062
ChainRulesCore = "1"
6163
Crayons = "4"
6264
DataFrames = "1"
@@ -92,5 +94,5 @@ julia = "1.10"
9294
[extras]
9395
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
9496
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"
95-
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
9697
SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
98+
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"

lib/cudadrv/state.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,6 @@ function context(dev::CuDevice)
239239
maxlog=1, _id=devidx)
240240
end
241241

242-
# warn about some known bugs
243-
if runtime_version() < v"11.5" && capability(dev) < v"7"
244-
@warn("""There are known codegen bugs on CUDA 11.4 and earlier for older GPUs like your $(name(dev)).
245-
Please use CUDA 11.5 or later, or switch to a different device.""",
246-
maxlog=1, _id=devidx)
247-
end
248-
249242
# configure the primary context
250243
pctx = CuPrimaryContext(dev)
251244
ctx = CuContext(pctx)

lib/cudadrv/version.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ function reset_runtime_version!()
9090
@info "Reset CUDA.jl toolkit preference, please re-start Julia for this to take effect."
9191
end
9292

93+
"""
94+
compiler_version()
95+
96+
Returns the CUDA toolkit version that is used to provide the CUDA compiler (`ptxas`) and
97+
other tools. This is version separately from the CUDA Runtime, in order to ensure
98+
compatibility with the driver, and make sure we use the latest compatible version regardless
99+
of the selected runtime.
100+
"""
101+
compiler_version() = CUDA_Compiler_jll.cuda_version
102+
93103

94104
## helpers
95105

src/CUDA.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ using LLVMLoopInfo
2424

2525
using CUDA_Driver_jll
2626

27+
using CUDA_Compiler_jll
28+
2729
import CUDA_Runtime_jll
2830
const local_toolkit = CUDA_Runtime_jll.host_platform["cuda_local"] == "true"
2931
const toolkit_version = if CUDA_Runtime_jll.host_platform["cuda"] == "none"

src/compatibility.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ const cuda_cap_db = Dict(
5656
v"8.7" => between(v"11.4", highest),
5757
v"8.9" => between(v"11.8", highest),
5858
v"9.0" => between(v"11.8", highest),
59-
v"12.0" => between(v"12.8", highest),
60-
v"12.1" => between(v"12.9", highest),
59+
v"12.0" => between(v"12.8", highest),
60+
v"12.1" => between(v"12.9", highest),
6161
)
6262

6363
function cuda_cap_support(ver::VersionNumber)
@@ -293,14 +293,15 @@ function llvm_compat(version=LLVM.version())
293293
return (cap=cap_support, ptx=ptx_support)
294294
end
295295

296-
function cuda_compat(driver=driver_version(), runtime=runtime_version())
296+
function cuda_compat(driver=driver_version(), compiler=compiler_version())
297+
# devices have to be supported by both the compiler and the driver
297298
driver_cap_support = cuda_cap_support(driver)
298-
toolkit_cap_support = cuda_cap_support(runtime)
299-
cap_support = sort(collect(driver_cap_support toolkit_cap_support))
299+
compiler_cap_support = cuda_cap_support(compiler)
300+
cap_support = sort(collect(driver_cap_support compiler_cap_support))
300301

301-
driver_ptx_support = cuda_ptx_support(driver)
302-
toolkit_ptx_support = cuda_ptx_support(runtime)
303-
ptx_support = sort(collect(driver_ptx_support toolkit_ptx_support))
302+
# PTX code only has to be supported by the compiler
303+
compiler_ptx_support = cuda_ptx_support(compiler)
304+
ptx_support = cuda_ptx_support(compiler)
304305

305306
return (cap=cap_support, ptx=ptx_support)
306307
end

src/compiler/compilation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function GPUCompiler.mcgen(@nospecialize(job::CUDACompilerJob), mod::LLVM.Module
137137
# only emitting `.loc` instructions...
138138
#
139139
# according to NVIDIA, "it is fine for PTX producers to produce debug info but not
140-
# set `.target debug` and if `--device-debug` isn't passed, PTXAS will compile in
140+
# set `.target debug` and if `--device-debug` isn't passed, ptxas will compile in
141141
# release mode".
142142
asm = replace(asm, r"(\.target .+), debug" => s"\1")
143143
end

src/utilities.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,21 @@ end
4141
function versioninfo(io::IO=stdout)
4242
@assert functional(true)
4343

44-
print(io, "CUDA runtime $(runtime_version().major).$(runtime_version().minor), ")
44+
println(io, "CUDA toolchain: ")
45+
46+
print(io, "- runtime $(runtime_version().major).$(runtime_version().minor), ")
4547
if local_toolkit
4648
println(io, "local installation")
4749
else
4850
println(io, "artifact installation")
4951
end
50-
println(io, "CUDA driver $(driver_version().major).$(driver_version().minor)")
5152
if has_nvml()
52-
println(io, "NVIDIA driver $(NVML.driver_version())")
53+
print(io, "- driver $(NVML.driver_version())")
5354
else
54-
println(io, "Unknown NVIDIA driver")
55+
print(io, "- unknown driver")
5556
end
57+
println(io, " for $(driver_version().major).$(driver_version().minor)")
58+
println(io, "- compiler $(compiler_version().major).$(compiler_version().minor)")
5659
println(io)
5760

5861
println(io, "CUDA libraries: ")
@@ -66,7 +69,7 @@ function versioninfo(io::IO=stdout)
6669

6770
println(io, "Julia packages: ")
6871
println(io, "- CUDA: $(Base.pkgversion(CUDA))")
69-
for name in [:CUDA_Driver_jll, :CUDA_Runtime_jll, :CUDA_Runtime_Discovery]
72+
for name in [:CUDA_Driver_jll, :CUDA_Compiler_jll, :CUDA_Runtime_jll, :CUDA_Runtime_Discovery]
7073
isdefined(CUDA, name) || continue
7174
mod = getfield(CUDA, name)
7275
println(io, "- $(name): $(Base.pkgversion(mod))")

0 commit comments

Comments
 (0)