@@ -6,56 +6,14 @@ using Libdl
6
6
7
7
include (" utils.jl" )
8
8
9
- """
10
- use_artifacts!(flag::Bool = true)
11
-
12
- Pass `true` to switch from system-wide ROCm installtion to artifacts.
13
- When using artifacts, system-wide installation is not needed at all.
14
- """
15
- function use_artifacts! (flag:: Bool = true ; show_message:: Bool = true )
16
- if flag && Base. libllvm_version >= v " 16"
17
- error (" No supported artifacts for LLVM 16+. See: https://github.com/JuliaGPU/AMDGPU.jl/issues/440." )
18
- end
19
- @set_preferences! (" use_artifacts" => flag)
20
- if show_message
21
- @info """
22
- Switched `use_artifacts` to `$flag `.
23
- Restart Julia session for the changes to take effect.
24
- """
25
- end
26
- end
27
-
28
- use_artifacts ():: Bool = @load_preference (" use_artifacts" , false )
29
-
30
- @static if use_artifacts ()
31
- import hsa_rocr_jll
32
- end
33
-
34
- if haskey (ENV , " JULIA_AMDGPU_DISABLE_ARTIFACTS" )
35
- disable_artifacts = parse (Bool, get (ENV , " JULIA_AMDGPU_DISABLE_ARTIFACTS" , " true" ))
36
- if ! disable_artifacts && Base. libllvm_version >= v " 16"
37
- error (" No supported artifacts for LLVM 16+. See: https://github.com/JuliaGPU/AMDGPU.jl/issues/440." )
38
- end
39
- use_artifacts! (! disable_artifacts; show_message= false )
40
- end
41
-
42
9
function get_artifact_library (pkg:: Symbol , libname:: Symbol ):: String
43
10
succ, res = safe_exec (" import $pkg ; println($pkg .$libname )" )
44
11
(succ && ispath (res)) || return " "
45
12
return res
46
13
end
47
14
48
- function get_library (
49
- libname:: String ; rocm_path:: String ,
50
- artifact_library:: Symbol , artifact_field:: Union{Nothing, Symbol} = nothing ,
51
- ext:: String = dlext,
52
- )
53
- if use_artifacts ()
54
- artifact_field = artifact_field ≡ nothing ? Symbol (libname) : artifact_field
55
- get_artifact_library (artifact_library, artifact_field)
56
- else
57
- find_rocm_library (libname, rocm_path, ext)
58
- end
15
+ function get_library (libname:: String ; rocm_path:: String , ext:: String = dlext)
16
+ find_rocm_library (libname, rocm_path, ext)
59
17
end
60
18
61
19
function get_ld_lld (rocm_path:: String ;
@@ -76,7 +34,6 @@ function get_device_libs(from_artifact::Bool; rocm_path::String)
76
34
end
77
35
end
78
36
79
- export use_artifacts, use_artifacts!
80
37
export lld_artifact, lld_path, libhsaruntime, libdevice_libs, libhip
81
38
export librocblas, librocsparse, librocsolver, librocalution
82
39
export librocrand, librocfft, libMIOpen_path
@@ -108,14 +65,12 @@ function __init__()
108
65
end
109
66
end
110
67
111
- rocm_path = use_artifacts () ? " " : find_roc_path ()
68
+ rocm_path = find_roc_path ()
112
69
lib_prefix = Sys. islinux () ? " lib" : " "
113
70
114
71
try
115
72
global libhsaruntime = if Sys. islinux ()
116
- get_library (" libhsa-runtime64" ;
117
- rocm_path, artifact_library= :hsa_rocr_jll ,
118
- artifact_field= :libhsa_runtime64 , ext= " so.1" )
73
+ get_library (" libhsa-runtime64" ; rocm_path, ext= " so.1" )
119
74
else
120
75
" "
121
76
end
@@ -134,37 +89,26 @@ function __init__()
134
89
135
90
# HIP.
136
91
global libhip = get_library (
137
- Sys. islinux () ? " libamdhip64" : " amdhip64" ;
138
- rocm_path, artifact_library= :HIP_jll )
92
+ Sys. islinux () ? " libamdhip64" : " amdhip64" ; rocm_path)
93
+
94
+ # Detect HIP version, which will influence what device libraries to use.
95
+ hip_version = Base. thisminor (_hip_runtime_version ())
96
+ # Check if opaque pointers are enabled and turn off artifacts.
97
+ llvm_args = get (ENV , " JULIA_LLVM_ARGS" , " " )
98
+ enabled_opaque_pointers = occursin (" -opaque-pointers" , llvm_args)
99
+ from_artifact = hip_version > v " 5.4" && ! enabled_opaque_pointers
139
100
140
- from_artifact = if isempty (libhip)
141
- use_artifacts ()
142
- else
143
- # Detect HIP version, which will influence what device libraries to use.
144
- hip_version = Base. thisminor (_hip_runtime_version ())
145
- # Check if opaque pointers are enabled and turn off artifacts.
146
- llvm_args = get (ENV , " JULIA_LLVM_ARGS" , " " )
147
- enabled_opaque_pointers = occursin (" -opaque-pointers" , llvm_args)
148
- (hip_version > v " 5.4" && ! enabled_opaque_pointers) ? true : use_artifacts ()
149
- end
150
101
# If ROCm 5.5+ - use artifact device libraries.
151
102
global libdevice_libs = get_device_libs (from_artifact; rocm_path)
152
103
153
104
# HIP-based libraries.
154
- global librocblas = get_library (lib_prefix * " rocblas" ;
155
- rocm_path, artifact_library= :rocBLAS_jll )
156
- global librocsparse = get_library (lib_prefix * " rocsparse" ;
157
- rocm_path, artifact_library= :rocSPARSE_jll )
158
- global librocsolver = get_library (lib_prefix * " rocsolver" ;
159
- rocm_path, artifact_library= :rocSOLVER_jll )
160
- global librocalution = get_library (lib_prefix * " rocalution" ;
161
- rocm_path, artifact_library= :rocALUTION_jll )
162
- global librocrand = get_library (lib_prefix * " rocrand" ;
163
- rocm_path, artifact_library= :rocRAND_jll )
164
- global librocfft = get_library (lib_prefix * " rocfft" ;
165
- rocm_path, artifact_library= :rocFFT_jll )
166
- global libMIOpen_path = get_library (lib_prefix * " MIOpen" ;
167
- rocm_path, artifact_library= :MIOpen_jll )
105
+ global librocblas = get_library (lib_prefix * " rocblas" ; rocm_path)
106
+ global librocsparse = get_library (lib_prefix * " rocsparse" ; rocm_path)
107
+ global librocsolver = get_library (lib_prefix * " rocsolver" ; rocm_path)
108
+ global librocalution = get_library (lib_prefix * " rocalution" ; rocm_path)
109
+ global librocrand = get_library (lib_prefix * " rocrand" ; rocm_path)
110
+ global librocfft = get_library (lib_prefix * " rocfft" ; rocm_path)
111
+ global libMIOpen_path = get_library (lib_prefix * " MIOpen" ; rocm_path)
168
112
catch err
169
113
@error """ ROCm discovery failed!
170
114
Discovered ROCm path: $rocm_path .
0 commit comments