|
1 | 1 | using Base.BinaryPlatforms
|
2 | 2 |
|
3 |
| -const Reactant_UUID = Base.UUID("3c362404-f566-11ee-1572-e11a4b42c853") |
| 3 | +const Reactant_UUID = Base.UUID("0192cb87-2b54-54ad-80e0-3be72ad8a3c0") |
4 | 4 | const preferences = Base.get_preferences(Reactant_UUID)
|
5 |
| - |
6 |
| -module __CUDA |
7 |
| - using Base.BinaryPlatforms |
8 |
| - |
9 |
| -try |
10 |
| - using CUDA_Runtime_jll |
11 |
| -catch |
12 |
| - # during initial package installation, CUDA_Runtime_jll may not be available. |
13 |
| - # in that case, we just won't select an artifact. |
14 |
| -end |
15 |
| - |
16 |
| -# can't use Preferences for the same reason |
17 |
| -const CUDA_Runtime_jll_uuid = Base.UUID("76a88914-d11a-5bdc-97e0-2f5a05c973a2") |
18 |
| -const preferences = Base.get_preferences(CUDA_Runtime_jll_uuid) |
19 |
| -Base.record_compiletime_preference(CUDA_Runtime_jll_uuid, "version") |
20 |
| -Base.record_compiletime_preference(CUDA_Runtime_jll_uuid, "local") |
21 |
| -const local_toolkit = something(tryparse(Bool, get(preferences, "local", "false")), false) |
22 |
| - |
23 |
| -function cuda_comparison_strategy(_a::String, _b::String, a_requested::Bool, b_requested::Bool) |
24 |
| - # if we're using a local toolkit, we can't use artifacts |
25 |
| - if local_toolkit |
26 |
| - return false |
27 |
| - end |
28 |
| - |
29 |
| - # if either isn't a version number (e.g. "none"), perform a simple equality check |
30 |
| - a = tryparse(VersionNumber, _a) |
31 |
| - b = tryparse(VersionNumber, _b) |
32 |
| - if a === nothing || b === nothing |
33 |
| - return _a == _b |
34 |
| - end |
35 |
| - |
36 |
| - # if both b and a requested, then we fall back to equality |
37 |
| - if a_requested && b_requested |
38 |
| - return Base.thisminor(a) == Base.thisminor(b) |
39 |
| - end |
40 |
| - |
41 |
| - # otherwise, do the comparison between the the single version cap and the single version: |
42 |
| - function is_compatible(artifact::VersionNumber, host::VersionNumber) |
43 |
| - if host >= v"11.0" |
44 |
| - # enhanced compatibility, semver-style |
45 |
| - artifact.major == host.major && |
46 |
| - Base.thisminor(artifact) <= Base.thisminor(host) |
47 |
| - else |
48 |
| - Base.thisminor(artifact) == Base.thisminor(host) |
49 |
| - end |
50 |
| - end |
51 |
| - if a_requested |
52 |
| - is_compatible(b, a) |
| 5 | +Base.record_compiletime_preference(Reactant_UUID, "mode") |
| 6 | +const mode_preference = if haskey(preferences, "mode") |
| 7 | + if isa(preferences["mode"], String) && preferences["mode"] in ["opt", "dbg"] |
| 8 | + preferences["mode"] |
53 | 9 | else
|
54 |
| - is_compatible(a, b) |
| 10 | + @error "Mode preference is not valid; expected 'opt' or 'dbg', but got '$(preferences["debug"])'" |
| 11 | + nothing |
55 | 12 | end
|
| 13 | +else |
| 14 | + nothing |
56 | 15 | end
|
57 | 16 |
|
58 |
| -function augment_platform!(platform::Platform) |
59 |
| - if !@isdefined(CUDA_Runtime_jll) |
60 |
| - # don't set to nothing or Pkg will download any artifact |
61 |
| - platform["cuda"] = "none" |
62 |
| - end |
63 |
| - |
64 |
| - if !haskey(platform, "cuda") |
65 |
| - CUDA_Runtime_jll.augment_platform!(platform) |
66 |
| - end |
67 |
| - BinaryPlatforms.set_compare_strategy!(platform, "cuda", cuda_comparison_strategy) |
68 |
| - |
69 |
| - return platform |
70 |
| -end |
| 17 | +module __CUDA |
| 18 | + $(CUDA.augment::String) |
71 | 19 | end
|
72 | 20 |
|
73 | 21 | function augment_platform!(platform::Platform)
|
74 | 22 | __CUDA.augment_platform!(platform)
|
75 | 23 |
|
76 |
| - mode = get(ENV, "REACTANT_MODE", get(preferences, "mode", "opt")) |
| 24 | + mode = get(ENV, "REACTANT_MODE", something(mode_preference, "opt")) |
77 | 25 | if !haskey(platform, "mode")
|
78 | 26 | platform["mode"] = mode
|
79 | 27 | end
|
|
0 commit comments