101 using namespace Prof;
107 std::vector<uint> metricSrcIds;
108 std::vector<uint> metricDstIds;
112 uint numMetrics_orig = metricMgr->
size();
113 for (
uint mId = 0; mId < numMetrics_orig; ++mId) {
119 metricSrcIds.push_back(m->
id());
126 DIAG_Assert(m_new->
id() >= numMetrics_orig,
"Currently, we assume new metrics are added at the end of the metric vector.");
128 metricDstIds.push_back(m_new->
id());
132 if (metricSrcIds.empty()) {
139 make(prof.
cct()->
root(), metricSrcIds, metricDstIds,
false);
151 const std::vector<uint>& m_src,
152 const std::vector<uint>& m_dst,
153 bool isSeparableCtxt)
155 if (!node) {
return; }
162 for (
uint i = 0; i < m_src.size(); ++i) {
163 uint mId_src = m_src[i];
164 uint mId_dst = m_dst[i];
167 double mval = stmt->
metric(mId_src);
169 stmt->
metric(mId_src) = 0.0;
179 bool isSeparableCtxt_nxt = isSeparableCtxt;
180 if (!isSeparableCtxt && dynamic_cast<Prof::CCT::AProcNode*>(node)) {
187 make(x, m_src, m_dst, isSeparableCtxt_nxt);
195 const string& nm = mdesc->
name();
196 if (nm.find(
"PAPI_TOT_CYC") == 0) {
199 else if (nm.find(
"WALLCLOCK") == 0) {
225 static const string mpistr1 =
"MPI";
226 static const string mpistr2 =
"PMPI";
228 return (x_nm.compare(0, mpistr1.length(), mpistr1) == 0 ||
229 x_nm.compare(0, mpistr2.length(), mpistr2) == 0);
237 bool fnd = (x_nm.find(s_tag1) != string::npos ||
238 x_nm.find(s_tag2) != string::npos ||
239 x_nm.find(s_tag3) != string::npos);
248 using namespace Prof;
254 std::vector<uint> metricSrcIds;
255 std::vector<uint> metricBalanceIds;
256 std::vector<uint> metricImbalInclIds, metricImbalExclIds;
257 std::vector<uint> metricIdleInclIds;
261 uint numMetrics_orig = metricMgr->
size();
262 for (
uint mId = 0; mId < numMetrics_orig; ++mId) {
268 && m->
type() == Metric::ADesc::TyIncl
273 metricSrcIds.push_back(m->
id());
282 m_imbalIncl->
description(
"imbalance for MPI SPMD executions");
284 Metric::IData::npos));
288 m_imbalExcl->
type(Metric::ADesc::TyExcl);
290 Metric::IData::npos));
291 m_imbalIncl->
partner(m_imbalExcl);
292 m_imbalExcl->
partner(m_imbalIncl);
297 m_idleIncl->
description(
"idleness for MPI executions");
300 Metric::IData::npos));
302 metricMgr->
insert(m_imbalIncl);
303 metricMgr->
insert(m_imbalExcl);
304 metricMgr->
insert(m_idleIncl);
310 DIAG_Assert(m_imbalIncl->
id() >= numMetrics_orig && m_imbalExcl->
id() >= numMetrics_orig,
"Currently, we assume new metrics are added at the end of the metric vector.");
312 metricImbalInclIds.push_back(m_imbalIncl->
id());
313 metricImbalExclIds.push_back(m_imbalExcl->
id());
314 metricIdleInclIds.push_back(m_idleIncl->
id());
320 && m->
type() == Metric::ADesc::TyIncl
324 metricBalanceIds.push_back(m->
id());
330 if (metricSrcIds.empty()) {
341 uint metricBalancedId = metricBalanceIds[0];
345 metricBalancedExpr->
finalize(cctRoot_mdata);
347 double balancedThreshold = 1.2 * cctRoot_mdata.
demandMetric(metricBalancedId);
350 metricImbalInclIds, metricImbalExclIds, metricIdleInclIds,
351 metricBalancedId, metricBalancedExpr, balancedThreshold,
356 for (
uint i = 0; i < metricImbalInclIds.size(); ++i) {
357 uint mId = metricImbalInclIds[i];
360 mId = metricIdleInclIds[i];
370 const std::vector<uint>& m_src,
371 const std::vector<uint>& m_imbalIncl,
372 const std::vector<uint>& m_imbalExcl,
373 const std::vector<uint>& m_idleIncl,
376 double balancedThreshold,
380 using namespace Prof;
382 if (!node) {
return; }
389 if (isFrame &&
isSeparable(static_cast<Prof::CCT::ProcFrm*>(node))) {
394 for (
uint i = 0; i < m_src.size(); ++i) {
395 uint mId_src = m_src[i];
397 uint mId_imbalIncl = m_imbalIncl[i];
398 uint mId_imbalExcl = m_imbalExcl[i];
399 uint mId_idleIncl = m_idleIncl[i];
406 if (balancedNode != balancedFrm && balancedNodeFrm == balancedFrm) {
422 bool isComp = (!isFrame ||
424 !
isMPIFrame(static_cast<Prof::CCT::ProcFrm*>(node))));
425 bool isBalanced = (node_mdata.
demandMetric(mId_bal) <= balancedThreshold);
427 CCT::ANode* balancedFrmNxt = ((isFrame && isBalanced && isComp) ?
429 CCT::ANode* balancedNodeNxt = (isBalanced && isComp) ? node : balancedNode;
436 makeMetrics(x, m_src, m_imbalIncl, m_imbalExcl, m_idleIncl,
437 mId_bal, balancedExpr, balancedThreshold,
438 balancedFrmNxt, balancedNodeNxt);
453 const string& x_lm_nm = x->
lmName();
454 if (x_lm_nm.length() >= s_tag.length()) {
455 return (x_lm_nm.find(s_tag) != string::npos);
471 const string& x_fnm = x->
fileName();
472 if (x_fnm.length() >= s_tag.length()) {
473 size_t tag_beg = x_fnm.length() - s_tag.length();
474 return (x_fnm.compare(tag_beg, s_tag.length(), s_tag) == 0);
static void convertToWorkMetric(Prof::Metric::ADesc *mdesc)
void aggregateMetricsIncl(uint mBegId, uint mEndId)
static const std::string s_tag1
bool insert(Metric::ADesc *m)
static const std::string s_tag3
const char * DIAG_Unimplemented
virtual void make(Prof::CallPath::Profile &prof)
static bool isTimeMetric(const Prof::Metric::ADesc *mdesc)
double metric(size_t mId) const
virtual double finalize(Metric::IData &mdata) const =0
const std::string & nameBase() const
static void makeMetrics(Prof::CallPath::Profile &prof, const Analysis::Args &args, const Analysis::Util::NormalizeProfileArgs_t &nArgs)
static bool isMPIFrame(const Prof::CCT::ProcFrm *x)
ComputedTy computedType() const
static const std::string s_sum
static bool isDerivedMetric(const Prof::Metric::ADesc *mdesc, const std::string &type)
virtual const std::string & procName() const
bool hasMetric(size_t mId) const
virtual const std::string & lmName() const
static const std::string s_tag
virtual void make(Prof::CallPath::Profile &prof)
std::pair< iterator, bool > insert(const VMA beg, const VMA end)
ProcFrm * ancestorProcFrm() const
virtual ADesc * clone() const
void makeMetrics(Prof::CCT::ANode *node, const std::vector< uint > &m_src, const std::vector< uint > &m_imbalIncl, const std::vector< uint > &m_imbalExcl, const std::vector< uint > &m_idleIncl, uint mId_bal, Prof::Metric::AExprIncr *balancedExpr, double balancedThreshold, Prof::CCT::ANode *balancedFrm, Prof::CCT::ANode *balancedNode)
const Metric::Mgr * metricMgr() const
const char * DIAG_UnexpectedInput
virtual uint accumId(int i) const
static const std::string s_cfvar
double demandMetric(size_t mId, size_t size=0) const
virtual bool isSeparable(const Prof::CCT::AProcNode *x)
virtual bool isSeparable(const Prof::CCT::AProcNode *x)=0
virtual const std::string & fileName() const
Metric::ADesc * metric(uint i)
const std::string & description() const
virtual bool isSeparable(const Prof::CCT::AProcNode *x)
static const std::string s_tag2
virtual bool isSeparable(const Prof::CCT::AProcNode *x)
virtual DerivedIncrDesc * clone() const
Metric::AExprIncr * expr() const
static const std::string s_tag
virtual NonUniformDegreeTreeNode * Current() const