Skip to content

Commit

Permalink
Test in-order queues
Browse files Browse the repository at this point in the history
  • Loading branch information
Rbiessy committed Oct 25, 2024
1 parent 956ae49 commit 43428ca
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 164 deletions.
126 changes: 69 additions & 57 deletions tests/unit_tests/sparse_blas/include/test_spmm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void test_helper_with_format_with_transpose(
const std::vector<oneapi::mkl::sparse::spmm_alg> &non_default_algorithms,
oneapi::mkl::transpose transpose_A, oneapi::mkl::transpose transpose_B, int &num_passed,
int &num_skipped) {
sycl::property_list queue_properties;
double density_A_matrix = 0.8;
fpType fp_zero = set_fp_value<fpType>()(0.f, 0.f);
fpType fp_one = set_fp_value<fpType>()(1.f, 0.f);
Expand Down Expand Up @@ -85,108 +86,119 @@ void test_helper_with_format_with_transpose(

// Basic test
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, fp_one, fp_zero, ldb, ldc,
default_alg, default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, fp_zero, ldb, ldc, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
// Reset data
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, fp_one, fp_zero, ldb, ldc,
default_alg, default_A_view, default_properties, true,
no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, fp_zero, ldb, ldc, default_alg, default_A_view,
default_properties, true, no_scalars_on_device),
num_passed, num_skipped);
// Test alpha and beta on the device
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, fp_one, fp_zero, ldb, ldc,
default_alg, default_A_view, default_properties, no_reset_data, true),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, fp_zero, ldb, ldc, default_alg, default_A_view,
default_properties, no_reset_data, true),
num_passed, num_skipped);
// Test index_base 1
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix,
oneapi::mkl::index_base::one, col_major, transpose_A, transpose_B,
fp_one, fp_zero, ldb, ldc, default_alg, default_A_view,
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, oneapi::mkl::index_base::one, col_major, transpose_A,
transpose_B, fp_one, fp_zero, ldb, ldc, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
// Test non-default alpha
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, set_fp_value<fpType>()(2.f, 1.5f),
fp_zero, ldb, ldc, default_alg, default_A_view, default_properties,
no_reset_data, no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
set_fp_value<fpType>()(2.f, 1.5f), fp_zero, ldb, ldc, default_alg,
default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
num_passed, num_skipped);
// Test non-default beta
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, fp_one,
set_fp_value<fpType>()(3.2f, 1.f), ldb, ldc, default_alg,
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, set_fp_value<fpType>()(3.2f, 1.f), ldb, ldc, default_alg,
default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
num_passed, num_skipped);
// Test 0 alpha
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, fp_zero, fp_one, ldb, ldc,
default_alg, default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_zero, fp_one, ldb, ldc, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
// Test 0 alpha and beta
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, fp_zero, fp_zero, ldb, ldc,
default_alg, default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_zero, fp_zero, ldb, ldc, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
// Test non-default ldb
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, fp_one, fp_zero, ldb + 5, ldc,
default_alg, default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, fp_zero, ldb + 5, ldc, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
// Test non-default ldc
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, fp_one, fp_zero, ldb, ldc + 6,
default_alg, default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, fp_zero, ldb, ldc + 6, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
// Test row major layout
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
oneapi::mkl::layout::row_major, transpose_A, transpose_B, fp_one,
fp_zero, ncols_B, ncols_C, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, oneapi::mkl::layout::row_major,
transpose_A, transpose_B, fp_one, fp_zero, ncols_B, ncols_C,
default_alg, default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
num_passed, num_skipped);
// Test int64 indices
long long_nrows_A = 27, long_ncols_A = 13, long_ncols_C = 6;
auto [long_ldc, long_ldb] = swap_if_transposed(transpose_A, long_nrows_A, long_ncols_A);
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i64(dev, format, long_nrows_A, long_ncols_A, long_ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, fp_zero, long_ldb, long_ldc, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
test_functor_i64(dev, queue_properties, format, long_nrows_A, long_ncols_A,
long_ncols_C, density_A_matrix, index_zero, col_major, transpose_A,
transpose_B, fp_one, fp_zero, long_ldb, long_ldc, default_alg,
default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
num_passed, num_skipped);
// Test other algorithms
for (auto alg : non_default_algorithms) {
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix,
index_zero, col_major, transpose_A, transpose_B, fp_one, fp_zero,
ldb, ldc, alg, default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, fp_zero, ldb, ldc, alg, default_A_view, default_properties,
no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
}
// Test matrix properties
for (auto properties : get_all_matrix_properties_combinations(properties_queue, format)) {
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix,
index_zero, col_major, transpose_A, transpose_B, fp_one, fp_zero,
ldb, ldc, default_alg, default_A_view, properties, no_reset_data,
no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, fp_zero, ldb, ldc, default_alg, default_A_view, properties,
no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
}
// In-order queue
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, { property::queue::in_order::in_order() }, format, nrows_A,
ncols_A, ncols_C, density_A_matrix, index_zero, col_major, transpose_A,
transpose_B, fp_one, fp_zero, ldb, ldc, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
}
{
// Test different sizes
Expand All @@ -199,10 +211,10 @@ void test_helper_with_format_with_transpose(
int ldb = nrows_B;
int ldc = nrows_C;
EXPECT_TRUE_OR_FUTURE_SKIP(
test_functor_i32(dev, format, nrows_A, ncols_A, ncols_C, density_A_matrix, index_zero,
col_major, transpose_A, transpose_B, fp_one, fp_zero, ldb, ldc,
default_alg, default_A_view, default_properties, no_reset_data,
no_scalars_on_device),
test_functor_i32(dev, queue_properties, format, nrows_A, ncols_A, ncols_C,
density_A_matrix, index_zero, col_major, transpose_A, transpose_B,
fp_one, fp_zero, ldb, ldc, default_alg, default_A_view,
default_properties, no_reset_data, no_scalars_on_device),
num_passed, num_skipped);
}
}
Expand Down
Loading

0 comments on commit 43428ca

Please sign in to comment.