1
1
function 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
7
13
end
8
14
end
9
15
@@ -30,7 +36,7 @@ for (fname, elty, intty) in ((:onemklSsparse_set_csr_data , :Float32 , :Int3
30
36
if m != 0 && n != 0
31
37
$ fname (sycl_queue (queue), handle_ptr[], m, n, ' O' , rowPtr, colVal, nzVal)
32
38
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)
34
40
else
35
41
dA = oneSparseMatrixCSR {$elty, $intty} (nothing , rowPtr, colVal, nzVal, (m, n), nnzA)
36
42
end
0 commit comments