Skip to content

Commit f9254c0

Browse files
committed
Merge branch 'add-perfstubs'
2 parents 46cd33e + 9e99096 commit f9254c0

16 files changed

+67
-190
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ endif()
1717
find_package(MPI REQUIRED)
1818
#adios2 adds C and Fortran depending on how it was built
1919
find_package(ADIOS2 CONFIG 2.7.1 REQUIRED)
20+
# external packages (perfstubs)
21+
add_subdirectory(external)
2022

2123
set(REDEV_HEADERS
2224
redev.h
@@ -36,7 +38,6 @@ set(REDEV_HEADERS
3638

3739
set(REDEV_SOURCES
3840
redev.cpp
39-
redev_profile.cpp
4041
redev_time.cpp
4142
redev_assert.cpp
4243
redev_strings.cpp
@@ -45,11 +46,12 @@ set(REDEV_SOURCES
4546
add_library(redev ${REDEV_SOURCES})
4647
target_compile_features(redev PUBLIC cxx_std_17)
4748
target_link_libraries(redev PRIVATE redev_git_version)
48-
target_link_libraries(redev PUBLIC adios2::cxx11_mpi MPI::MPI_C)
49+
target_link_libraries(redev PUBLIC adios2::cxx11_mpi MPI::MPI_C perfstubs)
4950
target_compile_options(redev PRIVATE -Werror=switch)
5051
if(HAS_ASAN)
5152
target_compile_options(redev PRIVATE -fsanitize=address -fno-omit-frame-pointer)
5253
endif()
54+
target_compile_definitions(redev PUBLIC PERFSTUBS_USE_TIMERS)
5355

5456
include(CTest)
5557
if(BUILD_TESTING)
@@ -148,8 +150,6 @@ if(BUILD_TESTING)
148150
NAME2 app PROCS2 1 EXE2 ./test_setup_classPtn ARGS2 0)
149151
add_exe(test_query test_query.cpp)
150152
mpi_test(test_query_1p 1 ./test_query)
151-
add_exe(test_profile test_profile.cpp)
152-
mpi_test(test_profile_1p 1 ./test_profile)
153153
add_exe(test_send test_send.cpp)
154154
dual_mpi_test(TESTNAME test_send_3p TIMEOUT ${test_timeout}
155155
NAME1 rdv PROCS1 4 EXE1 ./test_send ARGS1 1

external/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include(FetchContent)
2+
3+
FetchContent_Declare(perfstubs
4+
GIT_REPOSITORY https://github.com/UO-OACISS/perfstubs.git
5+
GIT_TAG master)
6+
FetchContent_MakeAvailable(perfstubs)

redev.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ namespace {
3030
namespace redev {
3131

3232
//TODO consider moving the ClassPtn source to another file
33-
ClassPtn::ClassPtn() {}
33+
ClassPtn::ClassPtn() {
34+
REDEV_FUNCTION_TIMER;
35+
}
3436

3537
ClassPtn::ClassPtn(MPI_Comm comm, const redev::LOs& ranks_, const ModelEntVec& ents) {
38+
REDEV_FUNCTION_TIMER;
3639
REDEV_ALWAYS_ASSERT(comm != MPI_COMM_NULL);
3740
assert(ranks_.size() == ents.size());
3841
if( ! ModelEntDimsValid(ents) ) exit(EXIT_FAILURE);
@@ -64,6 +67,7 @@ namespace redev {
6467
}
6568

6669
bool ClassPtn::ModelEntDimsValid(const ClassPtn::ModelEntVec& ents) const {
70+
REDEV_FUNCTION_TIMER;
6771
auto badDim = [](ModelEnt e){ return (e.first<0 || e.first>3); };
6872
auto res = std::find_if(begin(ents), end(ents), badDim);
6973
if (res != std::end(ents)) {
@@ -183,15 +187,19 @@ namespace redev {
183187

184188

185189
//TODO consider moving the RCBPtn source to another file
186-
RCBPtn::RCBPtn() {}
190+
RCBPtn::RCBPtn() {
191+
REDEV_FUNCTION_TIMER;
192+
}
187193

188194
RCBPtn::RCBPtn(redev::LO dim_)
189195
: dim(dim_) {
196+
REDEV_FUNCTION_TIMER;
190197
assert(dim>0 && dim<=3);
191198
}
192199

193200
RCBPtn::RCBPtn(redev::LO dim_, std::vector<int>& ranks_, std::vector<double>& cuts_)
194201
: dim(dim_), ranks(ranks_), cuts(cuts_) {
202+
REDEV_FUNCTION_TIMER;
195203
assert(dim>0 && dim<=3);
196204
}
197205

@@ -329,6 +337,7 @@ namespace redev {
329337

330338
Redev::Redev(MPI_Comm comm, Partition ptn, ProcessType processType, bool noClients)
331339
: comm(comm), adios(comm), ptn(ptn), processType(processType), noClients(noClients) {
340+
PERFSTUBS_INITIALIZE();
332341
REDEV_FUNCTION_TIMER;
333342
int isInitialized = 0;
334343
MPI_Initialized(&isInitialized);
@@ -337,6 +346,7 @@ namespace redev {
337346
}
338347
Redev::Redev(MPI_Comm comm, ProcessType processType, bool noClients)
339348
: comm(comm), adios(comm), ptn(), processType(processType), noClients(noClients) {
349+
PERFSTUBS_INITIALIZE();
340350
REDEV_FUNCTION_TIMER;
341351
REDEV_ALWAYS_ASSERT(processType == ProcessType::Client);
342352
int isInitialized = 0;
@@ -346,6 +356,7 @@ namespace redev {
346356
}
347357

348358
void AdiosChannel::Setup(adios2::IO& s2cIO, adios2::Engine& s2cEngine) {
359+
REDEV_FUNCTION_TIMER;
349360
// initialize the partition on the client based on how it's set on the server
350361
if (process_type_ == ProcessType::Server) {
351362
std::ignore = SendPartitionTypeToClient(s2cIO, s2cEngine);
@@ -354,7 +365,6 @@ namespace redev {
354365
auto partition_index = SendPartitionTypeToClient(s2cIO, s2cEngine);
355366
ConstructPartitionFromIndex(partition_index);
356367
}
357-
REDEV_FUNCTION_TIMER;
358368
CheckVersion(s2cEngine,s2cIO);
359369
auto status = s2cEngine.BeginStep();
360370
REDEV_ALWAYS_ASSERT(status == adios2::StepStatus::OK);

redev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ class Redev {
200200
CreateAdiosChannel(std::string name, adios2::Params params,
201201
TransportType transportType = TransportType::BP4,
202202
std::string path = {}) {
203+
REDEV_FUNCTION_TIMER;
203204
if(RankParticipates()) {
204205
return AdiosChannel{
205206
adios, comm, std::move(name), std::move(params), transportType,

redev_adios_channel.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef REDEV_REDEV_ADIOS_CHANNEL_H
22
#define REDEV_REDEV_ADIOS_CHANNEL_H
33
#include "redev_assert.h"
4+
#include "redev_profile.h"
45
#include <adios2.h>
56

67
namespace redev {
@@ -14,6 +15,7 @@ class AdiosChannel {
1415
: comm_(comm), process_type_(processType), partition_(partition)
1516

1617
{
18+
REDEV_FUNCTION_TIMER;
1719
MPI_Comm_rank(comm, &rank_);
1820
auto s2cName = path + name + "_s2c";
1921
auto c2sName = path + name + "_c2s";
@@ -73,10 +75,11 @@ class AdiosChannel {
7375
num_server_ranks_(o.num_server_ranks_),
7476
comm_(std::exchange(o.comm_, MPI_COMM_NULL)),
7577
process_type_(o.process_type_), rank_(o.rank_),
76-
partition_(o.partition_) {}
78+
partition_(o.partition_) {REDEV_FUNCTION_TIMER;}
7779
AdiosChannel operator=(AdiosChannel &&) = delete;
7880
// FIXME IMPL RULE OF 5
7981
~AdiosChannel() {
82+
REDEV_FUNCTION_TIMER;
8083
// NEED TO CHECK that the engine exists before trying to close it because it
8184
// could be in a moved from state
8285
if (s2c_engine_) {
@@ -88,6 +91,7 @@ class AdiosChannel {
8891
}
8992
template <typename T>
9093
[[nodiscard]] BidirectionalComm<T> CreateComm(std::string name, MPI_Comm comm) {
94+
REDEV_FUNCTION_TIMER;
9195
// TODO, remove s2c/c2s destinction on variable names then use std::move
9296
// name
9397
if(comm != MPI_COMM_NULL) {
@@ -108,6 +112,7 @@ class AdiosChannel {
108112
// TODO s2c/c2s Engine/IO -> send/receive Engine/IO. This removes need for all
109113
// the switch statements...
110114
void BeginSendCommunicationPhase() {
115+
REDEV_FUNCTION_TIMER;
111116
adios2::StepStatus status;
112117
switch (process_type_) {
113118
case ProcessType::Client:
@@ -130,6 +135,7 @@ class AdiosChannel {
130135
}
131136
}
132137
void BeginReceiveCommunicationPhase() {
138+
REDEV_FUNCTION_TIMER;
133139
adios2::StepStatus status;
134140
switch (process_type_) {
135141
case ProcessType::Client:
@@ -142,6 +148,7 @@ class AdiosChannel {
142148
REDEV_ALWAYS_ASSERT(status == adios2::StepStatus::OK);
143149
}
144150
void EndReceiveCommunicationPhase() {
151+
REDEV_FUNCTION_TIMER;
145152
switch (process_type_) {
146153
case ProcessType::Client:
147154
s2c_engine_.EndStep();

redev_assert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#define REDEV_ALWAYS_ASSERT(cond) do { \
55
if (! (cond)) { \
66
char omsg[2048]; \
7-
snprintf(omsg,200, "%s failed at %s + %d \n", \
7+
snprintf(omsg,2048, "%s failed at %s + %d \n", \
88
#cond, __FILE__, __LINE__); \
99
redev::Redev_Assert_Fail(omsg); \
1010
} \

redev_bidirectional_comm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,28 @@ template <class T> class BidirectionalComm {
1717
BidirectionalComm(std::unique_ptr<Communicator<T>> sender_,
1818
std::unique_ptr<Communicator<T>> receiver_)
1919
: sender(std::move(sender_)), receiver(std::move(receiver_)) {
20+
REDEV_FUNCTION_TIMER;
2021
REDEV_ALWAYS_ASSERT(sender != nullptr);
2122
REDEV_ALWAYS_ASSERT(receiver != nullptr);
2223
}
2324
void SetOutMessageLayout(LOs &dest, LOs &offsets) {
25+
REDEV_FUNCTION_TIMER;
2426
REDEV_ALWAYS_ASSERT(sender != nullptr);
2527
sender->SetOutMessageLayout(dest, offsets);
2628
}
2729
InMessageLayout GetInMessageLayout() {
30+
REDEV_FUNCTION_TIMER;
2831
REDEV_ALWAYS_ASSERT(receiver != nullptr);
2932
return receiver->GetInMessageLayout();
3033
}
3134

3235
void Send(T *msgs, Mode mode = Mode::Deferred) {
36+
REDEV_FUNCTION_TIMER;
3337
REDEV_ALWAYS_ASSERT(sender != nullptr);
3438
sender->Send(msgs, mode);
3539
}
3640
std::vector<T> Recv(Mode mode = Mode::Deferred) {
41+
REDEV_FUNCTION_TIMER;
3742
REDEV_ALWAYS_ASSERT(receiver != nullptr);
3843
return receiver->Recv(mode);
3944
}

redev_channel.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ class Channel {
1212
: pimpl_{new ChannelModel<std::remove_cv_t<std::remove_reference_t<T>>>(
1313
std::forward<T>(channel))},
1414
send_communication_phase_active_(false),
15-
receive_communication_phase_active_(false) {}
15+
receive_communication_phase_active_(false) {
16+
REDEV_FUNCTION_TIMER;
17+
}
1618

1719
// For cases where we may be interested in storing the comm variant rather
1820
// than the exact type this function can be used to reduce the runtime
1921
// overhead of converting from the variant to the explicit type back to the
2022
// variant
2123
template <typename T> [[nodiscard]] CommV CreateCommV(std::string name, MPI_Comm comm) {
24+
REDEV_FUNCTION_TIMER;
2225
return pimpl_->CreateComm(std::move(name), comm,
2326
InvCommunicatorTypeMap<T>::value);
2427
}
@@ -27,32 +30,39 @@ class Channel {
2730
// that expects a typed communicator to be created.
2831
template <typename T>
2932
[[nodiscard]] BidirectionalComm<T> CreateComm(std::string name, MPI_Comm comm) {
33+
REDEV_FUNCTION_TIMER;
3034
return std::get<BidirectionalComm<T>>(CreateCommV<T>(std::move(name), comm));
3135
}
3236
void BeginSendCommunicationPhase() {
37+
REDEV_FUNCTION_TIMER;
3338
REDEV_ALWAYS_ASSERT(InSendCommunicationPhase() == false);
3439
pimpl_->BeginSendCommunicationPhase();
3540
send_communication_phase_active_ = true;
3641
}
3742
void EndSendCommunicationPhase() {
43+
REDEV_FUNCTION_TIMER;
3844
REDEV_ALWAYS_ASSERT(InSendCommunicationPhase() == true);
3945
pimpl_->EndSendCommunicationPhase();
4046
send_communication_phase_active_ = false;
4147
}
4248
void BeginReceiveCommunicationPhase() {
49+
REDEV_FUNCTION_TIMER;
4350
REDEV_ALWAYS_ASSERT(InReceiveCommunicationPhase() == false);
4451
pimpl_->BeginReceiveCommunicationPhase();
4552
receive_communication_phase_active_ = true;
4653
}
4754
void EndReceiveCommunicationPhase() {
55+
REDEV_FUNCTION_TIMER;
4856
REDEV_ALWAYS_ASSERT(InReceiveCommunicationPhase() == true);
4957
pimpl_->EndReceiveCommunicationPhase();
5058
receive_communication_phase_active_ = false;
5159
}
5260
[[nodiscard]] bool InSendCommunicationPhase() const noexcept {
61+
REDEV_FUNCTION_TIMER;
5362
return send_communication_phase_active_;
5463
}
5564
[[nodiscard]] bool InReceiveCommunicationPhase() const noexcept {
65+
REDEV_FUNCTION_TIMER;
5666
return receive_communication_phase_active_;
5767
}
5868

@@ -88,6 +98,7 @@ class Channel {
8898
~ChannelModel() noexcept final {}
8999
[[nodiscard]] CommV CreateComm(std::string &&name, MPI_Comm comm,
90100
CommunicatorDataType type) final {
101+
REDEV_FUNCTION_TIMER;
91102
switch (type) {
92103
case CommunicatorDataType::INT8:
93104
return CommV{impl_.template CreateComm<
@@ -145,15 +156,19 @@ class Channel {
145156
return {};
146157
}
147158
void BeginSendCommunicationPhase() final {
159+
REDEV_FUNCTION_TIMER;
148160
impl_.BeginSendCommunicationPhase();
149161
}
150162
void EndSendCommunicationPhase() final {
163+
REDEV_FUNCTION_TIMER;
151164
impl_.EndSendCommunicationPhase();
152165
}
153166
void BeginReceiveCommunicationPhase() final {
167+
REDEV_FUNCTION_TIMER;
154168
impl_.BeginReceiveCommunicationPhase();
155169
}
156170
void EndReceiveCommunicationPhase() final {
171+
REDEV_FUNCTION_TIMER;
157172
impl_.EndReceiveCommunicationPhase();
158173
}
159174

redev_comm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <stddef.h>
99
#include <type_traits> // is_same
1010
#include <adios2.h>
11+
#include "redev_time.h"
1112

1213
namespace {
1314
void checkStep(adios2::StepStatus status) {

redev_profile.cpp

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)