Skip to content

Commit

Permalink
Wait before freeing USM pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
Rbiessy committed Jul 29, 2024
1 parent 1c381f4 commit 42bbc8f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions tests/unit_tests/sparse_blas/include/test_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,6 @@ void set_matrix_data(sycl::queue &queue, sparse_matrix_format_t format,
oneapi::mkl::sparse::matrix_handle_t smhandle, std::int64_t num_rows,
std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index,
ContainerIndexT rows, ContainerIndexT cols, ContainerValueT vals) {
// Ensure to wait for previous operations to finish before resetting the data
queue.wait_and_throw();
if (format == sparse_matrix_format_t::CSR) {
CALL_RT_OR_CT(oneapi::mkl::sparse::set_csr_matrix_data, queue, smhandle, num_rows, num_cols,
nnz, index, rows, cols, vals);
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_tests/sparse_blas/source/sparse_spmm_usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ int test_spmm(sycl::device *dev, sparse_matrix_format_t format, intType nrows_A,
a_host.data(), reset_nnz, static_cast<std::size_t>(nrows_A));
}
if (reset_nnz > nnz) {
// Wait before freeing usm pointers
ev_spmm.wait_and_throw();
ia_usm_uptr = malloc_device_uptr<intType>(main_queue, ia_host.size());
ja_usm_uptr = malloc_device_uptr<intType>(main_queue, ja_host.size());
a_usm_uptr = malloc_device_uptr<fpType>(main_queue, a_host.size());
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_tests/sparse_blas/source/sparse_spmv_usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ int test_spmv(sycl::device *dev, sparse_matrix_format_t format, intType nrows_A,
a_host.data(), reset_nnz, static_cast<std::size_t>(nrows_A));
}
if (reset_nnz > nnz) {
// Wait before freeing usm pointers
ev_spmv.wait_and_throw();
ia_usm_uptr = malloc_device_uptr<intType>(main_queue, ia_host.size());
ja_usm_uptr = malloc_device_uptr<intType>(main_queue, ja_host.size());
a_usm_uptr = malloc_device_uptr<fpType>(main_queue, a_host.size());
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_tests/sparse_blas/source/sparse_spsv_usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ int test_spsv(sycl::device *dev, sparse_matrix_format_t format, intType m, doubl
a_host.data(), reset_nnz, mu);
}
if (reset_nnz > nnz) {
// Wait before freeing usm pointers
ev_spsv.wait_and_throw();
ia_usm_uptr = malloc_device_uptr<intType>(main_queue, ia_host.size());
ja_usm_uptr = malloc_device_uptr<intType>(main_queue, ja_host.size());
a_usm_uptr = malloc_device_uptr<fpType>(main_queue, a_host.size());
Expand Down

0 comments on commit 42bbc8f

Please sign in to comment.