Skip to content

Commit f696f27

Browse files
authored
Add communication region annotations (LLNL#565)
1 parent 10586a7 commit f696f27

File tree

7 files changed

+50
-4
lines changed

7 files changed

+50
-4
lines changed

include/caliper/cali.h

+17
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,23 @@ cali_begin_phase(const char* name);
390390
void
391391
cali_end_phase(const char* name);
392392

393+
/**
394+
* \brief Begin communication region \a name
395+
*
396+
* A communication region can be used to mark communication operations (e.g.,
397+
* MPI calls) that belong to a single communication pattern. They can be used
398+
* to summarize communication pattern statistics. Otherwise they behave
399+
* identical to regular Caliper regions.
400+
*/
401+
void
402+
cali_begin_comm_region(const char* name);
403+
404+
/**
405+
* \brief End phase region \a name
406+
*/
407+
void
408+
cali_end_comm_region(const char* name);
409+
393410
/**
394411
* \brief Begin region where the value for \a attr is `true` on the blackboard.
395412
*/

include/caliper/cali_macros.h

+11
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ extern cali_id_t cali_annotation_attr_id;
217217
/// \brief Mark end of a phase region
218218
#define CALI_MARK_PHASE_END(name) \
219219
cali_end_phase(name)
220+
221+
/// \brief Mark begin of a communication region
222+
///
223+
/// A communication region marks communication operations (e.g., MPI calls)
224+
/// that belong to a single communication pattern.
225+
#define CALI_MARK_COMM_REGION_BEGIN(name) \
226+
cali_begin_comm_region(name)
227+
228+
/// \brief Mark end of a communication region
229+
#define CALI_MARK_COMM_REGION_END(name) \
230+
cali_end_comm_region(name)
220231
/**
221232
* \} (group)
222233
*/

scripts/radiuss-spack-configs

src/caliper/api.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace cali
3939
Attribute region_attr;
4040
Attribute phase_attr;
4141
Attribute loop_attr;
42+
Attribute comm_region_attr;
4243

4344
void init_attribute_classes(Caliper* c) {
4445
class_aggregatable_attr =
@@ -65,6 +66,8 @@ namespace cali
6566
c->create_attribute("region", CALI_TYPE_STRING, CALI_ATTR_NESTED);
6667
phase_attr =
6768
c->create_attribute("phase", CALI_TYPE_STRING, CALI_ATTR_NESTED | CALI_ATTR_LEVEL_4);
69+
comm_region_attr =
70+
c->create_attribute("comm.region", CALI_TYPE_STRING, CALI_ATTR_NESTED | CALI_ATTR_LEVEL_1);
6871

6972
cali_region_attr_id = region_attr.id();
7073
cali_phase_attr_id = phase_attr.id();

src/caliper/cali.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace cali
3232

3333
extern Attribute region_attr;
3434
extern Attribute phase_attr;
35+
extern Attribute comm_region_attr;
3536

3637
}
3738

@@ -404,6 +405,20 @@ cali_end_phase(const char* name)
404405
c.end_with_value_check(cali::phase_attr, Variant(name));
405406
}
406407

408+
void
409+
cali_begin_comm_region(const char* name)
410+
{
411+
Caliper c;
412+
c.begin(cali::comm_region_attr, Variant(name));
413+
}
414+
415+
void
416+
cali_end_comm_region(const char* name)
417+
{
418+
Caliper c;
419+
c.end_with_value_check(cali::comm_region_attr, Variant(name));
420+
}
421+
407422
void
408423
cali_begin(cali_id_t attr_id)
409424
{

test/ci_app_tests/ci_test_mpi_before_cali.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ int main(int argc, char* argv[])
4040
MPI_Bcast(&val, 1, MPI_INT, 0, MPI_COMM_WORLD);
4141

4242
int in = val, out;
43-
43+
CALI_MARK_COMM_REGION_BEGIN("reduction");
4444
MPI_Reduce(&in, &out, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
45-
4645
MPI_Barrier(MPI_COMM_WORLD);
46+
CALI_MARK_COMM_REGION_END("reduction");
4747
}
4848

4949
mgr.flush();

0 commit comments

Comments
 (0)