Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle_t* -> std::unique_ptr<handle_t> in Bsr SpMV unit tests #2269

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions sparse/unit_test/Test_Sparse_spmv_bsr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ void test_spmv_combos(const char *mode, const Bsr &a, const Crs &acrs,
using handle_t = SPMVHandle<execution_space, Bsr, decltype(x), decltype(y)>;

// cover a variety of algorithms
std::vector<handle_t *> handles;
std::vector<std::unique_ptr<handle_t>> handles;
for (SPMVAlgorithm algo : {SPMV_DEFAULT, SPMV_NATIVE, SPMV_BSR_V41})
handles.push_back(new handle_t(algo));
cwpearson marked this conversation as resolved.
Show resolved Hide resolved
handles.push_back(std::make_unique<handle_t>(algo));

// Tensor core algorithm temporarily disabled, fails on V100
/*
Expand All @@ -405,14 +405,14 @@ void test_spmv_combos(const char *mode, const Bsr &a, const Crs &acrs,
}
*/

for (handle_t *handle : handles) {
for (std::unique_ptr<handle_t> &handle : handles) {
for (scalar_type alpha :
{scalar_type(0), scalar_type(1), scalar_type(-1), scalar_type(3.7)}) {
for (scalar_type beta : {scalar_type(0), scalar_type(1), scalar_type(-1),
scalar_type(-1.5)}) {
test_spmv(handle, mode, alpha, beta, a, acrs, maxNnzPerRow, x, y);
test_spmv(handle.get(), mode, alpha, beta, a, acrs, maxNnzPerRow, x, y);
if (beta == scalar_type(0)) {
test_spmv(handle, mode, alpha, beta, a, acrs, maxNnzPerRow,
test_spmv(handle.get(), mode, alpha, beta, a, acrs, maxNnzPerRow,
x_with_nans, y_with_nans);
}
}
Expand Down Expand Up @@ -644,9 +644,9 @@ void test_spm_mv_combos(const char *mode, const Bsr &a, const Crs &acrs,
SPMVHandle<execution_space, Bsr, multivector_t, multivector_t>;

// cover a variety of algorithms
std::vector<handle_t *> handles;
std::vector<std::unique_ptr<handle_t>> handles;
for (SPMVAlgorithm algo : {SPMV_DEFAULT, SPMV_NATIVE, SPMV_BSR_V41})
handles.push_back(new handle_t(algo));
handles.push_back(std::make_unique<handle_t>(algo));

// Tensor core algorithm temporarily disabled, fails on V100
/*
Expand All @@ -670,14 +670,15 @@ void test_spm_mv_combos(const char *mode, const Bsr &a, const Crs &acrs,
auto [x, y] = random_multivecs_for_spm_mv<Layout>(mode, a, numVecs);
auto [x_with_nans, y_with_nans] =
random_multivecs_for_spm_mv<Layout>(mode, a, numVecs, true);
for (handle_t *handle : handles) {
for (std::unique_ptr<handle_t> &handle : handles) {
for (scalar_type alpha : {scalar_type(0), scalar_type(1), scalar_type(-1),
scalar_type(3.7)}) {
for (scalar_type beta : {scalar_type(0), scalar_type(1),
scalar_type(-1), scalar_type(-1.5)}) {
test_spm_mv(handle, mode, alpha, beta, a, acrs, maxNnzPerRow, x, y);
test_spm_mv(handle.get(), mode, alpha, beta, a, acrs, maxNnzPerRow, x,
y);
if (beta == scalar_type(0)) {
test_spm_mv(handle, mode, alpha, beta, a, acrs, maxNnzPerRow,
test_spm_mv(handle.get(), mode, alpha, beta, a, acrs, maxNnzPerRow,
x_with_nans, y_with_nans);
}
}
Expand Down
Loading