Skip to content

Commit

Permalink
Simplify core code and remove kernels.
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikvn committed Apr 4, 2022
1 parent 960c57a commit de6e23c
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 436 deletions.
1 change: 0 additions & 1 deletion common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ set(UNIFIED_SOURCES
matrix/sellp_kernels.cpp
matrix/diagonal_kernels.cpp
multigrid/amgx_pgm_kernels.cpp
multigrid/fixed_coarsening_kernels.cpp
preconditioner/jacobi_kernels.cpp
solver/bicg_kernels.cpp
solver/bicgstab_kernels.cpp
Expand Down
107 changes: 0 additions & 107 deletions common/unified/multigrid/fixed_coarsening_kernels.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions core/device_hooks/common_kernels.inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/matrix/sellp_kernels.hpp"
#include "core/matrix/sparsity_csr_kernels.hpp"
#include "core/multigrid/amgx_pgm_kernels.hpp"
#include "core/multigrid/fixed_coarsening_kernels.hpp"
#include "core/preconditioner/isai_kernels.hpp"
#include "core/preconditioner/jacobi_kernels.hpp"
#include "core/reorder/rcm_kernels.hpp"
Expand Down Expand Up @@ -749,16 +748,6 @@ GKO_STUB_NON_COMPLEX_VALUE_AND_INDEX_TYPE(
} // namespace amgx_pgm


namespace fixed_coarsening {


GKO_STUB_VALUE_AND_INDEX_TYPE(GKO_DECLARE_FIXED_COARSENING_FILL_RESTRICT_OP);
GKO_STUB_INDEX_TYPE(GKO_DECLARE_FIXED_COARSENING_FILL_COARSE_INDICES);


} // namespace fixed_coarsening


namespace set_all_statuses {


Expand Down
15 changes: 3 additions & 12 deletions core/multigrid/fixed_coarsening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/base/utils.hpp"
#include "core/components/fill_array_kernels.hpp"
#include "core/matrix/csr_builder.hpp"
#include "core/multigrid/fixed_coarsening_kernels.hpp"


namespace gko {
Expand All @@ -58,9 +57,6 @@ namespace fixed_coarsening {
namespace {


GKO_REGISTER_OPERATION(fill_restrict_op, fixed_coarsening::fill_restrict_op);
GKO_REGISTER_OPERATION(fill_coarse_indices,
fixed_coarsening::fill_coarse_indices);
GKO_REGISTER_OPERATION(fill_array, components::fill_array);
GKO_REGISTER_OPERATION(fill_seq_array, components::fill_seq_array);

Expand Down Expand Up @@ -93,20 +89,15 @@ void FixedCoarsening<ValueType, IndexType>::generate()

GKO_ASSERT(parameters_.coarse_rows.get_data() != nullptr);
GKO_ASSERT(parameters_.coarse_rows.get_num_elems() > 0);
coarse_rows_ = gko::Array<IndexType>(exec, num_rows);
exec->run(fixed_coarsening::make_fill_array(coarse_rows_.get_data(),
num_rows, -one<IndexType>()));
// Fill with coarse rows converted to local indices.
size_type coarse_dim = parameters_.coarse_rows.get_num_elems();
exec->run(fixed_coarsening::make_fill_coarse_indices(
&parameters_.coarse_rows, &coarse_rows_));

auto fine_dim = system_matrix_->get_size()[0];
auto restrict_op = share(
csr_type::create(exec, gko::dim<2>{coarse_dim, fine_dim}, coarse_dim,
fixed_coarsening_op->get_strategy()));
exec->run(fixed_coarsening::make_fill_restrict_op(&coarse_rows_,
restrict_op.get()));
exec->copy_from(parameters_.coarse_rows.get_executor().get(), coarse_dim,
parameters_.coarse_rows.get_const_data(),
restrict_op->get_col_idxs());
exec->run(fixed_coarsening::make_fill_array(restrict_op->get_values(),
coarse_dim, one<ValueType>()));
exec->run(fixed_coarsening::make_fill_seq_array(restrict_op->get_row_ptrs(),
Expand Down
87 changes: 0 additions & 87 deletions core/multigrid/fixed_coarsening_kernels.hpp

This file was deleted.

23 changes: 1 addition & 22 deletions include/ginkgo/core/multigrid/fixed_coarsening.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,6 @@ class FixedCoarsening
return system_matrix_;
}

/**
* Returns the selected coarse rows.
*
* @return the selected coarse rows.
*/
IndexType* get_coarse_rows() noexcept { return coarse_rows_.get_data(); }

/**
* @copydoc FixedCoarsening::get_coarse_rows()
*
* @note This is the constant version of the function, which can be
* significantly more memory efficient than the non-constant version,
* so always prefer this version.
*/
const IndexType* get_const_coarse_rows() const noexcept
{
return coarse_rows_.get_const_data();
}


GKO_CREATE_FACTORY_PARAMETERS(parameters, Factory)
{
Expand Down Expand Up @@ -146,8 +127,7 @@ class FixedCoarsening
system_matrix->get_size()),
EnableMultigridLevel<ValueType>(system_matrix),
parameters_{factory->get_parameters()},
system_matrix_{system_matrix},
coarse_rows_(factory->get_executor(), system_matrix_->get_size()[0])
system_matrix_{system_matrix}
{
if (system_matrix_->get_size()[0] != 0) {
// generate on the existing matrix
Expand All @@ -159,7 +139,6 @@ class FixedCoarsening

private:
std::shared_ptr<const LinOp> system_matrix_{};
Array<IndexType> coarse_rows_;
};


Expand Down
1 change: 1 addition & 0 deletions include/ginkgo/ginkgo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/matrix/sparsity_csr.hpp>

#include <ginkgo/core/multigrid/amgx_pgm.hpp>
#include <ginkgo/core/multigrid/fixed_coarsening.hpp>
#include <ginkgo/core/multigrid/multigrid_level.hpp>

#include <ginkgo/core/preconditioner/ic.hpp>
Expand Down
1 change: 0 additions & 1 deletion reference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ target_sources(ginkgo_reference
matrix/sellp_kernels.cpp
matrix/sparsity_csr_kernels.cpp
multigrid/amgx_pgm_kernels.cpp
multigrid/fixed_coarsening_kernels.cpp
preconditioner/isai_kernels.cpp
preconditioner/jacobi_kernels.cpp
reorder/rcm_kernels.cpp
Expand Down
Loading

0 comments on commit de6e23c

Please sign in to comment.