diff --git a/cpp/test/sparse/sort.cu b/cpp/test/sparse/sort.cu index ecea5344e7..a673d5fd03 100644 --- a/cpp/test/sparse/sort.cu +++ b/cpp/test/sparse/sort.cu @@ -22,6 +22,7 @@ #include #include +#include namespace raft { namespace sparse { @@ -60,9 +61,9 @@ TEST_P(COOSort, Result) uniform(h, r, in_vals.data(), params.nnz, float(-1.0), float(1.0)); - int* in_rows_h = (int*)malloc(params.nnz * sizeof(int)); - int* in_cols_h = (int*)malloc(params.nnz * sizeof(int)); - int* verify_h = (int*)malloc(params.nnz * sizeof(int)); + auto in_rows_h = std::make_unique(params.nnz); + auto in_cols_h = std::make_unique(params.nnz); + auto verify_h = std::make_unique(params.nnz); for (int i = 0; i < params.nnz; i++) { in_rows_h[i] = params.nnz - i - 1; @@ -70,20 +71,16 @@ TEST_P(COOSort, Result) in_cols_h[i] = i; } - raft::update_device(in_rows.data(), in_rows_h, params.nnz, stream); + raft::update_device(in_rows.data(), in_rows_h.get(), params.nnz, stream); - raft::update_device(in_cols.data(), in_cols_h, params.nnz, stream); - raft::update_device(verify.data(), verify_h, params.nnz, stream); + raft::update_device(in_cols.data(), in_cols_h.get(), params.nnz, stream); + raft::update_device(verify.data(), verify_h.get(), params.nnz, stream); op::coo_sort( params.m, params.n, params.nnz, in_rows.data(), in_cols.data(), in_vals.data(), stream); ASSERT_TRUE(raft::devArrMatch( verify.data(), in_rows.data(), params.nnz, raft::Compare(), stream)); - - delete[] in_rows_h; - delete[] in_cols_h; - delete[] verify_h; } INSTANTIATE_TEST_CASE_P(SparseSortTest, COOSort, ::testing::ValuesIn(inputsf));