Skip to content

Commit

Permalink
First working apply for small problem
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzgoebel committed Feb 10, 2025
1 parent 8a3296b commit 9d9a57d
Show file tree
Hide file tree
Showing 11 changed files with 346 additions and 130 deletions.
19 changes: 10 additions & 9 deletions common/cuda_hip/distributed/preconditioner/bddc_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ void classify_dofs(
const matrix::Dense<ValueType>* labels, comm_index_type local_part,
array<experimental::distributed::preconditioner::dof_type>& dof_types,
array<IndexType>& permutation_array, array<IndexType>& interface_sizes,
array<ValueType>& owning_labels, size_type& n_inner_idxs,
size_type& n_face_idxs, size_type& n_edge_idxs, size_type& n_vertices,
size_type& n_faces, size_type& n_edges, size_type& n_constraints,
int& n_owning_interfaces) GKO_NOT_IMPLEMENTED;
array<ValueType>& unique_labels, array<ValueType>& owning_labels,
size_type& n_inner_idxs, size_type& n_face_idxs, size_type& n_edge_idxs,
size_type& n_vertices, size_type& n_faces, size_type& n_edges,
size_type& n_constraints, int& n_owning_interfaces) GKO_NOT_IMPLEMENTED;

GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_AND_INDEX_TYPE_BASE(
GKO_DECLARE_CLASSIFY_DOFS);
Expand All @@ -53,16 +53,17 @@ void fill_coarse_data(std::shared_ptr<const DefaultExecutor> exec,
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_BASE(GKO_DECLARE_FILL_COARSE_DATA);


template <typename ValueType>
template <typename ValueType, typename IndexType>
void build_coarse_contribution(
std::shared_ptr<const DefaultExecutor> exec,
const matrix::Dense<remove_complex<ValueType>>* local_labels,
const array<remove_complex<ValueType>>& local_labels,
const array<remove_complex<ValueType>>& global_labels,
const matrix::Dense<ValueType>* lambda,
device_matrix_data<ValueType, int>& coarse_contribution)
GKO_NOT_IMPLEMENTED;
device_matrix_data<ValueType, int>& coarse_contribution,
array<IndexType>& permutation_array) GKO_NOT_IMPLEMENTED;

GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_BASE(GKO_DECLARE_BUILD_COARSE_CONTRIBUTION);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE_BASE(
GKO_DECLARE_BUILD_COARSE_CONTRIBUTION);


} // namespace bddc
Expand Down
2 changes: 1 addition & 1 deletion core/device_hooks/common_kernels.inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ GKO_STUB_NON_COMPLEX_VALUE_AND_INDEX_TYPE_BASE(GKO_DECLARE_CLASSIFY_DOFS);
GKO_STUB_NON_COMPLEX_VALUE_AND_INDEX_TYPE_BASE(
GKO_DECLARE_GENERATE_CONSTRAINTS);
GKO_STUB_VALUE_TYPE_BASE(GKO_DECLARE_FILL_COARSE_DATA);
GKO_STUB_VALUE_TYPE_BASE(GKO_DECLARE_BUILD_COARSE_CONTRIBUTION);
GKO_STUB_VALUE_AND_INDEX_TYPE_BASE(GKO_DECLARE_BUILD_COARSE_CONTRIBUTION);


} // namespace bddc
Expand Down
1 change: 1 addition & 0 deletions core/distributed/dd_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ void DdMatrix<ValueType, LocalIndexType, GlobalIndexType>::read_distributed(
exec, dim<2>{row_partition->get_size(), large_partition->get_size()},
std::move(prolongate_row_idxs), std::move(prolongate_col_idxs),
std::move(prolongate_values)};
prolongate_data.sort_row_major();
prolongation_ =
Matrix<ValueType, LocalIndexType, GlobalIndexType>::create(exec, comm);
prolongation_->read_distributed(prolongate_data, row_partition,
Expand Down
258 changes: 208 additions & 50 deletions core/distributed/preconditioner/bddc.cpp

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions core/distributed/preconditioner/bddc_kernels.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

Expand Down Expand Up @@ -28,10 +28,10 @@ namespace kernels {
const matrix::Dense<ValueType>* labels, comm_index_type local_part, \
array<experimental::distributed::preconditioner::dof_type>& dof_types, \
array<IndexType>& permutation_array, \
array<IndexType>& interface_sizes, array<ValueType>& owning_labels, \
size_type& n_inner_idxs, size_type& n_face_idxs, \
size_type& n_edge_idxs, size_type& n_vertices, size_type& n_faces, \
size_type& n_edges, size_type& n_constraints, \
array<IndexType>& interface_sizes, array<ValueType>& unique_labels, \
array<ValueType>& owning_labels, size_type& n_inner_idxs, \
size_type& n_face_idxs, size_type& n_edge_idxs, size_type& n_vertices, \
size_type& n_faces, size_type& n_edges, size_type& n_constraints, \
int& n_owning_interfaces)


Expand All @@ -49,13 +49,14 @@ namespace kernels {
matrix::Dense<ValueType>* lambda_rhs)


#define GKO_DECLARE_BUILD_COARSE_CONTRIBUTION(ValueType) \
void build_coarse_contribution( \
std::shared_ptr<const DefaultExecutor> exec, \
const matrix::Dense<remove_complex<ValueType>>* local_labels, \
const array<remove_complex<ValueType>>& global_labels, \
const matrix::Dense<ValueType>* lambda, \
device_matrix_data<ValueType, int>& coarse_contribution)
#define GKO_DECLARE_BUILD_COARSE_CONTRIBUTION(ValueType, IndexType) \
void build_coarse_contribution( \
std::shared_ptr<const DefaultExecutor> exec, \
const array<remove_complex<ValueType>>& local_labels, \
const array<remove_complex<ValueType>>& global_labels, \
const matrix::Dense<ValueType>* lambda, \
device_matrix_data<ValueType, int>& coarse_contribution, \
array<IndexType>& permutation_array)


#define GKO_DECLARE_ALL_AS_TEMPLATES \
Expand All @@ -66,8 +67,8 @@ namespace kernels {
GKO_DECLARE_GENERATE_CONSTRAINTS(ValueType, IndexType); \
template <typename ValueType> \
GKO_DECLARE_FILL_COARSE_DATA(ValueType); \
template <typename ValueType> \
GKO_DECLARE_BUILD_COARSE_CONTRIBUTION(ValueType)
template <typename ValueType, typename IndexType> \
GKO_DECLARE_BUILD_COARSE_CONTRIBUTION(ValueType, IndexType)


GKO_DECLARE_FOR_ALL_EXECUTOR_NAMESPACES(bddc, GKO_DECLARE_ALL_AS_TEMPLATES);
Expand Down
19 changes: 10 additions & 9 deletions dpcpp/distributed/preconditioner/bddc_kernels.dp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ void classify_dofs(
const matrix::Dense<ValueType>* labels, comm_index_type local_part,
array<experimental::distributed::preconditioner::dof_type>& dof_types,
array<IndexType>& permutation_array, array<IndexType>& interface_sizes,
array<ValueType>& owning_labels, size_type& n_inner_idxs,
size_type& n_face_idxs, size_type& n_edge_idxs, size_type& n_vertices,
size_type& n_faces, size_type& n_edges, size_type& n_constraints,
int& n_owning_interfaces) GKO_NOT_IMPLEMENTED;
array<ValueType>& unique_labels, array<ValueType>& owning_labels,
size_type& n_inner_idxs, size_type& n_face_idxs, size_type& n_edge_idxs,
size_type& n_vertices, size_type& n_faces, size_type& n_edges,
size_type& n_constraints, int& n_owning_interfaces) GKO_NOT_IMPLEMENTED;

GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_AND_INDEX_TYPE_BASE(
GKO_DECLARE_CLASSIFY_DOFS);
Expand All @@ -53,16 +53,17 @@ void fill_coarse_data(std::shared_ptr<const DefaultExecutor> exec,
GKO_INSTANTIATE_FOR_EACH_VALUE_TYP_BASE_BASE(GKO_DECLARE_FILL_COARSE_DATA);


template <typename ValueType>
template <typename ValueType, typename IndexType>
void build_coarse_contribution(
std::shared_ptr<const DefaultExecutor> exec,
const matrix::Dense<remove_complex<ValueType>>* local_labels,
const array<remove_complex<ValueType>>& local_labels,
const array<remove_complex<ValueType>>& global_labels,
const matrix::Dense<ValueType>* lambda,
device_matrix_data<ValueType, int>& coarse_contribution)
GKO_NOT_IMPLEMENTED;
device_matrix_data<ValueType, int>& coarse_contribution,
array<IndexType>& permutation_array) GKO_NOT_IMPLEMENTED;

GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_BASE(GKO_DECLARE_BUILD_COARSE_CONTRIBUTION);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE_BASE(
GKO_DECLARE_BUILD_COARSE_CONTRIBUTION);


} // namespace bddc
Expand Down
37 changes: 30 additions & 7 deletions include/ginkgo/core/distributed/preconditioner/bddc.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

Expand Down Expand Up @@ -102,6 +102,11 @@ class Bddc
* Use of Face constraints.
*/
bool GKO_FACTORY_PARAMETER_SCALAR(faces, true);

/**
* Use of AMD reordering to reduce fill-in for local direct solvers.
*/
bool GKO_FACTORY_PARAMETER_SCALAR(amd, true);
};
GKO_ENABLE_LIN_OP_FACTORY(Bddc, parameters, Factory);
GKO_ENABLE_BUILD_METHOD(Factory);
Expand Down Expand Up @@ -192,17 +197,35 @@ class Bddc
std::shared_ptr<vec> coarse_buf_1_;
std::shared_ptr<vec> coarse_buf_2_;
std::shared_ptr<local_vec> local_buf_1_;
std::shared_ptr<local_vec> interior_1_;
std::shared_ptr<local_vec> bndry_1_;
std::shared_ptr<local_vec> dual_1_;
std::shared_ptr<local_vec> primal_1_;
std::shared_ptr<local_vec> local_buf_2_;
std::shared_ptr<local_vec> interior_2_;
std::shared_ptr<local_vec> bndry_2_;
std::shared_ptr<local_vec> dual_2_;
std::shared_ptr<local_vec> primal_2_;
std::shared_ptr<local_vec> local_buf_3_;
std::shared_ptr<local_vec> interior_3_;
std::shared_ptr<local_vec> bndry_3_;
std::shared_ptr<local_vec> dual_3_;
std::shared_ptr<local_vec> primal_3_;
std::shared_ptr<local_vec> schur_buf_1_;
std::shared_ptr<local_vec> schur_buf_2_;
std::shared_ptr<vec> broken_coarse_buf_1_;
std::shared_ptr<vec> broken_coarse_buf_2_;
std::shared_ptr<local_vec> local_coarse_buf_1_;
std::shared_ptr<local_vec> local_coarse_buf_2_;
std::shared_ptr<const LinOp> A_LL;
std::shared_ptr<const LinOp> A_LP;
std::shared_ptr<const LinOp> A_PL;
std::shared_ptr<const LinOp> A_PP;
std::shared_ptr<const LinOp> A_IB;
std::shared_ptr<const LinOp> A_BI;
std::shared_ptr<local_mtx> A_LL;
std::shared_ptr<const local_mtx> A_LP;
std::shared_ptr<const local_mtx> A_PL;
std::shared_ptr<const local_mtx> A_PP;
std::shared_ptr<const local_mtx> A_IB;
std::shared_ptr<const local_mtx> A_BI;
std::shared_ptr<const LinOp> one_;
std::shared_ptr<const LinOp> neg_one_;
std::shared_ptr<const LinOp> zero_;
};


Expand Down
19 changes: 10 additions & 9 deletions omp/distributed/preconditioner/bddc_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ void classify_dofs(
const matrix::Dense<ValueType>* labels, comm_index_type local_part,
array<experimental::distributed::preconditioner::dof_type>& dof_types,
array<IndexType>& permutation_array, array<IndexType>& interface_sizes,
array<ValueType>& owning_labels, size_type& n_inner_idxs,
size_type& n_face_idxs, size_type& n_edge_idxs, size_type& n_vertices,
size_type& n_faces, size_type& n_edges, size_type& n_constraints,
int& n_owning_interfaces) GKO_NOT_IMPLEMENTED;
array<ValueType>& unique_labels, array<ValueType>& owning_labels,
size_type& n_inner_idxs, size_type& n_face_idxs, size_type& n_edge_idxs,
size_type& n_vertices, size_type& n_faces, size_type& n_edges,
size_type& n_constraints, int& n_owning_interfaces) GKO_NOT_IMPLEMENTED;

GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_AND_INDEX_TYPE_BASE(
GKO_DECLARE_CLASSIFY_DOFS);
Expand All @@ -53,16 +53,17 @@ void fill_coarse_data(std::shared_ptr<const DefaultExecutor> exec,
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_BASE(GKO_DECLARE_FILL_COARSE_DATA);


template <typename ValueType>
template <typename ValueType, typename IndexType>
void build_coarse_contribution(
std::shared_ptr<const DefaultExecutor> exec,
const matrix::Dense<remove_complex<ValueType>>* local_labels,
const array<remove_complex<ValueType>>& local_labels,
const array<remove_complex<ValueType>>& global_labels,
const matrix::Dense<ValueType>* lambda,
device_matrix_data<ValueType, int>& coarse_contribution)
GKO_NOT_IMPLEMENTED;
device_matrix_data<ValueType, int>& coarse_contribution,
array<IndexType>& permutation_array) GKO_NOT_IMPLEMENTED;

GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_BASE(GKO_DECLARE_BUILD_COARSE_CONTRIBUTION);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE_BASE(
GKO_DECLARE_BUILD_COARSE_CONTRIBUTION);


} // namespace bddc
Expand Down
5 changes: 3 additions & 2 deletions reference/distributed/index_map_kernels.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

Expand Down Expand Up @@ -220,7 +220,7 @@ void map_to_global(
auto map_local = [&](auto lid) {
if (0 <= lid && lid < local_size) {
local_range_id =
find_local_range(lid, rank, partition, local_range_id);
find_local_range(lid, rank, partition, 0); // local_range_id);
return map_to_global(lid, partition,
local_ranges.begin[local_range_id]);
} else {
Expand Down Expand Up @@ -262,6 +262,7 @@ void map_to_global(
for (size_type i = 0; i < local_ids.get_size(); ++i) {
auto lid = local_ids.get_const_data()[i];
global_ids.get_data()[i] = map_combined(lid);
// std::cout << lid << " ==> " << map_combined(lid) << std::endl;
}
}
}
Expand Down
Loading

0 comments on commit 9d9a57d

Please sign in to comment.