atexit handler: terminates process before HIP's broken atexit cleanup runs. Registered after HIP init, so runs before HIP's handler (LIFO order).
()
| 39 | /// atexit handler: terminates process before HIP's broken atexit cleanup runs. |
| 40 | /// Registered after HIP init, so runs before HIP's handler (LIFO order). |
| 41 | extern "C" fn hip_atexit_handler() { |
| 42 | if HIP_INITIALIZED.load(Ordering::Relaxed) { |
| 43 | // Flush stdio then hard-exit to prevent HIP atexit crash |
| 44 | unsafe { |
| 45 | libc::fflush(std::ptr::null_mut()); |
| 46 | libc::syscall(libc::SYS_exit_group, 0); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | use candle_core::{DType, Device, Result, Tensor, TensorId, D}; |
| 52 |