Skip to content

Commit

Permalink
Array to array fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikvn committed Jun 21, 2022
1 parent 911740a commit c2ac3f8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 33 deletions.
4 changes: 2 additions & 2 deletions common/unified/multigrid/uniform_coarsening_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace uniform_coarsening {

template <typename ValueType, typename IndexType>
void fill_restrict_op(std::shared_ptr<const DefaultExecutor> exec,
const Array<IndexType>* coarse_rows,
const array<IndexType>* coarse_rows,
matrix::Csr<ValueType, IndexType>* restrict_op)
{
run_kernel(
Expand All @@ -76,7 +76,7 @@ GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
template <typename IndexType>
void fill_incremental_indices(std::shared_ptr<const DefaultExecutor> exec,
size_type num_jumps,
Array<IndexType>* coarse_rows)
array<IndexType>* coarse_rows)
{
IndexType num_elems = (coarse_rows->get_num_elems());
run_kernel(
Expand Down
4 changes: 2 additions & 2 deletions core/multigrid/uniform_coarsening_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ namespace uniform_coarsening {

#define GKO_DECLARE_UNIFORM_COARSENING_FILL_RESTRICT_OP(ValueType, IndexType) \
void fill_restrict_op(std::shared_ptr<const DefaultExecutor> exec, \
const Array<IndexType>* coarse_rows, \
const array<IndexType>* coarse_rows, \
matrix::Csr<ValueType, IndexType>* restrict_op)

#define GKO_DECLARE_UNIFORM_COARSENING_FILL_INCREMENTAL_INDICES(IndexType) \
void fill_incremental_indices(std::shared_ptr<const DefaultExecutor> exec, \
size_type num_jumps, \
Array<IndexType>* coarse_rows)
array<IndexType>* coarse_rows)


#define GKO_DECLARE_ALL_AS_TEMPLATES \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ int main(int argc, char* argv[])

// Prepare the stopping criteria
const gko::remove_complex<ValueType> tolerance = 1e-8;
auto iter_stop =
gko::share(gko::stop::Iteration::build().with_max_iters(100u).on(exec));
auto iter_stop = gko::share(
gko::stop::Iteration::build().with_max_iters(1000u).on(exec));
auto tol_stop =
gko::share(gko::stop::AbsoluteResidualNorm<ValueType>::build()
.with_tolerance(tolerance)
Expand Down Expand Up @@ -196,33 +196,31 @@ int main(int argc, char* argv[])
.with_min_coarse_rows(10u)
.with_pre_smoother(smoother_gen)
.with_post_uses_pre(true)
.with_mg_level(gko::share(mg_level_gen))
.with_mg_level(mg_level_gen)
.with_coarsest_solver(coarsest_gen)
.with_zero_guess(true)
.with_criteria(iter_stop, tol_stop)
.on(exec));
if (use_uniform_coarsening) {
std::cout << "Using Uniform Coarsening" << std::endl;
multigrid_gen =
gko::share(mg::build()
.with_max_levels(10u)
.with_min_coarse_rows(10u)
.with_pre_smoother(smoother_gen)
.with_post_uses_pre(true)
.with_mg_level(gko::share(coarse_unif_gen))
.with_coarsest_solver(coarsest_gen)
.with_zero_guess(true)
.with_criteria(iter_stop, tol_stop)
.on(exec));
multigrid_gen = gko::share(mg::build()
.with_max_levels(10u)
.with_min_coarse_rows(10u)
.with_pre_smoother(smoother_gen)
.with_post_uses_pre(true)
.with_mg_level(coarse_unif_gen)
.with_coarsest_solver(coarsest_gen)
.with_zero_guess(true)
.with_criteria(iter_stop, tol_stop)
.on(exec));
} else {
std::cout << "Using AMGX " << std::endl;
}
// Create solver factory
auto solver_gen =
cg::build()
.with_criteria(gko::share(iter_stop), gko::share(tol_stop))
.with_preconditioner(multigrid_gen)
.on(exec);
auto solver_gen = cg::build()
.with_criteria(iter_stop, tol_stop)
.with_preconditioner(multigrid_gen)
.on(exec);
// Create solver
std::chrono::nanoseconds gen_time(0);
auto gen_tic = std::chrono::steady_clock::now();
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/multigrid/uniform_coarsening.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class UniformCoarsening

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


Expand Down
4 changes: 2 additions & 2 deletions reference/multigrid/uniform_coarsening_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace uniform_coarsening {

template <typename ValueType, typename IndexType>
void fill_restrict_op(std::shared_ptr<const DefaultExecutor> exec,
const Array<IndexType>* coarse_rows,
const array<IndexType>* coarse_rows,
matrix::Csr<ValueType, IndexType>* restrict_op)
{
auto num_rows = restrict_op->get_size()[0];
Expand All @@ -86,7 +86,7 @@ GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
template <typename IndexType>
void fill_incremental_indices(std::shared_ptr<const DefaultExecutor> exec,
size_type num_jumps,
Array<IndexType>* coarse_rows)
array<IndexType>* coarse_rows)
{
for (IndexType i = 0; i < coarse_rows->get_num_elems(); i += num_jumps) {
coarse_rows->get_data()[i] = i / num_jumps;
Expand Down
14 changes: 7 additions & 7 deletions test/multigrid/uniform_coarsening_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ class UniformCoarsening : public ::testing::Test {
}
}

gko::Array<index_type> gen_coarse_array(gko::size_type num,
gko::array<index_type> gen_coarse_array(gko::size_type num,
gko::size_type num_jumps)
{
gko::Array<index_type> coarse_array(ref, num);
gko::array<index_type> coarse_array(ref, num);
coarse_array.fill(-1);
// the aggregated group must contain the identifier-th element
// agg_val[i] == i holds in the aggregated group whose identifier is i
Expand All @@ -117,7 +117,7 @@ class UniformCoarsening : public ::testing::Test {
coarse_rows = gen_coarse_array(m, num_jumps);
c_dim = (coarse_rows.get_num_elems() + 1) / num_jumps;

d_coarse_rows = gko::Array<index_type>(exec);
d_coarse_rows = gko::array<index_type>(exec);
d_coarse_rows = coarse_rows;
restrict_op = Csr::create(ref, gko::dim<2>(c_dim, m), c_dim);

Expand All @@ -135,8 +135,8 @@ class UniformCoarsening : public ::testing::Test {

std::default_random_engine rand_engine;

gko::Array<index_type> coarse_rows;
gko::Array<index_type> d_coarse_rows;
gko::array<index_type> coarse_rows;
gko::array<index_type> d_coarse_rows;

std::shared_ptr<Csr> restrict_op;
std::shared_ptr<Csr> d_restrict_op;
Expand All @@ -152,9 +152,9 @@ class UniformCoarsening : public ::testing::Test {

TEST_F(UniformCoarsening, FillIncrementalIndicesIsEquivalentToRef)
{
auto c_rows = gko::Array<index_type>(ref, m);
auto c_rows = gko::array<index_type>(ref, m);
c_rows.fill(-gko::one<index_type>());
auto d_c_rows = gko::Array<index_type>(exec, c_rows);
auto d_c_rows = gko::array<index_type>(exec, c_rows);

{
gko::size_type num_jumps = 2;
Expand Down

0 comments on commit c2ac3f8

Please sign in to comment.