-
Notifications
You must be signed in to change notification settings - Fork 8
Add AOCL-Sparse backend #44
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e880394
Add AOCL-Sparse backend
mshanthagit 955dacf
Edit for `clang-format`.
BenBrock 6f41c3b
Fix apparent typo.
BenBrock ff7c4b3
Merge branch 'main' into aoclsparse
BenBrock 889f881
Merge branch 'main' into aoclsparse
mshanthagit a8406f6
Misc changes based on review
mshanthagit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights reserved. | ||
| * $COPYRIGHT$ | ||
| * | ||
| * Additional copyrights may follow | ||
| * | ||
| * $HEADER$ | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "spgemm_impl.hpp" | ||
| #include "spmm_impl.hpp" | ||
| #include "spmv_impl.hpp" | ||
| #include "triangular_solve_impl.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| /* | ||
| * Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights reserved. | ||
| * $COPYRIGHT$ | ||
| * | ||
| * Additional copyrights may follow | ||
| * | ||
| * $HEADER$ | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "aoclsparse.h" | ||
| #include <spblas/detail/log.hpp> | ||
|
|
||
| namespace spblas { | ||
| namespace __aoclsparse { | ||
|
|
||
| template <typename T> | ||
| aoclsparse_status | ||
| aoclsparse_csrmm(aoclsparse_operation op, T alpha, const aoclsparse_matrix A, | ||
| const aoclsparse_mat_descr descr, aoclsparse_order order, | ||
| const T* B, aoclsparse_int n, aoclsparse_int ldb, T beta, T* C, | ||
| aoclsparse_int ldc) { | ||
| log_warning("spmm data types are currently not supported"); | ||
| return aoclsparse_status_not_implemented; | ||
| } | ||
|
|
||
| template <> | ||
| inline aoclsparse_status aoclsparse_csrmm<float>( | ||
| aoclsparse_operation op, float alpha, const aoclsparse_matrix A, | ||
| const aoclsparse_mat_descr descr, aoclsparse_order order, const float* B, | ||
| aoclsparse_int n, aoclsparse_int ldb, float beta, float* C, | ||
| aoclsparse_int ldc) { | ||
| return aoclsparse_scsrmm(op, alpha, A, descr, order, B, n, ldb, beta, C, ldc); | ||
| } | ||
|
|
||
| template <> | ||
| inline aoclsparse_status aoclsparse_csrmm<double>( | ||
| aoclsparse_operation op, double alpha, const aoclsparse_matrix A, | ||
| const aoclsparse_mat_descr descr, aoclsparse_order order, const double* B, | ||
| aoclsparse_int n, aoclsparse_int ldb, double beta, double* C, | ||
| aoclsparse_int ldc) { | ||
| return aoclsparse_dcsrmm(op, alpha, A, descr, order, B, n, ldb, beta, C, ldc); | ||
| } | ||
|
|
||
| template <typename T> | ||
| inline aoclsparse_status aoclsparse_mv(aoclsparse_operation op, const T* alpha, | ||
| aoclsparse_matrix A, | ||
| const aoclsparse_mat_descr descr, | ||
| const T* x, const T* beta, T* y) { | ||
| log_warning("aoclsparse_mv data types are currently not supported"); | ||
| return aoclsparse_status_not_implemented; | ||
| } | ||
|
|
||
| template <> | ||
| inline aoclsparse_status | ||
| aoclsparse_mv<float>(aoclsparse_operation op, const float* alpha, | ||
| aoclsparse_matrix A, const aoclsparse_mat_descr descr, | ||
| const float* x, const float* beta, float* y) { | ||
| return aoclsparse_smv(op, alpha, A, descr, x, beta, y); | ||
| } | ||
|
|
||
| template <> | ||
| inline aoclsparse_status | ||
| aoclsparse_mv<double>(aoclsparse_operation op, const double* alpha, | ||
| aoclsparse_matrix A, const aoclsparse_mat_descr descr, | ||
| const double* x, const double* beta, double* y) { | ||
| return aoclsparse_dmv(op, alpha, A, descr, x, beta, y); | ||
| } | ||
|
|
||
| template <typename T> | ||
| inline aoclsparse_status aoclsparse_trsv(const aoclsparse_operation trans, | ||
| const T alpha, aoclsparse_matrix A, | ||
| const aoclsparse_mat_descr descr, | ||
| const T* b, T* x) { | ||
| log_warning("aoclsparse_trsv data types are currently not supported"); | ||
| return aoclsparse_status_not_implemented; | ||
| } | ||
|
|
||
| template <> | ||
| inline aoclsparse_status | ||
| aoclsparse_trsv<double>(const aoclsparse_operation trans, const double alpha, | ||
| aoclsparse_matrix A, const aoclsparse_mat_descr descr, | ||
| const double* b, double* x) { | ||
| return aoclsparse_dtrsv(trans, alpha, A, descr, b, x); | ||
| } | ||
|
|
||
| template <> | ||
| inline aoclsparse_status | ||
| aoclsparse_trsv<float>(const aoclsparse_operation trans, const float alpha, | ||
| aoclsparse_matrix A, const aoclsparse_mat_descr descr, | ||
| const float* b, float* x) { | ||
| return aoclsparse_strsv(trans, alpha, A, descr, b, x); | ||
| } | ||
|
|
||
| template <class T> | ||
| inline aoclsparse_status | ||
| aoclsparse_create_csr(aoclsparse_matrix* mat, aoclsparse_index_base base, | ||
| aoclsparse_int M, aoclsparse_int N, aoclsparse_int nnz, | ||
| aoclsparse_int* row_ptr, aoclsparse_int* col_idx, | ||
| T* val) { | ||
| log_warning("matrix creating with this data type is currently not supported"); | ||
| return aoclsparse_status_not_implemented; | ||
| } | ||
|
|
||
| template <> | ||
| inline aoclsparse_status | ||
| aoclsparse_create_csr<float>(aoclsparse_matrix* mat, aoclsparse_index_base base, | ||
| aoclsparse_int M, aoclsparse_int N, | ||
| aoclsparse_int nnz, aoclsparse_int* row_ptr, | ||
| aoclsparse_int* col_idx, float* val) { | ||
| return aoclsparse_create_scsr(mat, base, M, N, nnz, row_ptr, col_idx, val); | ||
| } | ||
| template <> | ||
| inline aoclsparse_status aoclsparse_create_csr<double>( | ||
| aoclsparse_matrix* mat, aoclsparse_index_base base, aoclsparse_int M, | ||
| aoclsparse_int N, aoclsparse_int nnz, aoclsparse_int* row_ptr, | ||
| aoclsparse_int* col_idx, double* val) { | ||
| return aoclsparse_create_dcsr(mat, base, M, N, nnz, row_ptr, col_idx, val); | ||
| } | ||
|
|
||
| template <typename T> | ||
| inline aoclsparse_status | ||
| aoclsparse_export_csr(const aoclsparse_matrix mat, aoclsparse_index_base* base, | ||
| aoclsparse_int* m, aoclsparse_int* n, aoclsparse_int* nnz, | ||
| aoclsparse_int** row_ptr, aoclsparse_int** col_idx, | ||
| T** val) { | ||
| log_warning( | ||
| "exporting matrix with this data type is currently not supported"); | ||
| return aoclsparse_status_not_implemented; | ||
| } | ||
|
|
||
| template <> | ||
| inline aoclsparse_status aoclsparse_export_csr<float>( | ||
| const aoclsparse_matrix mat, aoclsparse_index_base* base, aoclsparse_int* m, | ||
| aoclsparse_int* n, aoclsparse_int* nnz, aoclsparse_int** row_ptr, | ||
| aoclsparse_int** col_idx, float** val) { | ||
| return aoclsparse_export_scsr(mat, base, m, n, nnz, row_ptr, col_idx, val); | ||
| } | ||
|
|
||
| template <> | ||
| inline aoclsparse_status aoclsparse_export_csr<double>( | ||
| const aoclsparse_matrix mat, aoclsparse_index_base* base, aoclsparse_int* m, | ||
| aoclsparse_int* n, aoclsparse_int* nnz, aoclsparse_int** row_ptr, | ||
| aoclsparse_int** col_idx, double** val) { | ||
| return aoclsparse_export_dcsr(mat, base, m, n, nnz, row_ptr, col_idx, val); | ||
| } | ||
|
|
||
| } // namespace __aoclsparse | ||
| } // namespace spblas |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /* | ||
| * Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights reserved. | ||
| * $COPYRIGHT$ | ||
| * | ||
| * Additional copyrights may follow | ||
| * | ||
| * $HEADER$ | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "algorithms.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights reserved. | ||
| * $COPYRIGHT$ | ||
| * | ||
| * Additional copyrights may follow | ||
| * | ||
| * $HEADER$ | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "aoclsparse.h" | ||
|
|
||
| namespace spblas { | ||
|
|
||
| namespace __aoclsparse { | ||
|
|
||
| struct operation_state_t { | ||
| aoclsparse_matrix a_handle = nullptr; | ||
| aoclsparse_matrix b_handle = nullptr; | ||
| aoclsparse_matrix c_handle = nullptr; | ||
|
|
||
| operation_state_t() = default; | ||
|
|
||
| operation_state_t(aoclsparse_matrix a_handle, aoclsparse_matrix b_handle, | ||
| aoclsparse_matrix c_handle) | ||
| : a_handle(a_handle), b_handle(b_handle), c_handle(c_handle) {} | ||
|
|
||
| operation_state_t(operation_state_t&& other) { | ||
| *this = std::move(other); | ||
| } | ||
|
|
||
| operation_state_t& operator=(operation_state_t&& other) { | ||
| a_handle = other.a_handle; | ||
| b_handle = other.b_handle; | ||
| c_handle = other.c_handle; | ||
|
|
||
| other.a_handle = other.b_handle = other.c_handle = nullptr; | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| operation_state_t(const operation_state_t& other) = delete; | ||
|
|
||
| ~operation_state_t() { | ||
| release_matrix_handle(a_handle); | ||
| release_matrix_handle(b_handle); | ||
| release_matrix_handle(c_handle); | ||
| } | ||
|
|
||
| private: | ||
| void release_matrix_handle(aoclsparse_matrix handle) { | ||
| if (handle != nullptr) { | ||
| aoclsparse_destroy(&handle); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| } // namespace __aoclsparse | ||
|
|
||
| } // namespace spblas | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to set handle to nullptr here after destruction ?