Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 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
42 changes: 24 additions & 18 deletions benchmark/blas/blas_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class CopyOperation : public BenchmarkOperation {
}

private:
std::unique_ptr<gko::LinOp> in_;
std::unique_ptr<gko::LinOp> out_;
std::unique_ptr<gko::AbstractMultiVector> in_;
std::unique_ptr<gko::AbstractMultiVector> out_;
};


Expand Down Expand Up @@ -132,8 +132,8 @@ class AxpyOperation : public BenchmarkOperation {

private:
std::unique_ptr<gko::matrix::MultiVector<etype>> alpha_;
std::unique_ptr<gko::LinOp> x_;
std::unique_ptr<gko::LinOp> y_;
std::unique_ptr<gko::AbstractMultiVector> x_;
std::unique_ptr<gko::AbstractMultiVector> y_;
};


Expand Down Expand Up @@ -172,8 +172,8 @@ class SubScaledOperation : public BenchmarkOperation {

private:
std::unique_ptr<gko::matrix::MultiVector<etype>> alpha_;
std::unique_ptr<gko::LinOp> x_;
std::unique_ptr<gko::LinOp> y_;
std::unique_ptr<gko::AbstractMultiVector> x_;
std::unique_ptr<gko::AbstractMultiVector> y_;
};


Expand Down Expand Up @@ -208,7 +208,7 @@ class ScalOperation : public BenchmarkOperation {

private:
std::unique_ptr<gko::matrix::MultiVector<etype>> alpha_;
std::unique_ptr<gko::LinOp> y_;
std::unique_ptr<gko::AbstractMultiVector> y_;
};


Expand Down Expand Up @@ -245,8 +245,8 @@ class DotOperation : public BenchmarkOperation {

private:
std::unique_ptr<gko::matrix::MultiVector<etype>> alpha_;
std::unique_ptr<gko::LinOp> x_;
std::unique_ptr<gko::LinOp> y_;
std::unique_ptr<gko::AbstractMultiVector> x_;
std::unique_ptr<gko::AbstractMultiVector> y_;
};


Expand Down Expand Up @@ -279,7 +279,7 @@ class NormOperation : public BenchmarkOperation {

private:
std::unique_ptr<gko::matrix::MultiVector<etype>> alpha_;
std::unique_ptr<gko::LinOp> y_;
std::unique_ptr<gko::AbstractMultiVector> y_;
};


Expand All @@ -293,8 +293,11 @@ class ApplyOperation : public BenchmarkOperation {
{
// Since dense distributed matrices are not supported we can use
// local_size == global_size
A_ = generator.create_multi_vector_strided(exec, gko::dim<2>{n, k},
gko::dim<2>{n, k}, stride_A);
A_ = generator
.create_multi_vector_strided(exec, gko::dim<2>{n, k},
gko::dim<2>{n, k}, stride_A)
->as_const_dense_view()
->clone();
B_ = generator.create_multi_vector_strided(exec, gko::dim<2>{k, m},
gko::dim<2>{k, m}, stride_B);
C_ = generator.create_multi_vector_strided(exec, gko::dim<2>{n, m},
Expand All @@ -320,8 +323,8 @@ class ApplyOperation : public BenchmarkOperation {

private:
std::unique_ptr<gko::LinOp> A_;
std::unique_ptr<gko::LinOp> B_;
std::unique_ptr<gko::LinOp> C_;
std::unique_ptr<gko::AbstractMultiVector> B_;
std::unique_ptr<gko::AbstractMultiVector> C_;
};


Expand All @@ -336,8 +339,11 @@ class AdvancedApplyOperation : public BenchmarkOperation {
{
// Since dense distributed matrices are not supported we can use
// local_size == global_size
A_ = generator.create_multi_vector_strided(exec, gko::dim<2>{n, k},
gko::dim<2>{n, k}, stride_A);
A_ = generator
.create_multi_vector_strided(exec, gko::dim<2>{n, k},
gko::dim<2>{n, k}, stride_A)
->as_const_dense_view()
->clone();
B_ = generator.create_multi_vector_strided(exec, gko::dim<2>{k, m},
gko::dim<2>{k, m}, stride_B);
C_ = generator.create_multi_vector_strided(exec, gko::dim<2>{n, m},
Expand Down Expand Up @@ -372,8 +378,8 @@ class AdvancedApplyOperation : public BenchmarkOperation {
std::unique_ptr<gko::matrix::MultiVector<etype>> alpha_;
std::unique_ptr<gko::matrix::MultiVector<etype>> beta_;
std::unique_ptr<gko::LinOp> A_;
std::unique_ptr<gko::LinOp> B_;
std::unique_ptr<gko::LinOp> C_;
std::unique_ptr<gko::AbstractMultiVector> B_;
std::unique_ptr<gko::AbstractMultiVector> C_;
};


Expand Down
6 changes: 3 additions & 3 deletions benchmark/preconditioner/preconditioner.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

Expand Down Expand Up @@ -101,8 +101,8 @@ std::string encode_parameters(const char* precond_name)


struct preconditioner_benchmark_state {
std::unique_ptr<gko::LinOp> x;
std::unique_ptr<gko::LinOp> b;
std::unique_ptr<gko::AbstractMultiVector> x;
std::unique_ptr<gko::AbstractMultiVector> b;
std::shared_ptr<const gko::LinOp> system_matrix;
};

Expand Down
3 changes: 2 additions & 1 deletion benchmark/solver/distributed/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ struct Generator : public DistributedDefaultSystemGenerator<SolverGenerator> {
if (FLAGS_rhs_generation == "sinus") {
gko::dim<2> vec_size{system_matrix->get_size()[0], FLAGS_nrhs};
gko::dim<2> local_vec_size{
gko::detail::get_local(system_matrix)->get_size()[1],
gko::experimental::distributed::detail::get_local(system_matrix)
->get_size()[1],
FLAGS_nrhs};
return create_normalized_manufactured_rhs(
exec, system_matrix,
Expand Down
11 changes: 7 additions & 4 deletions benchmark/solver/solver_common.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

Expand Down Expand Up @@ -321,7 +321,8 @@ struct SolverGenerator : DefaultSystemGenerator<> {
} else {
gko::dim<2> vec_size{system_matrix->get_size()[0], FLAGS_nrhs};
gko::dim<2> local_vec_size{
gko::detail::get_local(system_matrix)->get_size()[1],
gko::experimental::distributed::detail::get_local(system_matrix)
->get_size()[1],
FLAGS_nrhs};
if (FLAGS_rhs_generation == "1") {
return create_multi_vector(exec, vec_size, local_vec_size,
Expand All @@ -346,7 +347,9 @@ struct SolverGenerator : DefaultSystemGenerator<> {
{
gko::dim<2> vec_size{system_matrix->get_size()[1], FLAGS_nrhs};
gko::dim<2> local_vec_size{
gko::detail::get_local(system_matrix)->get_size()[1], FLAGS_nrhs};
gko::experimental::distributed::detail::get_local(system_matrix)
->get_size()[1],
FLAGS_nrhs};
if (FLAGS_initial_guess_generation == "0") {
return create_multi_vector(exec, vec_size, local_vec_size,
gko::zero<etype>());
Expand Down Expand Up @@ -432,7 +435,7 @@ struct SolverBenchmark : Benchmark<solver_benchmark_state<Generator>> {
solver_benchmark_state<Generator> state;

if (FLAGS_overhead) {
state.system_matrix = generator.initialize({1.0}, exec);
state.system_matrix = generator.generate_overhead_operator(exec);
state.b = generator.initialize(
{std::numeric_limits<rc_etype>::quiet_NaN()}, exec);
state.x = generator.initialize({0.0}, exec);
Expand Down
6 changes: 3 additions & 3 deletions benchmark/sparse_blas/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ class SpgeamOperation : public BenchmarkOperation {
{
auto ref = gko::ReferenceExecutor::create();
auto correct = gko::make_temporary_clone(ref, mtx2_);
gko::make_temporary_clone(ref, mtx_)->apply(scalar_, id_, scalar_,
correct.get());
gko::make_temporary_clone(ref, mtx_)->scale_add(scalar_, scalar_,
correct.get());
return validate_result(correct.get(), mtx_out_);
}

Expand Down Expand Up @@ -661,7 +661,7 @@ class SymbolicCholeskyOperation : public BenchmarkOperation {
{gko::one<etype>()}, exec);
const auto id =
gko::matrix::Identity<etype>::create(exec, mtx_->get_size()[0]);
lt_factor->apply(scalar, id, scalar, symm_result);
lt_factor->scale_add(scalar, scalar, symm_result);
return std::make_pair(
validate_symbolic_factorization(mtx_, symm_result.get()), 0.0);
}
Expand Down
6 changes: 3 additions & 3 deletions benchmark/test/reference/blas.profile.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Running on ReferenceExecutor
Running with 0 warm iterations and 1 running iterations
The random seed for right hand sides is 42
The operations are copy,axpy,scal
Running test case n = 100
DEBUG: begin n = 100
Running test case n = 100
DEBUG: begin n = 100
Running blas: copy
DEBUG: begin copy
DEBUG: begin multivector::fill
Expand Down Expand Up @@ -37,4 +37,4 @@ DEBUG: begin multivector::scale
DEBUG: end multivector::scale
DEBUG: end repetition
DEBUG: end scal
DEBUG: end n = 100
DEBUG: end n = 100
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Running on ReferenceExecutor
Running with 2 warm iterations and 10 running iterations
The random seed for right hand sides is 42
The operations are copy,axpy,scal
Running test case n = 100
Running test case n = 100
Running blas: copy
Running blas: axpy
Running blas: scal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Running on ReferenceExecutor
Running with 2 warm iterations and 10 running iterations
The random seed for right hand sides is 42
The operations are copy,axpy,scal
Running test case n = 100
Running test case n = 100
Running blas: copy
Running blas: axpy
Running blas: scal
33 changes: 20 additions & 13 deletions benchmark/utils/cuda_linops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class CusparseCsrEx
CusparseCsrEx& operator=(const CusparseCsrEx& other) = default;

protected:
void apply_impl(const gko::LinOp* b, gko::LinOp* x) const override
void apply_impl(const gko::AbstractMultiVector* b,
gko::AbstractMultiVector* x) const override
{
auto dense_b = gko::as<gko::matrix::MultiVector<ValueType>>(b);
auto dense_x = gko::as<gko::matrix::MultiVector<ValueType>>(x);
Expand Down Expand Up @@ -162,9 +163,10 @@ class CusparseCsrEx
// DEVICE for Ginkgo
}

void apply_impl(const gko::LinOp* alpha, const gko::LinOp* b,
const gko::LinOp* beta,
gko::LinOp* x) const override GKO_NOT_IMPLEMENTED;
void apply_impl(
const gko::AbstractMultiVector* alpha,
const gko::AbstractMultiVector* b, const gko::AbstractMultiVector* beta,
gko::AbstractMultiVector* x) const override GKO_NOT_IMPLEMENTED;

CusparseCsrEx(std::shared_ptr<const gko::Executor> exec,
const gko::dim<2>& size = gko::dim<2>{})
Expand Down Expand Up @@ -192,7 +194,8 @@ template <typename ValueType>
void cusparse_generic_spmv(std::shared_ptr<const gko::CudaExecutor> gpu_exec,
const cusparseSpMatDescr_t mat,
const gko::array<ValueType>& scalars,
const gko::LinOp* b, gko::LinOp* x,
const gko::AbstractMultiVector* b,
gko::AbstractMultiVector* x,
cusparseOperation_t trans, cusparseSpMVAlg_t alg)
{
cudaDataType_t cu_value = gko::kernels::cuda::cuda_data_type<ValueType>();
Expand Down Expand Up @@ -295,15 +298,17 @@ class CusparseGenericCsr
CusparseGenericCsr& operator=(const CusparseGenericCsr& other) = default;

protected:
void apply_impl(const gko::LinOp* b, gko::LinOp* x) const override
void apply_impl(const gko::AbstractMultiVector* b,
gko::AbstractMultiVector* x) const override
{
cusparse_generic_spmv(this->get_gpu_exec(), mat_, scalars, b, x, trans_,
Alg);
}

void apply_impl(const gko::LinOp* alpha, const gko::LinOp* b,
const gko::LinOp* beta,
gko::LinOp* x) const override GKO_NOT_IMPLEMENTED;
void apply_impl(
const gko::AbstractMultiVector* alpha,
const gko::AbstractMultiVector* b, const gko::AbstractMultiVector* beta,
gko::AbstractMultiVector* x) const override GKO_NOT_IMPLEMENTED;

CusparseGenericCsr(std::shared_ptr<const gko::Executor> exec,
const gko::dim<2>& size = gko::dim<2>{})
Expand Down Expand Up @@ -385,15 +390,17 @@ class CusparseGenericCoo
CusparseGenericCoo& operator=(const CusparseGenericCoo& other) = default;

protected:
void apply_impl(const gko::LinOp* b, gko::LinOp* x) const override
void apply_impl(const gko::AbstractMultiVector* b,
gko::AbstractMultiVector* x) const override
{
cusparse_generic_spmv(this->get_gpu_exec(), mat_, scalars, b, x, trans_,
default_csr_alg);
}

void apply_impl(const gko::LinOp* alpha, const gko::LinOp* b,
const gko::LinOp* beta,
gko::LinOp* x) const override GKO_NOT_IMPLEMENTED;
void apply_impl(
const gko::AbstractMultiVector* alpha,
const gko::AbstractMultiVector* b, const gko::AbstractMultiVector* beta,
gko::AbstractMultiVector* x) const override GKO_NOT_IMPLEMENTED;

CusparseGenericCoo(std::shared_ptr<const gko::Executor> exec,
const gko::dim<2>& size = gko::dim<2>{})
Expand Down
3 changes: 2 additions & 1 deletion benchmark/utils/dpcpp_linops.dp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ class OnemklCsr : public OnemklBase,
}

protected:
void apply_impl(const gko::LinOp* b, gko::LinOp* x) const override
void apply_impl(const gko::AbstractMultiVector* b,
gko::AbstractMultiVector* x) const override
{
auto dense_b = gko::as<gko::matrix::MultiVector<ValueType>>(b);
auto dense_x = gko::as<gko::matrix::MultiVector<ValueType>>(x);
Expand Down
18 changes: 8 additions & 10 deletions benchmark/utils/general.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,8 @@ ValueType get_norm(const vec<ValueType>* norm)
}


template <typename VectorType,
typename ValueType = typename VectorType::value_type>
gko::remove_complex<ValueType> compute_norm2(const VectorType* b)
template <typename ValueType = etype>
gko::remove_complex<ValueType> compute_norm2(const gko::AbstractMultiVector* b)
{
auto exec = b->get_executor();
auto b_norm =
Expand All @@ -484,10 +483,10 @@ gko::remove_complex<ValueType> compute_direct_error(const gko::LinOp* solver,
}


template <typename VectorType,
typename ValueType = typename VectorType::value_type>
template <typename ValueType = etype>
gko::remove_complex<ValueType> compute_residual_norm(
const gko::LinOp* system_matrix, const VectorType* b, const VectorType* x)
const gko::LinOp* system_matrix, const gko::AbstractMultiVector* b,
const gko::AbstractMultiVector* x)
{
auto exec = system_matrix->get_executor();
auto one = gko::initialize<vec<ValueType>>({1.0}, exec);
Expand Down Expand Up @@ -519,10 +518,9 @@ gko::remove_complex<ValueType> compute_max_relative_norm2(
clone(absolute_norm->get_executor()->get_master(), absolute_norm);
rc_vtype max_relative_norm2 = 0;
for (gko::size_type i = 0; i < host_answer_norm->get_size()[1]; i++) {
max_relative_norm2 = std::max(
gko::detail::get_local(host_absolute_norm.get())->at(0, i) /
gko::detail::get_local(host_answer_norm.get())->at(0, i),
max_relative_norm2);
max_relative_norm2 =
std::max(host_absolute_norm->at(0, i) / host_answer_norm->at(0, i),
max_relative_norm2);
Comment on lines +521 to +523

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compute_norm will return multivector no matter it is distributed or not

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, all reductions (compute_dot/compute_norm) use gko::matrix::MultiVector for their result. This is also how it is currently. Maybe if we have a column distributed vector it would make sense to return something else, but for now it doesn't.

}
return max_relative_norm2;
}
Expand Down
18 changes: 18 additions & 0 deletions benchmark/utils/generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ struct DefaultSystemGenerator {
local_size);
}

static std::shared_ptr<gko::LinOp> generate_overhead_operator(
std::shared_ptr<const gko::Executor> exec)
{
return gko::matrix::Dense<etype>::create(std::move(exec),
gko::dim<2>{1, 1});
}

static gko::dim<2> create_default_local_size(gko::dim<2> global_size)
{
return global_size;
Expand Down Expand Up @@ -285,6 +292,17 @@ struct DistributedDefaultSystemGenerator {
local_size);
}

std::shared_ptr<gko::LinOp> generate_overhead_operator(
std::shared_ptr<gko::Executor> exec) const
{
auto global_size = static_cast<gko::size_type>(comm.size());
return generate_matrix_with_default_format(
std::move(exec),
gko::matrix_data<value_type, global_itype>{
gko::dim<2>{global_size, global_size}},
gko::dim<2>{1, 1});
}

gko::dim<2> create_default_local_size(gko::dim<2> global_size) const
{
// This computes Partition::build_from_global_size_uniform manually,
Expand Down
Loading
Loading