CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
188 lines
5.4 KiB
C++
188 lines
5.4 KiB
C++
/* ************************************************************************
|
|
* Copyright (C) 2025-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
|
|
#include "auto_testing_bad_arg.hpp"
|
|
#include "display.hpp"
|
|
#include "flops.hpp"
|
|
#include "gbyte.hpp"
|
|
#include "rocsparse.hpp"
|
|
#include "rocsparse_check.hpp"
|
|
#include "rocsparse_matrix_factory.hpp"
|
|
#include "rocsparse_reproducibility.hpp"
|
|
#include "rocsparse_reproducibility_test_save.hpp"
|
|
#include "rocsparse_traits.hpp"
|
|
#include "rocsparse_vector_utils.hpp"
|
|
#include "utility.hpp"
|
|
|
|
namespace rocsparse_clients
|
|
{
|
|
|
|
template <typename T>
|
|
struct dense_vector_t
|
|
{
|
|
protected:
|
|
host_dense_vector<T>* m_h;
|
|
device_dense_vector<T> m_d;
|
|
rocsparse_local_dnvec m_dnvec;
|
|
|
|
public:
|
|
operator rocsparse_dnvec_descr&()
|
|
{
|
|
return this->m_dnvec;
|
|
}
|
|
operator const rocsparse_dnvec_descr&() const
|
|
{
|
|
return this->m_dnvec;
|
|
}
|
|
|
|
static host_dense_vector<T>* init(int64_t size)
|
|
{
|
|
host_dense_vector<T>* that = new host_dense_vector<T>(size);
|
|
T* d = that->data();
|
|
for(int64_t i = 0; i < size; ++i)
|
|
{
|
|
d[i] = 1;
|
|
}
|
|
return that;
|
|
}
|
|
|
|
~dense_vector_t()
|
|
{
|
|
if(m_h != nullptr)
|
|
{
|
|
delete m_h;
|
|
}
|
|
}
|
|
dense_vector_t(int64_t size)
|
|
: m_h(init(size))
|
|
, m_d(m_h[0])
|
|
, m_dnvec(m_d)
|
|
{
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
struct dense_matrix_t
|
|
{
|
|
protected:
|
|
host_dense_matrix<T>* m_h;
|
|
device_dense_matrix<T> m_d;
|
|
rocsparse_local_dnmat m_dnmat;
|
|
|
|
public:
|
|
operator rocsparse_dnmat_descr&()
|
|
{
|
|
return this->m_dnmat;
|
|
}
|
|
operator const rocsparse_dnmat_descr&() const
|
|
{
|
|
return this->m_dnmat;
|
|
}
|
|
|
|
static host_dense_matrix<T>* init(int64_t m, int64_t n)
|
|
{
|
|
host_dense_matrix<T>* that = new host_dense_matrix<T>(m, n);
|
|
T* d = that->data();
|
|
for(int64_t i = 0; i < m * n; ++i)
|
|
d[0] = 1;
|
|
return that;
|
|
}
|
|
~dense_matrix_t()
|
|
{
|
|
if(m_h != nullptr)
|
|
delete m_h;
|
|
}
|
|
dense_matrix_t(int64_t m, int64_t n)
|
|
: m_h(init(m, n))
|
|
, m_d(m_h[0])
|
|
, m_dnmat(m_d)
|
|
{
|
|
}
|
|
};
|
|
|
|
template <typename T, typename I, typename J>
|
|
struct csr_tridiag_matrix_t
|
|
{
|
|
protected:
|
|
host_csr_matrix<T, I, J>* m_h;
|
|
device_csr_matrix<T, I, J> m_d;
|
|
rocsparse_local_spmat m_spmat;
|
|
|
|
public:
|
|
operator rocsparse_spmat_descr&()
|
|
{
|
|
return this->m_spmat;
|
|
}
|
|
operator const rocsparse_spmat_descr&() const
|
|
{
|
|
return this->m_spmat;
|
|
}
|
|
|
|
static host_csr_matrix<T, I, J>* init(int64_t size)
|
|
{
|
|
const int64_t nnz = (size > 2) ? ((size - 2) * 3 + 4) : 4;
|
|
auto that = new host_csr_matrix<T, I, J>(size, size, nnz, rocsparse_index_base_zero);
|
|
|
|
that->ptr[0] = 0;
|
|
that->ptr[1] = 2;
|
|
for(int64_t i = 2; i < size; ++i)
|
|
{
|
|
that->ptr[i] = that->ptr[i - 1] + 3;
|
|
}
|
|
that->ptr[size] = that->ptr[size - 1] + 2;
|
|
|
|
that->val[0] = 2;
|
|
that->val[1] = -1;
|
|
for(int64_t i = 2; i < size; ++i)
|
|
{
|
|
that->val[2 + 3 * (i - 2) + 0] = -1;
|
|
that->val[2 + 3 * (i - 2) + 1] = 2;
|
|
that->val[2 + 3 * (i - 2) + 2] = -1;
|
|
}
|
|
that->val[nnz - 2] = -1;
|
|
that->val[nnz - 1] = 2;
|
|
|
|
that->ind[0] = 0;
|
|
that->ind[1] = 1;
|
|
for(int64_t i = 2; i < size; ++i)
|
|
{
|
|
that->ind[2 + 3 * (i - 2) + 0] = i - 1;
|
|
that->ind[2 + 3 * (i - 2) + 1] = i;
|
|
that->ind[2 + 3 * (i - 2) + 2] = i + 1;
|
|
}
|
|
that->ind[nnz - 2] = size - 2;
|
|
that->ind[nnz - 1] = size - 1;
|
|
return that;
|
|
}
|
|
|
|
csr_tridiag_matrix_t(int64_t size)
|
|
: m_h(init(size))
|
|
, m_d(m_h[0])
|
|
, m_spmat(m_d)
|
|
{
|
|
}
|
|
};
|
|
|
|
}
|