Skip to content

Commit 84524f6

Browse files
authored
Remove artifacts support & fix rocSPARSE bug (#674)
1 parent 72e0aee commit 84524f6

File tree

8 files changed

+41
-124
lines changed

8 files changed

+41
-124
lines changed

Project.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
1111
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
1212
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
1313
GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55"
14-
HIP_jll = "2696aab5-0948-5276-aa9a-2a86a37016b8"
1514
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
1615
LLD_jll = "d55e3150-da41-5e91-b323-ecfd1eec6109"
1716
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
@@ -32,7 +31,6 @@ StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
3231
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
3332
UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f"
3433
UnsafeAtomicsLLVM = "d80eeb9a-aca5-4d75-85e5-170c8b632249"
35-
hsa_rocr_jll = "dd59ff1a-a01a-568d-8b29-0669330f116a"
3634

3735
[compat]
3836
AbstractFFTs = "1.0"
@@ -42,7 +40,6 @@ CEnum = "0.4, 0.5"
4240
ExprTools = "0.1"
4341
GPUArrays = "10"
4442
GPUCompiler = "0.26, 0.27"
45-
HIP_jll = "5.4"
4643
KernelAbstractions = "0.9.2"
4744
LLD_jll = "15, 16, 17"
4845
LLVM = "8.1"
@@ -56,5 +53,4 @@ SpecialFunctions = "2"
5653
StaticArraysCore = "1"
5754
UnsafeAtomics = "0.2"
5855
UnsafeAtomicsLLVM = "0.2"
59-
hsa_rocr_jll = "5.4"
6056
julia = "1.10"

docs/src/index.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,6 @@ Standard path:
6969
If you have non-standard path for ROCm, set `ROCM_PATH=<path>`
7070
environment variable before launching Julia.
7171

72-
## ROCm artifacts
73-
74-
There is limited support for ROCm 5.4+ artifacts which can be enabled with
75-
[`AMDGPU.use_artifacts!`](@ref).
76-
77-
Limited means not all libraries are available and some of the functionality
78-
may be disabled.
79-
80-
```@docs
81-
AMDGPU.use_artifacts!
82-
```
83-
8472
## Extra Setup Details
8573

8674
List of additional steps that may be needed to take to ensure everything is working:
@@ -139,9 +127,6 @@ Template of `LocalPreferences.toml` with all options:
139127
# If `true` (default), eagerly run GC to keep the pool from growing too big.
140128
# GC is triggered during new allocatoins or synchronization points.
141129
eager_gc = false
142-
# If `true` then use ROCm libraries provided by artifacts.
143-
# However, not all ROCm libraries are available as artifacts.
144-
use_artifacts = false
145130
# Use non-blocking synchronization for all `AMDGPU.synchronize()` calls.
146131
nonblocking_synchronization = true
147132
# Memory limit specifies maximum amount of memory in percentages

docs/src/profiling.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,5 @@ wall duration is lower.
6969

7070
## Debugging
7171

72-
Use `JULIA_AMDGPU_LAUNCH_BLOCKING=1` and `HIP_LAUNCH_BLOCKING=1` to
73-
synchronize immediately after launching GPU kernels.
72+
Use `HIP_LAUNCH_BLOCKING=1` to synchronize immediately after launching GPU kernels.
7473
This will allow to pinpoint exact kernel that caused the exception.

src/AMDGPU.jl

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,31 +156,12 @@ function __init__()
156156
Runtime.RT_EXITING[] = true
157157
end
158158

159-
if haskey(ENV, "JULIA_AMDGPU_LAUNCH_BLOCKING")
160-
launch_blocking = parse(Bool, ENV["JULIA_AMDGPU_LAUNCH_BLOCKING"])
161-
LAUNCH_BLOCKING[] = launch_blocking
162-
if launch_blocking
163-
@info "`JULIA_AMDGPU_LAUNCH_BLOCKING` is set to `true`. " *
164-
"Synchronizing immediately after every Julia kernel launch."
165-
end
166-
end
167-
168159
if haskey(ENV, "HIP_LAUNCH_BLOCKING")
169160
launch_blocking = parse(Bool, ENV["HIP_LAUNCH_BLOCKING"])
161+
LAUNCH_BLOCKING[] = launch_blocking
170162
if launch_blocking
171-
@info "`HIP_AMDGPU_LAUNCH_BLOCKING` is set to `true`. " *
172-
"Synchronizing immediately after every HIP kernel launch."
173-
end
174-
end
175-
176-
if haskey(ENV, "JULIA_AMDGPU_DISABLE_ARTIFACTS")
177-
env_use_artifacts = !parse(Bool, ENV["JULIA_AMDGPU_DISABLE_ARTIFACTS"])
178-
if use_artifacts() != env_use_artifacts
179-
enable_artifacts!(env_use_artifacts)
180-
@warn """
181-
The environment variable JULIA_AMDGPU_DISABLE_ARTIFACTS does not match the value from preferences.
182-
Forcing the preferences value to $(env_use_artifacts); please restart Julia for changes to take effect.
183-
"""
163+
@info "`HIP_LAUNCH_BLOCKING` is set to `true`. " *
164+
"Synchronizing immediately after every Julia & HIP kernel launch."
184165
end
185166
end
186167

src/discovery/discovery.jl

Lines changed: 19 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,14 @@ using Libdl
66

77
include("utils.jl")
88

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-
429
function get_artifact_library(pkg::Symbol, libname::Symbol)::String
4310
succ, res = safe_exec("import $pkg; println($pkg.$libname)")
4411
(succ && ispath(res)) || return ""
4512
return res
4613
end
4714

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)
5917
end
6018

6119
function get_ld_lld(rocm_path::String;
@@ -76,7 +34,6 @@ function get_device_libs(from_artifact::Bool; rocm_path::String)
7634
end
7735
end
7836

79-
export use_artifacts, use_artifacts!
8037
export lld_artifact, lld_path, libhsaruntime, libdevice_libs, libhip
8138
export librocblas, librocsparse, librocsolver, librocalution
8239
export librocrand, librocfft, libMIOpen_path
@@ -108,14 +65,12 @@ function __init__()
10865
end
10966
end
11067

111-
rocm_path = use_artifacts() ? "" : find_roc_path()
68+
rocm_path = find_roc_path()
11269
lib_prefix = Sys.islinux() ? "lib" : ""
11370

11471
try
11572
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")
11974
else
12075
""
12176
end
@@ -134,37 +89,26 @@ function __init__()
13489

13590
# HIP.
13691
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
139100

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
150101
# If ROCm 5.5+ - use artifact device libraries.
151102
global libdevice_libs = get_device_libs(from_artifact; rocm_path)
152103

153104
# 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)
168112
catch err
169113
@error """ROCm discovery failed!
170114
Discovered ROCm path: $rocm_path.

src/sparse/level2.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ for (bname,aname,sname,elty) in (
184184
(:rocsparse_scsrsv_buffer_size, :rocsparse_scsrsv_analysis, :rocsparse_scsrsv_solve, :Float32),
185185
(:rocsparse_dcsrsv_buffer_size, :rocsparse_dcsrsv_analysis, :rocsparse_dcsrsv_solve, :Float64),
186186
(:rocsparse_ccsrsv_buffer_size, :rocsparse_ccsrsv_analysis, :rocsparse_ccsrsv_solve, :ComplexF32),
187-
(:rocsparse_ccsrsv_buffer_size, :rocsparse_zcsrsv_analysis, :rocsparse_zcsrsv_solve, :ComplexF64),
187+
(:rocsparse_zcsrsv_buffer_size, :rocsparse_zcsrsv_analysis, :rocsparse_zcsrsv_solve, :ComplexF64),
188188
)
189189
@eval begin
190190
function sv2!(
@@ -230,8 +230,10 @@ for (bname,aname,sname,elty) in (
230230
handle(), ctransa, m, nnz(A),
231231
desc, nonzeros(A), A.colPtr, rowvals(A), info_ref[],
232232
rocsparse_analysis_policy_force, rocsparse_solve_policy_auto, buffer)
233+
233234
posit = Ref{Cint}(1)
234235
rocsparse_csrsv_zero_pivot(handle(), desc, info_ref[], posit)
236+
235237
if posit[] >= 0
236238
rocsparse_destroy_mat_info(info_ref[])
237239
error("Structural/numerical zero in A at ($(posit[]),$(posit[])))")

test/rocsparse/generic.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,16 @@ for SparseMatrixType in (ROCSparseMatrixCSR, ROCSparseMatrixCSC, ROCSparseMatrix
117117
dC = ROCArray(C)
118118
alpha = rand(T)
119119
rocSPARSE.sm!(transa, transb, uplo, diag, alpha, dA, dB, dC, 'O', algo)
120-
if transb == 'T'
121-
@test_broken opa(A) \ (alpha * opb(B)) collect(dC)
122-
else
120+
121+
if AMDGPU.HIP.runtime_version() v"6.2"
123122
@test opa(A) \ (alpha * opb(B)) collect(dC)
123+
# TODO remove once we support only ROCm 6.2+
124+
else
125+
if transb == 'T'
126+
@test_broken opa(A) \ (alpha * opb(B)) collect(dC)
127+
else
128+
@test opa(A) \ (alpha * opb(B)) collect(dC)
129+
end
124130
end
125131
end
126132
end

test/rocsparse/preconditioners.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ end
3535
T = uplo == 'L' ? tril(T) : triu(T)
3636
T = diag == 'N' ? T : T - Diagonal(T) + I
3737
T = sparse(T)
38-
d_T = SparseMatrixType == ROCSparseMatrixBSR ? SparseMatrixType(ROCSparseMatrixCSR(T), blockdim) : SparseMatrixType(T)
38+
d_T = SparseMatrixType == ROCSparseMatrixBSR ?
39+
SparseMatrixType(ROCSparseMatrixCSR(T), blockdim) :
40+
SparseMatrixType(T)
3941
x = rand(elty,n)
4042
d_x = ROCVector{elty}(x)
4143
d_y = rocSPARSE.sv2(trans, uplo, diag, d_T, d_x, 'O')
@@ -58,7 +60,9 @@ end
5860
T = uplo == 'L' ? tril(T) : triu(T)
5961
T = diag == 'N' ? T : T - Diagonal(T) + I
6062
T = sparse(T)
61-
d_T = SparseMatrixType == ROCSparseMatrixBSR ? SparseMatrixType(ROCSparseMatrixCSR(T), blockdim) : SparseMatrixType(T)
63+
d_T = SparseMatrixType == ROCSparseMatrixBSR ?
64+
SparseMatrixType(ROCSparseMatrixCSR(T), blockdim) :
65+
SparseMatrixType(T)
6266
X = transX == 'N' ? rand(elty,n,p) : rand(elty,p,n)
6367
d_X = ROCMatrix{elty}(X)
6468
d_Y = rocSPARSE.sm2(transT, transX, uplo, diag, d_T, d_X, 'O')

0 commit comments

Comments
 (0)