Skip to content

Commit f3bf24a

Browse files
committed
add caliper support for bdddc
1 parent 9d214a4 commit f3bf24a

File tree

5 files changed

+76
-1
lines changed

5 files changed

+76
-1
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,12 @@ find_package(VTune)
369369
if(VTune_FOUND)
370370
set(GINKGO_HAVE_VTUNE 1)
371371
endif()
372+
# Automatically find Caliper
373+
set(GINKGO_HAVE_CALIPER 0)
374+
find_package(caliper QUIET)
375+
if(caliper_FOUND)
376+
set(GINKGO_HAVE_CALIPER 1)
377+
endif()
372378
# Automatically find METIS
373379
set(GINKGO_HAVE_METIS 0)
374380
find_package(METIS)

core/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ if(GINKGO_HAVE_PARMETIS)
214214
target_link_libraries(${ginkgo_core} PRIVATE ParMETIS::ParMETIS)
215215
endif()
216216

217+
if(GINKGO_HAVE_CALIPER)
218+
target_link_libraries(${ginkgo_core} PRIVATE caliper)
219+
endif()
220+
217221
if(GINKGO_BUILD_MPI)
218222
target_link_libraries(${ginkgo_core} PUBLIC MPI::MPI_CXX)
219223
endif()

core/base/caliper.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
2+
//
3+
// SPDX-License-Identifier: BSD-3-Clause
4+
5+
#ifndef GKO_CORE_BASE_CALIPER_HPP_
6+
#define GKO_CORE_BASE_CALIPER_HPP_
7+
8+
#include <ginkgo/config.hpp>
9+
10+
#if GKO_HAVE_CALIPER
11+
#include <caliper/cali.h>
12+
#else
13+
#define CALI_CXX_MARK_SCOPE(name)
14+
#define CALI_MARK_BEGIN(name)
15+
#define CALI_MARK_END(name)
16+
#endif
17+
18+
#endif // GKO_CORE_BASE_CALIPER_HPP_

core/distributed/preconditioner/bddc.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <ginkgo/core/stop/iteration.hpp>
4141
#include <ginkgo/core/stop/residual_norm.hpp>
4242

43+
#include "core/base/caliper.hpp"
4344
#include "core/base/extended_float.hpp"
4445
#include "core/base/utils.hpp"
4546
#include "core/components/fill_array_kernels.hpp"
@@ -361,14 +362,18 @@ void Bddc<ValueType, LocalIndexType, GlobalIndexType>::apply_dense_impl(
361362
using Vector = matrix::Dense<ValueType>;
362363
auto exec = this->get_executor();
363364
auto comm = buf_1_->get_communicator();
365+
CALI_CXX_MARK_SCOPE("bddc::apply");
364366

367+
CALI_MARK_BEGIN("bddc::apply/restriction");
365368
restriction_->apply(dense_b, buf_2_);
366369
if (active) {
367370
local_buf_2_->permute(permutation_, local_buf_1_,
368371
matrix::permute_mode::rows);
369372
local_buf_4_->copy_from(local_buf_1_);
370373
}
374+
CALI_MARK_END("bddc::apply/restriction");
371375

376+
CALI_MARK_BEGIN("bddc::apply/static_condensation_1");
372377
if (!pre_solved) {
373378
if (active) {
374379
// Static condensation 1
@@ -386,15 +391,19 @@ void Bddc<ValueType, LocalIndexType, GlobalIndexType>::apply_dense_impl(
386391
}
387392
bndry_1_->add_scaled(neg_one_, bndry_3_);
388393
}
394+
CALI_MARK_END("bddc::apply/static_condensation_1");
389395

396+
CALI_MARK_BEGIN("bddc::apply/weight_application");
390397
if (active) {
391398
interior_1_->fill(zero<ValueType>());
392399
weights_->apply(local_buf_1_, local_buf_2_);
393400

394401
// Coarse grid correction
395402
phi_t_->apply(bndry_2_, local_coarse_buf_1_);
396403
}
404+
CALI_MARK_END("bddc::apply/weight_application");
397405

406+
CALI_MARK_BEGIN("bddc::apply/coarse_correction");
398407
coarse_prolongation_->apply(broken_coarse_buf_1_, coarse_buf_1_);
399408
if (coarse_solver_->apply_uses_initial_guess()) {
400409
coarse_buf_2_->fill(zero<ValueType>());
@@ -403,7 +412,11 @@ void Bddc<ValueType, LocalIndexType, GlobalIndexType>::apply_dense_impl(
403412
coarse_restriction_->apply(coarse_buf_2_, broken_coarse_buf_1_);
404413
if (active) {
405414
phi_->apply(local_coarse_buf_1_, bndry_1_);
415+
}
416+
CALI_MARK_END("bddc::apply/coarse_correction");
406417

418+
CALI_MARK_BEGIN("bddc::apply/substructure_correction");
419+
if (active) {
407420
// Substructure correction
408421
local_solver_->apply(dual_2_, dual_3_);
409422
constraints_->apply(dual_3_, schur_buf_1_);
@@ -419,6 +432,9 @@ void Bddc<ValueType, LocalIndexType, GlobalIndexType>::apply_dense_impl(
419432
local_buf_2_->permute(permutation_, local_buf_1_,
420433
matrix::permute_mode::inverse_rows);
421434
}
435+
CALI_MARK_END("bddc::apply/substructure_correction");
436+
437+
CALI_MARK_BEGIN("bddc::apply/static_condensation_2");
422438
prolongation_->apply(buf_1_, dense_x);
423439
restriction_->apply(dense_x, buf_1_);
424440
if (active) {
@@ -434,13 +450,17 @@ void Bddc<ValueType, LocalIndexType, GlobalIndexType>::apply_dense_impl(
434450
local_buf_2_->permute(permutation_, local_buf_1_,
435451
matrix::permute_mode::inverse_rows);
436452
}
453+
CALI_MARK_END("bddc::apply/static_condensation_2");
454+
455+
CALI_MARK_BEGIN("bddc::apply/prolongation");
437456
prolongation_->apply(one_, buf_1_, one_, dense_x);
438457

439458
if (parameters_.constant_nullspace) {
440459
dense_x->compute_dot(nsp, LL_scal_3);
441460
LL_scal_3->inv_scale(n_op);
442461
dense_x->add_scaled(LL_scal_3, nsp);
443462
}
463+
CALI_MARK_END("bddc::apply/prolongation");
444464
}
445465

446466

@@ -1524,6 +1544,7 @@ template <typename ValueType, typename LocalIndexType, typename GlobalIndexType>
15241544
void Bddc<ValueType, LocalIndexType, GlobalIndexType>::generate(
15251545
std::shared_ptr<const LinOp> system_matrix)
15261546
{
1547+
CALI_CXX_MARK_SCOPE("bddc::generate");
15271548
auto exec = this->get_executor();
15281549
auto host_exec = exec->get_master();
15291550

@@ -1584,12 +1605,14 @@ void Bddc<ValueType, LocalIndexType, GlobalIndexType>::generate(
15841605
size_type n_inner_idxs, n_face_idxs, n_edge_idxs, n_vertices, n_faces,
15851606
n_edges, n_constraints;
15861607
int n_owning_interfaces;
1608+
CALI_MARK_BEGIN("bddc::generate/classify_dofs");
15871609
auto labels = bddc::classify_dofs(
15881610
host_exec, dd_system_matrix, tags, dof_types, permutation_array,
15891611
interface_sizes, unique_labels, unique_tags, owning_labels, owning_tags,
15901612
n_inner_idxs, n_face_idxs, n_edge_idxs, n_vertices, n_faces, n_edges,
15911613
n_constraints, n_owning_interfaces, parameters_.faces,
15921614
parameters_.edges);
1615+
CALI_MARK_END("bddc::generate/classify_dofs");
15931616

15941617
if (exec != host_exec) {
15951618
labels = clone(exec, labels);
@@ -1645,9 +1668,13 @@ void Bddc<ValueType, LocalIndexType, GlobalIndexType>::generate(
16451668
share(as<local_real_vec>(labels->get_local_vector())
16461669
->permute(permutation_, matrix::permute_mode::rows));
16471670

1671+
CALI_MARK_BEGIN("bddc::generate/extract_matrix_blocks");
16481672
extract_matrix_blocks(reordered_system_matrix, n_inner_idxs,
16491673
n_face_idxs, n_edge_idxs, n_vertices);
1674+
CALI_MARK_END("bddc::generate/extract_matrix_blocks");
1675+
CALI_MARK_BEGIN("bddc::generate/setup_local_solvers");
16501676
setup_local_solvers(n_inner_idxs, n_face_idxs, n_edge_idxs, n_vertices);
1677+
CALI_MARK_END("bddc::generate/setup_local_solvers");
16511678

16521679
matrix_data<ValueType, LocalIndexType> condest_LL_data(
16531680
gko::dim<2>{A_LL->get_size()[0], 1},
@@ -1660,16 +1687,22 @@ void Bddc<ValueType, LocalIndexType, GlobalIndexType>::generate(
16601687
auto condest_rhs_II = local_vec::create(exec);
16611688
condest_rhs_II->read(condest_II_data);
16621689

1690+
CALI_MARK_BEGIN("bddc::generate/setup_nullspace_and_conditioning");
16631691
setup_nullspace_and_conditioning(share(std::move(condest_rhs_LL)),
16641692
share(std::move(condest_rhs_II)));
1693+
CALI_MARK_END("bddc::generate/setup_nullspace_and_conditioning");
16651694

1695+
CALI_MARK_BEGIN("bddc::generate/generate_constraints_and_schur");
16661696
generate_constraints_and_schur(local_labels, n_inactive, n_dual,
16671697
interface_sizes, n_inner_idxs,
16681698
n_face_idxs, n_edge_idxs);
1699+
CALI_MARK_END("bddc::generate/generate_constraints_and_schur");
16691700

1701+
CALI_MARK_BEGIN("bddc::generate/compute_harmonic_extensions");
16701702
compute_harmonic_extensions(phi, lambda, n_inner_idxs, n_face_idxs,
16711703
n_edge_idxs, n_vertices, n_dual,
16721704
n_constraints);
1705+
CALI_MARK_END("bddc::generate/compute_harmonic_extensions");
16731706
}
16741707

16751708
// Set up global numbering for coarse problem, read coarse matrix and
@@ -1680,26 +1713,35 @@ void Bddc<ValueType, LocalIndexType, GlobalIndexType>::generate(
16801713
array<LocalIndexType> coarse_global_idxs{host_exec};
16811714

16821715
array<int> owning_interfaces{host_exec, num_parts + 1};
1716+
CALI_MARK_BEGIN("bddc::generate/assemble_coarse_problem");
16831717
assemble_coarse_problem(
16841718
labels, lambda, dof_types, unique_tags, unique_labels, owning_labels,
16851719
owning_tags, n_constraints, n_owning_interfaces, owning_interfaces,
16861720
coarse_contribution, coarse_global_idxs);
1721+
CALI_MARK_END("bddc::generate/assemble_coarse_problem");
16871722
size_type n_global_interfaces = coarse_partition_->get_size();
16881723

1724+
CALI_MARK_BEGIN("bddc::generate/setup_coarse_solver");
16891725
setup_coarse_solver(coarse_contribution, coarse_partition_, n_constraints,
16901726
local_size, owning_interfaces, coarse_global_idxs);
1727+
CALI_MARK_END("bddc::generate/setup_coarse_solver");
16911728

1729+
CALI_MARK_BEGIN("bddc::generate/setup_coarse_mapping");
16921730
setup_coarse_mapping(coarse_contribution, coarse_partition_, phi,
16931731
coarse_global_idxs, n_inner_idxs, n_face_idxs,
16941732
n_edge_idxs, n_vertices, n_constraints);
1733+
CALI_MARK_END("bddc::generate/setup_coarse_mapping");
16951734

1696-
// Create workspace buffers
1735+
CALI_MARK_BEGIN("bddc::generate/create_workspace_buffers");
16971736
create_workspace_buffers(local_size, n_inner_idxs, n_face_idxs, n_edge_idxs,
16981737
n_vertices, n_dual, n_constraints,
16991738
n_owning_interfaces, n_global_interfaces);
1739+
CALI_MARK_END("bddc::generate/create_workspace_buffers");
17001740

1741+
CALI_MARK_BEGIN("bddc::generate/generate_weights");
17011742
generate_weights(local_size, n_inner_idxs, n_face_idxs, n_inactive,
17021743
interface_sizes, permutation_array, unique_labels);
1744+
CALI_MARK_END("bddc::generate/generate_weights");
17031745

17041746
nsp = vec::create(
17051747
exec, comm, dim<2>{prolongation_->get_size()[0], 1},

include/ginkgo/config.hpp.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@
114114
#define GKO_HAVE_ROCTX @GINKGO_HAVE_ROCTX@
115115
// clang-format on
116116

117+
/* Is Caliper available for Profiling? */
118+
// clang-format off
119+
#define GKO_HAVE_CALIPER @GINKGO_HAVE_CALIPER@
120+
// clang-format on
121+
117122

118123
/* Is MPI available ? */
119124
// clang-format off

0 commit comments

Comments
 (0)