Skip to content
Open
1 change: 1 addition & 0 deletions common/unified/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set(UNIFIED_SOURCES
matrix/diagonal_kernels.cpp
multigrid/pgm_kernels.cpp
multigrid/rs_kernels.cpp
multigrid/uniform_coarsening_kernels.cpp
preconditioner/jacobi_kernels.cpp
solver/bicg_kernels.cpp
solver/bicgstab_kernels.cpp
Expand Down
63 changes: 63 additions & 0 deletions common/unified/multigrid/uniform_coarsening_kernels.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

#include "core/multigrid/uniform_coarsening_kernels.hpp"

#include <ginkgo/core/base/math.hpp>

#include "common/unified/base/kernel_launch.hpp"
#include "common/unified/base/kernel_launch_reduction.hpp"
#include "core/components/prefix_sum_kernels.hpp"


namespace gko {
namespace kernels {
namespace GKO_DEVICE_NAMESPACE {
namespace uniform_coarsening {


template <typename ValueType, typename IndexType>
void fill_restrict_op(std::shared_ptr<const DefaultExecutor> exec,
const array<IndexType>* coarse_rows,
matrix::Csr<ValueType, IndexType>* restrict_op)
{
run_kernel(
exec,
[] GKO_KERNEL(auto tidx, const auto coarse_data,
auto restrict_col_idxs) {
if (coarse_data[tidx] >= 0) {
restrict_col_idxs[coarse_data[tidx]] = tidx;
}
},
coarse_rows->get_size(), coarse_rows->get_const_data(),
restrict_op->get_col_idxs());
}

GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
GKO_DECLARE_UNIFORM_COARSENING_FILL_RESTRICT_OP);


template <typename IndexType>
void fill_incremental_indices(std::shared_ptr<const DefaultExecutor> exec,
size_type coarse_skip,
array<IndexType>* coarse_rows)
{
const size_type num_elems = coarse_rows->get_size();
const size_type num_iters = gko::ceildiv(num_elems, coarse_skip);
run_kernel(
exec,
[] GKO_KERNEL(auto tidx, auto coarse_skip, auto coarse_data) {
coarse_data[tidx * coarse_skip] = tidx;
},
num_iters, coarse_skip, coarse_rows->get_data());
}

GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE(
GKO_DECLARE_UNIFORM_COARSENING_FILL_INCREMENTAL_INDICES);


} // namespace uniform_coarsening
} // namespace GKO_DEVICE_NAMESPACE
} // namespace kernels
} // namespace gko
1 change: 1 addition & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ target_sources(
multigrid/fixed_coarsening.cpp
multigrid/pgm.cpp
multigrid/rs.cpp
multigrid/uniform_coarsening.cpp
preconditioner/batch_jacobi.cpp
preconditioner/gauss_seidel.cpp
preconditioner/ic.cpp
Expand Down
1 change: 1 addition & 0 deletions core/config/config_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ enum class LinOpFactoryType : int {
Multigrid,
Pgm,
Rs,
UniformCoarsening,
Schwarz
};

Expand Down
3 changes: 3 additions & 0 deletions core/config/multigrid_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <ginkgo/core/multigrid/pgm.hpp>
#include <ginkgo/core/multigrid/rs.hpp>
#include <ginkgo/core/multigrid/uniform_coarsening.hpp>

#include "core/config/parse_macro.hpp"

Expand All @@ -14,6 +15,8 @@ namespace config {

GKO_PARSE_VALUE_AND_INDEX_TYPE(Pgm, gko::multigrid::Pgm);
GKO_PARSE_VALUE_AND_INDEX_TYPE(Rs, gko::multigrid::Rs);
GKO_PARSE_VALUE_AND_INDEX_TYPE(UniformCoarsening,
gko::multigrid::UniformCoarsening);


} // namespace config
Expand Down
2 changes: 2 additions & 0 deletions core/config/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ configuration_map generate_config_map()
{"solver::Multigrid", parse<LinOpFactoryType::Multigrid>},
{"multigrid::Pgm", parse<LinOpFactoryType::Pgm>},
{"multigrid::Rs", parse<LinOpFactoryType::Rs>},
{"multigrid::UniformCoarsening",
Comment thread
yhmtsai marked this conversation as resolved.
parse<LinOpFactoryType::UniformCoarsening>},
#if GINKGO_BUILD_MPI
{
"preconditioner::Schwarz", parse<LinOpFactoryType::Schwarz>
Expand Down
11 changes: 11 additions & 0 deletions core/device_hooks/common_kernels.inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "core/matrix/sparsity_csr_kernels.hpp"
#include "core/multigrid/pgm_kernels.hpp"
#include "core/multigrid/rs_kernels.hpp"
#include "core/multigrid/uniform_coarsening_kernels.hpp"
#include "core/preconditioner/batch_jacobi_kernels.hpp"
#include "core/preconditioner/isai_kernels.hpp"
#include "core/preconditioner/jacobi_kernels.hpp"
Expand Down Expand Up @@ -1154,6 +1155,16 @@ GKO_STUB_VALUE_AND_INDEX_TYPE(GKO_DECLARE_RS_COMPUTE_INTERPOLATION_KERNEL);
} // namespace rs


namespace uniform_coarsening {


GKO_STUB_VALUE_AND_INDEX_TYPE(GKO_DECLARE_UNIFORM_COARSENING_FILL_RESTRICT_OP);
GKO_STUB_INDEX_TYPE(GKO_DECLARE_UNIFORM_COARSENING_FILL_INCREMENTAL_INDICES);


} // namespace uniform_coarsening


namespace set_all_statuses {


Expand Down
Loading
Loading