Skip to content

Commit 75d7b6a

Browse files
committed
Cleanup & show shmem size for devices
1 parent f9719da commit 75d7b6a

File tree

2 files changed

+19
-40
lines changed

2 files changed

+19
-40
lines changed

src/AMDGPU.jl

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,8 @@ import .ROCKernels: ROCBackend
154154
export ROCBackend
155155

156156
function __init__()
157-
atexit() do
158-
Runtime.RT_EXITING[] = true
159-
end
157+
# Used to shutdown hostcalls if any is running.
158+
atexit(() -> begin Runtime.RT_EXITING[] = true end)
160159

161160
if haskey(ENV, "HIP_LAUNCH_BLOCKING")
162161
launch_blocking = parse(Bool, ENV["HIP_LAUNCH_BLOCKING"])
@@ -167,78 +166,57 @@ function __init__()
167166
end
168167
end
169168

170-
# Quiet path first, in case this system doesn't have AMD GPUs
171-
if Sys.islinux() && !ispath("/dev/kfd")
172-
@debug "/dev/kfd not available (no AMD GPU), skipping initialization"
173-
return
174-
end
175-
176-
# Verbose path, something is misconfigured
177169
if Sys.islinux()
170+
if !ispath("/dev/kfd")
171+
@debug "/dev/kfd not available (no AMD GPU), skipping initialization"
172+
return
173+
end
174+
178175
if !isempty(libhsaruntime)
179-
# Initialize the HSA runtime.
180-
status = HSA.init()
181-
if status == HSA.STATUS_SUCCESS
182-
# Register shutdown hook.
183-
atexit(() -> HSA.shut_down())
184-
else
176+
HSA.init() == HSA.STATUS_SUCCESS ?
177+
atexit(() -> HSA.shut_down()) :
185178
@warn "HSA initialization failed with code $status"
186-
end
187179
else
188-
@warn """
189-
HSA runtime is unavailable, compilation and runtime functionality will be disabled.
190-
"""
180+
@warn "HSA runtime is unavailable, compilation and runtime functionality will be disabled."
191181
if parse(Bool, get(ENV, "JULIA_AMDGPU_CORE_MUST_LOAD", "0"))
192182
print_build_diagnostics()
193183
error("Failed to load HSA runtime, but HSA must load, bailing out")
194184
end
195185
end
196186
end
197187

198-
# Check whether ld.lld was found
199188
if !functional(:lld)
200-
@warn """
201-
LLD is unavailable, compilation functionality will be disabled.
202-
"""
189+
@warn "LLD is unavailable, compilation functionality will be disabled."
203190
if parse(Bool, get(ENV, "JULIA_AMDGPU_CORE_MUST_LOAD", "0"))
204191
print_build_diagnostics()
205192
error("Failed to find ld.lld, but ld.lld must exist, bailing out")
206193
end
207194
end
208195

209-
# Check whether device intrinsics are available
210196
if !functional(:device_libs)
211-
@warn """
212-
Device libraries are unavailable, device intrinsics will be disabled.
213-
"""
197+
@warn "Device libraries are unavailable, device intrinsics will be disabled."
214198
if parse(Bool, get(ENV, "JULIA_AMDGPU_CORE_MUST_LOAD", "0"))
215199
print_build_diagnostics()
216200
error("Failed to find Device Libs, but Device Libs must exist, bailing out")
217201
end
218202
end
219203

220-
# Check whether HIP is available
221204
if functional(:hip)
222205
HIP.devices()
223206
else
224-
@warn """
225-
HIP library is unavailable, HIP integration will be disabled.
226-
"""
207+
@warn "HIP library is unavailable, HIP integration will be disabled."
227208
if parse(Bool, get(ENV, "JULIA_AMDGPU_HIP_MUST_LOAD", "0"))
228209
print_build_diagnostics()
229210
error("Failed to load HIP runtime, but HIP must load, bailing out")
230211
end
231212
end
232213

233-
# Check whether external libraries are available.
234214
hiplibs = (
235215
("rocBLAS", :rocblas), ("rocSPARSE", :rocsparse),
236216
("rocSOLVER", :rocsolver), ("rocALUTION", :rocalution),
237217
("rocRAND", :rocrand), ("rocFFT", :rocfft), ("MIOpen", :MIOpen))
238218
for (name, symbol) in hiplibs
239-
if !functional(symbol)
240-
@warn "$name is unavailable, functionality will be disabled."
241-
end
219+
functional(symbol) || @warn "$name is unavailable, functionality will be disabled."
242220
end
243221
end
244222

src/hip/device.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,18 @@ function __pretty_data(dev::HIPDevice)
161161
name_ptr = pointer([props.name...])
162162
name = unsafe_string(name_ptr)
163163
reshape(String[
164-
"$(dev.device_id)", name, "$(dev.gcn_arch)",
165-
"$(dev.wavefrontsize)", "$(Base.format_bytes(props.totalGlobalMem))",
164+
"$(dev.device_id)", name, dev.gcn_arch, "$(dev.wavefrontsize)",
165+
Base.format_bytes(props.totalGlobalMem),
166+
Base.format_bytes(props.sharedMemPerBlock),
166167
], 1, :)
167168
end
168169

169170
function Base.show(io::IO, mime::MIME{Symbol("text/plain")}, dev::HIPDevice)
170171
PrettyTables.pretty_table(io, __pretty_data(dev); header=[
171-
"Id", "Name", "GCN arch", "Wavefront", "Memory"])
172+
"Id", "Name", "GCN arch", "Wavefront", "Memory", "Shared Memory"])
172173
end
173174

174175
function Base.show(io::IO, mime::MIME{Symbol("text/plain")}, devs::Vector{HIPDevice})
175176
PrettyTables.pretty_table(io, vcat(__pretty_data.(devs)...); header=[
176-
"Id", "Name", "GCN arch", "Wavefront", "Memory"])
177+
"Id", "Name", "GCN arch", "Wavefront", "Memory", "Shared Memory"])
177178
end

0 commit comments

Comments
 (0)