11function sparse_release_matrix_handle (A:: oneAbstractSparseMatrix )
2- return if A. handle != = nothing
3- queue = global_queue (context (A. nzVal), device (A. nzVal))
4- oneL0. synchronize (queue)
5- handle_ptr = Ref {matrix_handle_t} (A. handle)
6- onemklXsparse_release_matrix_handle (sycl_queue (queue), handle_ptr)
2+ if A. handle != = nothing
3+ try
4+ queue = global_queue (context (A. nzVal), device (A. nzVal))
5+ handle_ptr = Ref {matrix_handle_t} (A. handle)
6+ onemklXsparse_release_matrix_handle (sycl_queue (queue), handle_ptr)
7+ # Only synchronize after successful release to ensure completion
8+ synchronize (queue)
9+ catch err
10+ # Don't let finalizer errors crash the program
11+ @warn " Error releasing sparse matrix handle" exception= err
12+ end
713 end
814end
915
@@ -30,7 +36,7 @@ for (fname, elty, intty) in ((:onemklSsparse_set_csr_data , :Float32 , :Int3
3036 if m != 0 && n != 0
3137 $ fname (sycl_queue (queue), handle_ptr[], m, n, ' O' , rowPtr, colVal, nzVal)
3238 dA = oneSparseMatrixCSR {$elty, $intty} (handle_ptr[], rowPtr, colVal, nzVal, (m, n), nnzA)
33- finalizer (spars_release_matrix_handle , dA)
39+ finalizer (sparse_release_matrix_handle , dA)
3440 else
3541 dA = oneSparseMatrixCSR {$elty, $intty} (nothing , rowPtr, colVal, nzVal, (m, n), nnzA)
3642 end
0 commit comments