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

[FEA] Support for half-float mixed precise in brute-force #2382

Merged
merged 20 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
fix CI fail by skipping low version cuSparse
  • Loading branch information
rhdong committed Aug 1, 2024
commit 34dbde8c364f4b37b316a724d86bf2eb7f56be00
35 changes: 29 additions & 6 deletions cpp/test/sparse/masked_matmul.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <thrust/reduce.h>

#include <cusparse.h>
#include <gtest/gtest.h>

#include <iostream>
Expand Down Expand Up @@ -67,6 +68,22 @@ template <typename value_t, typename output_t, typename index_t>
return os;
}

bool isCuSparseVersionGreaterThan_12_0_1()
{
int version;
cusparseHandle_t handle;
cusparseCreate(&handle);
cusparseGetVersion(handle, &version);

int major = version / 1000;
int minor = (version % 1000) / 100;
int patch = version % 100;

cusparseDestroy(handle);

return (major > 12) || (major == 12 && minor > 0) || (major == 12 && minor == 0 && patch >= 2);
}

template <typename value_t,
typename output_t,
typename index_t,
Expand Down Expand Up @@ -272,7 +289,13 @@ class MaskedMatmulTest
resource::sync_stream(handle);
}

void SetUp() override { make_data(); }
void SetUp() override
{
if (std::is_same_v<value_t, half> && !isCuSparseVersionGreaterThan_12_0_1()) {
GTEST_SKIP() << "Skipping all tests for half-float as cuSparse doesn't support it.";
}
make_data();
}

void Run()
{
Expand Down Expand Up @@ -360,14 +383,14 @@ const std::vector<MaskedMatmulInputs<double, double, int>> sddmm_inputs_d = {
{0.0001f, 1024, 1024, 1024, 0.1, 1234ULL}};

const std::vector<MaskedMatmulInputs<half, float, int>> sddmm_inputs_h = {
{0.0001f, 10, 5, 32, 0.01, 1234ULL},
{0.0001f, 10, 5, 32, 0.1, 1234ULL},
{0.0001f, 1024, 32, 1024, 0.1, 1234ULL},
{0.0001f, 32, 1024, 1024, 0.2, 1234ULL},
{0.0001f, 1024, 1024, 1024, 0.19, 1234ULL},
{0.0003f, 32, 1024, 1024, 0.2, 1234ULL},
{0.001f, 1024, 1024, 1024, 0.19, 1234ULL},
{0.0001f, 1024, 1024, 32, 0.3, 1234ULL},
{0.0001f, 1024, 32, 1024, 0.4, 1234ULL},
{0.0001f, 32, 1024, 1024, 0.19, 1234ULL},
{0.0001f, 1024, 1024, 1024, 0.1, 1234ULL}};
{0.0003f, 32, 1024, 1024, 0.19, 1234ULL},
{0.001f, 1024, 1024, 1024, 0.1, 1234ULL}};

INSTANTIATE_TEST_CASE_P(MaskedMatmulTest, MaskedMatmulTestF, ::testing::ValuesIn(sddmm_inputs_f));

Expand Down
32 changes: 16 additions & 16 deletions cpp/test/sparse/sddmm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,6 @@ template <typename ValueType, typename IndexType>
return os;
}

bool isCuSparseVersionGreaterThan_12_0_1()
{
int version;
cusparseHandle_t handle;
cusparseCreate(&handle);
cusparseGetVersion(handle, &version);

int major = version / 1000;
int minor = (version % 1000) / 100;
int patch = version % 100;

cusparseDestroy(handle);

return (major > 12) || (major == 12 && minor > 0) || (major == 12 && minor == 0 && patch >= 2);
}

template <typename ValueType,
typename IndexType,
typename LayoutPolicyA = raft::layout_c_contiguous,
Expand All @@ -113,6 +97,22 @@ class SDDMMTest : public ::testing::TestWithParam<SDDMMInputs<ValueType, IndexTy
}

protected:
bool isCuSparseVersionGreaterThan_12_0_1()
{
int version;
cusparseHandle_t handle;
cusparseCreate(&handle);
cusparseGetVersion(handle, &version);

int major = version / 1000;
int minor = (version % 1000) / 100;
int patch = version % 100;

cusparseDestroy(handle);

return (major > 12) || (major == 12 && minor > 0) || (major == 12 && minor == 0 && patch >= 2);
}

IndexType create_sparse_matrix(IndexType m,
IndexType n,
OutputType sparsity,
Expand Down
Loading