Skip to content

Commit

Permalink
#105: format with clang-format files in src and in tests directories
Browse files Browse the repository at this point in the history
  • Loading branch information
tlamonthezie committed Sep 4, 2024
1 parent 5466d8a commit 2848368
Show file tree
Hide file tree
Showing 41 changed files with 1,128 additions and 1,202 deletions.
216 changes: 126 additions & 90 deletions src/vt-tv/api/info.h

Large diffs are not rendered by default.

55 changes: 22 additions & 33 deletions src/vt-tv/api/object_communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,14 @@ struct Object;
* \brief A class holding received and sent messages for an object.
*/
struct ObjectCommunicator {

ObjectCommunicator() = default;

/**
* \brief Construct an \c ObjectCommunicator without any edges
*
* \param[in] id_in the object id
*/
explicit ObjectCommunicator(ElementIDType id_in)
: object_id_(id_in)
{}
explicit ObjectCommunicator(ElementIDType id_in) : object_id_(id_in) { }

/**
* \brief Construct an \c ObjectCommunicator with edges
Expand All @@ -84,13 +81,11 @@ struct ObjectCommunicator {
* \param[in] sent_in send edges
*/
ObjectCommunicator(
ElementIDType id_in,
std::multimap<ElementIDType, double> recv_in,
std::multimap<ElementIDType, double> sent_in
) : object_id_(id_in),
ElementIDType id_in, std::multimap<ElementIDType, double> recv_in,
std::multimap<ElementIDType, double> sent_in)
: object_id_(id_in),
received_(recv_in),
sent_(sent_in)
{ }
sent_(sent_in) { }

/**
* \brief Get the id of object for this communicator
Expand All @@ -114,7 +109,7 @@ struct ObjectCommunicator {

std::vector<double> results;
for (auto it = range.first; it != range.second; ++it) {
results.push_back(it->second);
results.push_back(it->second);
}

return results;
Expand All @@ -133,7 +128,7 @@ struct ObjectCommunicator {

std::vector<double> results;
for (auto it = range.first; it != range.second; ++it) {
results.push_back(it->second);
results.push_back(it->second);
}

return results;
Expand All @@ -149,8 +144,7 @@ struct ObjectCommunicator {
this->received_.insert(std::make_pair(from_id, bytes));
if (from_id == this->object_id_) {
fmt::print(
"Object {} receiving communication from myself\n", this->object_id_
);
"Object {} receiving communication from myself\n", this->object_id_);
}
}

Expand All @@ -164,37 +158,32 @@ struct ObjectCommunicator {
this->sent_.insert(std::make_pair(to_id, bytes));
if (to_id == this->object_id_) {
fmt::print(
"Object {} sending communication to myself\n", this->object_id_
);
"Object {} sending communication to myself\n", this->object_id_);
}
}

/**
/**
* \brief maximum bytes received or sent at this communicator
*/
double getMaxVolume() const {
// Search for the maximum value in received and sent (0. if sets are empty)
double max_recv = !this->received_.empty() ?
std::max_element(
this->received_.begin(),
this->received_.end(),
[](const auto& a, const auto& b) {
return a.second < b.second;
})->second :
0.0;
std::max_element(
this->received_.begin(), this->received_.end(),
[](const auto& a, const auto& b) { return a.second < b.second; })
->second :
0.0;

double max_sent = !this->sent_.empty() ?
std::max_element(
this->sent_.begin(),
this->sent_.end(),
[](const auto& a, const auto& b) {
return a.second < b.second;
})->second :
0.0;
std::max_element(
this->sent_.begin(), this->sent_.end(),
[](const auto& a, const auto& b) { return a.second < b.second; })
->second :
0.0;

// Return the max
return std::max(max_recv, max_sent);
}
}

/**
* \brief Get the total received communication volume for this communicator
Expand Down Expand Up @@ -235,7 +224,7 @@ struct ObjectCommunicator {
}

private:
ElementIDType object_id_; /**< The object id */
ElementIDType object_id_; /**< The object id */
std::multimap<ElementIDType, double> received_; /**< The received edges */
std::multimap<ElementIDType, double> sent_; /**< The sent edges */
};
Expand Down
12 changes: 4 additions & 8 deletions src/vt-tv/api/object_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ namespace vt::tv {
* ranks or phases.
*/
struct ObjectInfo {

ObjectInfo() = default;

/**
Expand All @@ -69,15 +68,12 @@ struct ObjectInfo {
* \param[in] in_index the index for the object
*/
ObjectInfo(
ElementIDType in_id,
NodeType in_home,
bool in_migratable,
std::vector<UniqueIndexBitType> const& in_index
) : id_(in_id),
ElementIDType in_id, NodeType in_home, bool in_migratable,
std::vector<UniqueIndexBitType> const& in_index)
: id_(in_id),
home_(in_home),
migratable_(in_migratable),
index_(in_index)
{ }
index_(in_index) { }

/**
* \brief Get the object's ID
Expand Down
20 changes: 6 additions & 14 deletions src/vt-tv/api/object_work.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ namespace vt::tv {
* \brief Holds work for an object for a given phase
*/
struct ObjectWork {

ObjectWork() = default;

/**
Expand All @@ -72,18 +71,16 @@ struct ObjectWork {
* \param[in] in_user_defined the user-defined fields in json
*/
ObjectWork(
ElementIDType in_id,
TimeType in_whole_phase_load,
ElementIDType in_id, TimeType in_whole_phase_load,
std::unordered_map<SubphaseType, TimeType> in_subphase_loads,
std::unordered_map<std::string, QOIVariantTypes> in_user_defined = {},
std::unordered_map<std::string, QOIVariantTypes> in_attributes = {}
) : id_(in_id),
std::unordered_map<std::string, QOIVariantTypes> in_attributes = {})
: id_(in_id),
whole_phase_load_(in_whole_phase_load),
subphase_loads_(std::move(in_subphase_loads)),
user_defined_(std::move(in_user_defined)),
communicator_(id_),
attributes_(std::move(in_attributes))
{ }
attributes_(std::move(in_attributes)) { }

/**
* \brief Get element ID
Expand Down Expand Up @@ -165,9 +162,7 @@ struct ObjectWork {
/**
* \brief Get maximum bytes received or sent at this object
*/
double getMaxVolume() const {
return communicator_.getMaxVolume();
}
double getMaxVolume() const { return communicator_.getMaxVolume(); }

/**
* \brief Get the total received communication volume for this object
Expand All @@ -183,9 +178,7 @@ struct ObjectWork {
*
* \return total sent communication volume
*/
double getSentVolume() const {
return communicator_.getTotalSentVolume();
}
double getSentVolume() const { return communicator_.getTotalSentVolume(); }

/**
* \brief Serializer for data
Expand Down Expand Up @@ -215,7 +208,6 @@ struct ObjectWork {
ObjectCommunicator communicator_;
// QOIs to be visualized
std::unordered_map<std::string, QOIVariantTypes> attributes_;

};

} /* end namespace vt::tv */
Expand Down
21 changes: 12 additions & 9 deletions src/vt-tv/api/phase_work.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ namespace vt::tv {
* \brief The work for a given phase
*/
struct PhaseWork {

PhaseWork() = default;

/**
Expand All @@ -68,10 +67,9 @@ struct PhaseWork {
*/
PhaseWork(
PhaseType in_phase,
std::unordered_map<ElementIDType, ObjectWork> in_objects
) : phase_(in_phase),
objects_(std::move(in_objects))
{ }
std::unordered_map<ElementIDType, ObjectWork> in_objects)
: phase_(in_phase),
objects_(std::move(in_objects)) { }

/**
* \brief Get the phase ID
Expand Down Expand Up @@ -105,14 +103,17 @@ struct PhaseWork {
*
* \return void
*/
void setCommunications(ElementIDType o_id, ObjectCommunicator& c) { objects_.at(o_id).setCommunications(c); };
void setCommunications(ElementIDType o_id, ObjectCommunicator& c) {
objects_.at(o_id).setCommunications(c);
};

/**
* \brief add a received communication to an object in this phase
*
* \return void
*/
void addObjectReceivedCommunication(ElementIDType o_id, ElementIDType from_id, double bytes) {
void addObjectReceivedCommunication(
ElementIDType o_id, ElementIDType from_id, double bytes) {
objects_.at(o_id).addReceivedCommunications(from_id, bytes);
};

Expand All @@ -121,7 +122,8 @@ struct PhaseWork {
*
* \return void
*/
void addObjectSentCommunication(ElementIDType o_id, ElementIDType to_id, double bytes) {
void addObjectSentCommunication(
ElementIDType o_id, ElementIDType to_id, double bytes) {
objects_.at(o_id).addSentCommunications(to_id, bytes);
};

Expand All @@ -133,7 +135,8 @@ struct PhaseWork {

for (auto const& [obj_id, obj_work] : this->objects_) {
auto obj_max_v = obj_work.getMaxVolume();
if (obj_max_v > ov_max) ov_max = obj_max_v;
if (obj_max_v > ov_max)
ov_max = obj_max_v;
}
return ov_max;
}
Expand Down
29 changes: 17 additions & 12 deletions src/vt-tv/api/rank.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ namespace vt::tv {
* \brief All the data for a given \c Rank
*/
struct Rank {

Rank() = default;

/**
Expand All @@ -64,13 +63,11 @@ struct Rank {
* \param[in] in_phase_info all the phase info
*/
Rank(
NodeType in_rank,
std::unordered_map<PhaseType, PhaseWork> in_phase_info,
std::unordered_map<std::string, QOIVariantTypes> in_attributes = {}
) : rank_(in_rank),
NodeType in_rank, std::unordered_map<PhaseType, PhaseWork> in_phase_info,
std::unordered_map<std::string, QOIVariantTypes> in_attributes = {})
: rank_(in_rank),
phase_info_(std::move(in_phase_info)),
attributes_(std::move(in_attributes))
{ }
attributes_(std::move(in_attributes)) { }

/**
* \brief Get the rank ID
Expand Down Expand Up @@ -98,7 +95,9 @@ struct Rank {
*
* \return the load
*/
double getLoad(PhaseType phase) const { return phase_info_.at(phase).getLoad(); }
double getLoad(PhaseType phase) const {
return phase_info_.at(phase).getLoad();
}

/**
* \brief Get attribute fields
Expand All @@ -114,23 +113,29 @@ struct Rank {
*
* \return the number of objects
*/
uint64_t getNumObjects(PhaseType phase) const { return phase_info_.at(phase).getObjectWork().size(); }
uint64_t getNumObjects(PhaseType phase) const {
return phase_info_.at(phase).getObjectWork().size();
}

/**
* \brief add a received communication to an object at a given phase
*
* \return void
*/
void addObjectReceivedCommunicationAtPhase(PhaseType phase_id, ElementIDType o_id, ElementIDType from_id, double bytes) {
phase_info_.at(phase_id).addObjectReceivedCommunication(o_id, from_id, bytes);
void addObjectReceivedCommunicationAtPhase(
PhaseType phase_id, ElementIDType o_id, ElementIDType from_id,
double bytes) {
phase_info_.at(phase_id).addObjectReceivedCommunication(
o_id, from_id, bytes);
};

/**
* \brief add a sent communication to an object at a given phase
*
* \return void
*/
void addObjectSentCommunicationAtPhase(PhaseType phase_id, ElementIDType o_id, ElementIDType to_id, double bytes) {
void addObjectSentCommunicationAtPhase(
PhaseType phase_id, ElementIDType o_id, ElementIDType to_id, double bytes) {
phase_info_.at(phase_id).addObjectSentCommunication(o_id, to_id, bytes);
};

Expand Down
Loading

0 comments on commit 2848368

Please sign in to comment.