/*! \file */ /* ************************************************************************ * Copyright (C) 2020-2026 Advanced Micro Devices, Inc. All rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * ************************************************************************ */ #pragma once #ifndef ROCSPARSE_MATRIX_FACTORY_HPP #define ROCSPARSE_MATRIX_FACTORY_HPP #include "rocsparse_import.hpp" #include "rocsparse_matrix_utils.hpp" std::string rocsparse_exepath(); #include "rocsparse_matrix_factory_file.hpp" #include "rocsparse_matrix_factory_laplace2d.hpp" #include "rocsparse_matrix_factory_laplace3d.hpp" #include "rocsparse_matrix_factory_pentadiagonal.hpp" #include "rocsparse_matrix_factory_random.hpp" #include "rocsparse_matrix_factory_tridiagonal.hpp" #include "rocsparse_matrix_factory_zero.hpp" template struct rocsparse_matrix_factory : public rocsparse_matrix_factory_base { public: const Arguments& m_arg; private: rocsparse_matrix_factory_base* m_instance; public: ~rocsparse_matrix_factory(); rocsparse_matrix_factory(const Arguments& arg, rocsparse_matrix_init matrix, bool to_int = false, bool full_rank = false, bool noseed = false); rocsparse_matrix_factory(const rocsparse_matrix_factory& that) = delete; rocsparse_matrix_factory& operator=(const rocsparse_matrix_factory& that) = delete; explicit rocsparse_matrix_factory(const Arguments& arg, bool to_int = false, bool full_rank = false, bool noseed = false); virtual void init_csr(std::vector& csr_row_ptr, std::vector& csr_col_ind, std::vector& csr_val, J& m, J& n, I& nnz, rocsparse_index_base base, rocsparse_matrix_type matrix_type, rocsparse_fill_mode uplo, rocsparse_storage_mode storage) { return this->m_instance->init_csr( csr_row_ptr, csr_col_ind, csr_val, m, n, nnz, base, matrix_type, uplo, storage); } virtual void init_gebsr(std::vector& bsr_row_ptr, std::vector& bsr_col_ind, std::vector& bsr_val, rocsparse_direction dirb, J& mb, J& nb, I& nnzb, J& row_block_dim, J& col_block_dim, rocsparse_index_base base, rocsparse_matrix_type matrix_type, rocsparse_fill_mode uplo, rocsparse_storage_mode storage) { return this->m_instance->init_gebsr(bsr_row_ptr, bsr_col_ind, bsr_val, dirb, mb, nb, nnzb, row_block_dim, col_block_dim, base, matrix_type, uplo, storage); } virtual void init_coo(std::vector& coo_row_ind, std::vector& coo_col_ind, std::vector& coo_val, I& m, I& n, int64_t& nnz, rocsparse_index_base base, rocsparse_matrix_type matrix_type, rocsparse_fill_mode uplo, rocsparse_storage_mode storage) { return this->m_instance->init_coo( coo_row_ind, coo_col_ind, coo_val, m, n, nnz, base, matrix_type, uplo, storage); } // // COO // void init_coo(std::vector& coo_row_ind, std::vector& coo_col_ind, std::vector& coo_val, I& m, I& n, int64_t& nnz, rocsparse_index_base base); void init_coo(host_coo_matrix& that); void init_coo(host_coo_matrix& that, I& m, I& n); void init_coo(host_coo_matrix& that, I& m, I& n, rocsparse_index_base base); // // CSR // void init_csr(std::vector& csr_row_ptr, std::vector& csr_col_ind, std::vector& csr_val, J& m, J& n, I& nnz, rocsparse_index_base base); void init_csr(host_csr_matrix& that); void init_csr(host_csr_matrix& that, J& m, J& n); void init_csr(host_csr_matrix& that, J& m, J& n, rocsparse_index_base base); // // CSC // void init_csc(std::vector& csc_col_ptr, std::vector& csc_row_ind, std::vector& csc_val, J& m, J& n, I& nnz, rocsparse_index_base base); void init_csc(host_csc_matrix& that, J& m, J& n, rocsparse_index_base base); // // GEBSR // void init_gebsr(std::vector& bsr_row_ptr, std::vector& bsr_col_ind, std::vector& bsr_val, rocsparse_direction dirb, J& mb, J& nb, I& nnzb, J& row_block_dim, J& col_block_dim, rocsparse_index_base base); void init_gebsr(host_gebsr_matrix& that); void init_gebsr(host_gebsr_matrix& that, J& mb, J& nb, J& row_block_dim, J& col_block_dim, rocsparse_index_base base_); void init_gebsr(host_gebsr_matrix& that, rocsparse_direction block_dir_, J& mb_, J& nb_, I& nnzb_, J& row_block_dim_, J& col_block_dim_, rocsparse_index_base base_); void init_gebsr_spezial(host_gebsr_matrix& that, J& mb, J& nb); void init_gebsc(std::vector& bsc_col_ptr, std::vector& bsc_row_ind, std::vector& bsc_val, rocsparse_direction dirb, J& Mb, J& Nb, I& nnzb, J& row_block_dim, J& col_block_dim, rocsparse_index_base base); // // BSR // void init_bsr(std::vector& bsr_row_ptr, std::vector& bsr_col_ind, std::vector& bsr_val, rocsparse_direction dirb, J& mb, J& nb, I& nnzb, J& block_dim, rocsparse_index_base base); void init_bsr(host_gebsr_matrix& that_, J& mb_, J& nb_, rocsparse_index_base base_); void init_bsr(host_gebsr_matrix& that, device_gebsr_matrix& that_on_device, J& mb_, J& nb_, rocsparse_index_base base_); // // COO AOS // void init_coo_aos(host_coo_aos_matrix& that, I& m, I& n, rocsparse_index_base base); // // ELL // void init_ell(host_ell_matrix& that, I& m, I& n, rocsparse_index_base base); // // BLOCKED ELL // void init_bell(std::vector& bell_col_ind, std::vector& bell_val, I& mb, I& nb, I& ell_cols, I& ell_block_size, rocsparse_index_base base); // // SLICED ELL // void init_sell( host_sell_matrix& that, J& m, J& n, J sell_slice_size, rocsparse_index_base base); // // HYBRID // void init_hyb( rocsparse_hyb_mat hyb, I& m, I& n, I& nnz, rocsparse_index_base base, bool& conform); }; #endif // ROCSPARSE_MATRIX_FACTORY_HPP