@@ -154,9 +154,8 @@ import .ROCKernels: ROCBackend
154154export ROCBackend
155155
156156function __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
243221end
244222
0 commit comments