Skip to content

Commit

Permalink
#130: api: add LB iterations: parsing and visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Dec 11, 2024
1 parent dd66399 commit 7a02449
Show file tree
Hide file tree
Showing 11 changed files with 903 additions and 468 deletions.
406 changes: 275 additions & 131 deletions src/vt-tv/api/info.h

Large diffs are not rendered by default.

141 changes: 134 additions & 7 deletions src/vt-tv/api/phase_work.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@
namespace vt::tv {

/**
* \struct PhaseWork
* \struct WorkDistribution
*
* \brief The work for a given phase
* \brief The work distribution for a phase or iteration
*/
struct PhaseWork {
PhaseWork() = default;
struct WorkDistribution {
WorkDistribution() = default;

/**
* \brief Construct phase work
* \brief Construct work distribution
*
* \param[in] in_phase the phase
* \param[in] in_phase the phase for the work distribution
* \param[in] in_objects objects' work for the phase
* \param[in] in_user_defined the user-defined fields in json
*/
PhaseWork(
WorkDistribution(
PhaseType in_phase,
std::unordered_map<ElementIDType, ObjectWork> in_objects,
std::unordered_map<std::string, QOIVariantTypes> in_user_defined = {}
Expand Down Expand Up @@ -174,6 +174,133 @@ struct PhaseWork {
std::unordered_map<std::string, QOIVariantTypes> user_defined_;
};

/**
* \struct LBIteration
*
* \brief An LB iteration within a phase where the distribution is changing
*/
struct LBIteration : WorkDistribution {
LBIteration() = default;

/**
* \brief Construct a LB iteration
*
* \param[in] in_phase the phase
* \param[in] in_lb_iteration the LB iteration
* \param[in] in_objects objects' work for the phase
* \param[in] in_user_defined the user-defined fields in json
*/
LBIteration(
PhaseType in_phase,
LBIterationType in_lb_iteration,
std::unordered_map<ElementIDType, ObjectWork> in_objects,
std::unordered_map<std::string, QOIVariantTypes> in_user_defined = {}
) : WorkDistribution(in_phase, std::move(in_objects), std::move(in_user_defined)),
lb_iteration_(in_lb_iteration)
{ }

/**
* \brief Get the LB iteration ID
*
* \return the LB iteration ID
*/
LBIterationType getLBIterationID() const { return lb_iteration_; }

/**
* \brief Serializer for data
*
* \param[in] s the serializer
*/
template <typename SerializerT>
void serialize(SerializerT& s) {
WorkDistribution::serialize(s);
s | lb_iteration_;
}

private:
LBIterationType lb_iteration_ = 0; /**< The LB iteration */
};

/**
* \struct PhaseWork
*
* \brief The work for a phase which may include multiple subsequent LB
* iterations
*/
struct PhaseWork : WorkDistribution {
PhaseWork() = default;

/**
* \brief Construct a phase work
*
* \param[in] in_phase the phase
* \param[in] in_objects objects' work for the phase
* \param[in] in_user_defined the user-defined fields in json
*/
PhaseWork(
PhaseType in_phase,
std::unordered_map<ElementIDType, ObjectWork> in_objects,
std::unordered_map<std::string, QOIVariantTypes> in_user_defined = {}
) : WorkDistribution(in_phase, std::move(in_objects), std::move(in_user_defined))
{ }

/**
* \brief Add an LB iteration
*
* \param[in] lb_iter_id the iteration ID
* \param[in] lb_iter the work distribution for the iteration
*/
void addLBIteration(LBIterationType lb_iter_id, LBIteration lb_iter) {
lb_iters_.emplace(lb_iter_id, std::move(lb_iter));
}

/**
* \brief Get all LB iterations
*
* \return the const LB iterations
*/
auto const& getLBIterations() const { return lb_iters_; }

/**
* \brief Get a LB iteration
*
* \param[in] lb_iter_id the LB iteration ID
*
* \return ref to the lb iteration
*/
LBIteration& getLBIteration(LBIterationType lb_iter_id) {
return lb_iters_.find(lb_iter_id)->second;
}

/**
* \brief Get a const LB iteration
*
* \param[in] lb_iter_id the LB iteration ID
*
* \return ref to the lb iteration
*/
LBIteration const& getLBIteration(LBIterationType lb_iter_id) const {
return lb_iters_.find(lb_iter_id)->second;
}

/**
* \brief Serializer for data
*
* \param[in] s the serializer
*/
template <typename SerializerT>
void serialize(SerializerT& s) {
WorkDistribution::serialize(s);
s | lb_iters_;
}

private:
/// LB iterations for this phase
std::unordered_map<LBIterationType, LBIteration> lb_iters_;
};



} /* end namespace vt::tv */

#endif /*INCLUDED_VT_TV_API_PHASE_WORK_H*/
16 changes: 12 additions & 4 deletions src/vt-tv/api/rank.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ struct Rank {
*
* \return the load
*/
double getLoad(PhaseType phase) const {
return phase_info_.at(phase).getLoad();
double getLoad(PhaseType phase, LBIterationType lb_iter) const {
if (lb_iter == no_lb_iter) {
return phase_info_.at(phase).getLoad();
} else {
return phase_info_.at(phase).getLBIteration(lb_iter).getLoad();
}
}

/**
Expand All @@ -114,8 +118,12 @@ 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, LBIterationType lb_iter) const {
if (lb_iter == no_lb_iter) {
return phase_info_.at(phase).getObjectWork().size();
} else {
return phase_info_.at(phase).getLBIteration(lb_iter).getObjectWork().size();
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/vt-tv/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
namespace vt::tv {

using PhaseType = uint64_t;
using LBIterationType = uint64_t;
using NodeType = int16_t;
using ElementIDType = uint64_t;
using SubphaseType = uint16_t;
Expand All @@ -61,6 +62,8 @@ using CollectionObjGroupIDType = uint64_t;
/// Possible QOIs types
using QOIVariantTypes = std::variant<int, double, std::string>;

constexpr LBIterationType no_lb_iter = static_cast<LBIterationType>(-1);

} /* end namespace vt::tv */

#endif /*INCLUDED_VT_TV_API_TYPES_H*/
Loading

0 comments on commit 7a02449

Please sign in to comment.