[Hpctoolkit-commits] r1906 - in trunk/src/lib: banal support

tallent at osp5.lbl.gov tallent at osp5.lbl.gov
Wed Jan 28 14:07:26 PST 2009


Author: tallent
Date: 2009-01-28 14:07:26 -0800 (Wed, 28 Jan 2009)
New Revision: 1906

Modified:
   trunk/src/lib/banal/bloop.cpp
   trunk/src/lib/banal/bloop.hpp
   trunk/src/lib/support/ProcNameMgr.cpp
   trunk/src/lib/support/ProcNameMgr.hpp
Log:
hpcstruct: can now be given a ProcNameMgr to canonicalize procedure names.


Modified: trunk/src/lib/banal/bloop.cpp
===================================================================
--- trunk/src/lib/banal/bloop.cpp	2009-01-28 17:52:52 UTC (rev 1905)
+++ trunk/src/lib/banal/bloop.cpp	2009-01-28 22:07:26 UTC (rev 1906)
@@ -112,30 +112,30 @@
 
 static ProcStrctToProcMap*
 buildLMSkeleton(Struct::LM* lmStrct, BinUtil::LM* lm, 
-		ProcNameMgr* procNameMgr);
+		ProcNameMgr* procNmMgr);
 
 static Struct::File*
 demandFileNode(Struct::LM* lmStrct, BinUtil::Proc* p);
 
 static Struct::Proc*
 demandProcNode(Struct::File* fStrct, BinUtil::Proc* p, 
-	       ProcNameMgr* procNameMgr);
+	       ProcNameMgr* procNmMgr);
 
 
 static Struct::Proc*
 buildProcStructure(Struct::Proc* pStrct, BinUtil::Proc* p, 
-		   bool irrIvalIsLoop, 
-		   bool fwdSubstOff,
+		   bool isIrrIvalLoop, bool fwdSubstOff, ProcNameMgr* procNmMgr,
 		   const std::string& dbgProcGlob); 
 
 static int
 buildProcLoopNests(Struct::Proc* pStrct, BinUtil::Proc* p,
-		   bool irrIvalIsLoop, bool fwdSubstOff, bool isDbg);
+		   bool isIrrIvalLoop, bool fwdSubstOff, 
+		   ProcNameMgr* procNmMgr, bool isDbg);
 
 static int
 buildStmts(bloop::LocationMgr& locMgr,
 	   Struct::ACodeNode* enclosingStrct, BinUtil::Proc* p,
-	   OA::OA_ptr<OA::CFG::NodeInterface> bb);
+	   OA::OA_ptr<OA::CFG::NodeInterface> bb, ProcNameMgr* procNmMgr);
 
 
 static void
@@ -185,7 +185,7 @@
 mergeBogusAlienStrct(Prof::Struct::LM* lmStrct);
 
 static bool
-coalesceDuplicateStmts(Prof::Struct::LM* lmStrct, bool unsafeNormalizations);
+coalesceDuplicateStmts(Prof::Struct::LM* lmStrct, bool doNormalizeUnsafe);
 
 static bool 
 mergePerfectlyNestedLoops(Struct::ANode* node);
@@ -300,11 +300,11 @@
 //   optimizations such as loop unrolling.
 Prof::Struct::LM*
 banal::bloop::makeStructure(BinUtil::LM* lm, 
-			    bool normalizeScopeTree,
-			    bool unsafeNormalizations,
-			    bool irreducibleIntervalIsLoop,
-			    bool forwardSubstitutionOff,
-			    ProcNameMgr* procNameMgr,
+			    bool doNormalize,
+			    bool doNormalizeUnsafe,
+			    bool isIrrIvalLoop,
+			    bool fwdSubstOff,
+			    ProcNameMgr* procNmMgr,
 			    const std::string& dbgProcGlob)
 {
   // Assume lm->Read() has been performed
@@ -316,7 +316,7 @@
   Struct::LM* lmStrct = new Struct::LM(lm->name(), NULL);
 
   // 1. Build Struct::File/Struct::Proc skeletal structure
-  ProcStrctToProcMap* mp = buildLMSkeleton(lmStrct, lm, procNameMgr);
+  ProcStrctToProcMap* mp = buildLMSkeleton(lmStrct, lm, procNmMgr);
   
   // 2. For each [Struct::Proc, BinUtil::Proc] pair, complete the build.
   // Note that a Struct::Proc may be associated with more than one
@@ -326,15 +326,14 @@
     BinUtil::Proc* p = it->second;
 
     DIAG_Msg(2, "Building scope tree for [" << p->name()  << "] ... ");
-    buildProcStructure(pStrct, p, 
-		       irreducibleIntervalIsLoop, forwardSubstitutionOff,
-		       dbgProcGlob);
+    buildProcStructure(pStrct, p, isIrrIvalLoop, fwdSubstOff, 
+		       procNmMgr, dbgProcGlob);
   }
   delete mp;
 
   // 3. Normalize
-  if (normalizeScopeTree) {
-    bool result = normalize(lmStrct, unsafeNormalizations);
+  if (doNormalize) {
+    bool result = normalize(lmStrct, doNormalizeUnsafe);
     DIAG_Assert(result, "Normalization result should never be false!");
   }
 
@@ -347,7 +346,7 @@
 // almost all unnormalized scope tree contain duplicate statement
 // instances.  See each normalizing routine for more information.
 bool 
-banal::bloop::normalize(Prof::Struct::LM* lmStrct, bool unsafeNormalizations)
+banal::bloop::normalize(Prof::Struct::LM* lmStrct, bool doNormalizeUnsafe)
 {
   bool changed = false;
   
@@ -355,7 +354,7 @@
   changed |= mergeBogusAlienStrct(lmStrct);
 
   // Cleanup procedure/alien scopes
-  changed |= coalesceDuplicateStmts(lmStrct, unsafeNormalizations);
+  changed |= coalesceDuplicateStmts(lmStrct, doNormalizeUnsafe);
   changed |= mergePerfectlyNestedLoops(lmStrct);
   changed |= removeEmptyNodes(lmStrct);
   
@@ -380,7 +379,7 @@
 //
 // Struct::Procs will be sorted by begLn (cf. Struct::ACodeNode::Reorder)
 static ProcStrctToProcMap*
-buildLMSkeleton(Struct::LM* lmStrct, BinUtil::LM* lm, ProcNameMgr* procNameMgr)
+buildLMSkeleton(Struct::LM* lmStrct, BinUtil::LM* lm, ProcNameMgr* procNmMgr)
 {
   ProcStrctToProcMap* mp = new ProcStrctToProcMap;
   
@@ -393,7 +392,7 @@
     BinUtil::Proc* p = it->second;
     if (p->size() != 0) {
       Struct::File* fStrct = demandFileNode(lmStrct, p);
-      Struct::Proc* pStrct = demandProcNode(fStrct, p, procNameMgr);
+      Struct::Proc* pStrct = demandProcNode(fStrct, p, procNmMgr);
       mp->insert(make_pair(pStrct, p));
     }
   }
@@ -452,7 +451,7 @@
 // the parent is always a Struct::File.
 static Struct::Proc*
 demandProcNode(Struct::File* fStrct, BinUtil::Proc* p, 
-	       ProcNameMgr* procNameMgr)
+	       ProcNameMgr* procNmMgr)
 {
   // Find VMA boundaries: [beg, end)
   VMA endVMA = p->begVMA() + p->size();
@@ -461,8 +460,8 @@
 	      << bounds.toString());
   
   // Find procedure name
-  string procNm   = BinUtil::canonicalizeProcName(p->name(), procNameMgr);
-  string procLnNm = BinUtil::canonicalizeProcName(p->linkName(), procNameMgr);
+  string procNm   = BinUtil::canonicalizeProcName(p->name(), procNmMgr);
+  string procLnNm = BinUtil::canonicalizeProcName(p->linkName(), procNmMgr);
   
   // Find preliminary source line bounds
   string file, proc;
@@ -524,21 +523,23 @@
 		   OA::OA_ptr<OA::NestedSCR> tarj,
 		   OA::OA_ptr<OA::CFG::CFGInterface> cfg, 
 		   OA::RIFG::NodeId fgRoot, 
-		   bool irrIvalIsLoop, bool fwdSubstOff, bool isDbg);
+		   bool isIrrIvalLoop, bool fwdSubstOff,
+		   ProcNameMgr* procNmMgr, bool isDbg);
 
 static Struct::ACodeNode*
 buildLoopAndStmts(bloop::LocationMgr& locMgr, 
 		  Struct::ACodeNode* enclosingStrct, BinUtil::Proc* p,
 		  OA::OA_ptr<OA::NestedSCR> tarj,
 		  OA::OA_ptr<OA::CFG::CFGInterface> cfg, 
-		  OA::RIFG::NodeId fgNode, bool irrIvalIsLoop);
+		  OA::RIFG::NodeId fgNode,
+		  bool isIrrIvalLoop, ProcNameMgr* procNmMgr);
 
 
 // buildProcStructure: Complete the representation for 'pStrct' given the
 // BinUtil::Proc 'p'.  Note that pStrcts parent may itself be a Struct::Proc.
 static Struct::Proc* 
 buildProcStructure(Struct::Proc* pStrct, BinUtil::Proc* p,
-		   bool irrIvalIsLoop, bool fwdSubstOff,
+		   bool isIrrIvalLoop, bool fwdSubstOff, ProcNameMgr* procNmMgr,
 		   const std::string& dbgProcGlob)
 {
   DIAG_Msg(3, "==> Proc `" << p->name() << "' (" << p->id() << ") <==");
@@ -549,7 +550,7 @@
     isDbg = FileUtil::fnmatch(dbgProcGlob, p->name().c_str());
   }
   
-  buildProcLoopNests(pStrct, p, irrIvalIsLoop, fwdSubstOff, isDbg);
+  buildProcLoopNests(pStrct, p, isIrrIvalLoop, fwdSubstOff, procNmMgr, isDbg);
   
   return pStrct;
 }
@@ -560,7 +561,8 @@
 // scopes.
 static int
 buildProcLoopNests(Struct::Proc* pStrct, BinUtil::Proc* p,
-		   bool irrIvalIsLoop, bool fwdSubstOff, bool isDbg)
+		   bool isIrrIvalLoop, bool fwdSubstOff, 
+		   ProcNameMgr* procNmMgr, bool isDbg)
 {
   static const int sepWidth = 77;
   using std::setfill;
@@ -612,7 +614,7 @@
     }
 
     int r = buildProcLoopNests(pStrct, p, tarj, cfg, fgRoot,
-			       irrIvalIsLoop, fwdSubstOff, isDbg);
+			       isIrrIvalLoop, fwdSubstOff, procNmMgr, isDbg);
 
     if (isDbg) {
       cerr << setfill('-') << setw(sepWidth) << "-" << endl;
@@ -638,7 +640,8 @@
 		   OA::OA_ptr<OA::NestedSCR> tarj,
 		   OA::OA_ptr<OA::CFG::CFGInterface> cfg, 
 		   OA::RIFG::NodeId fgRoot, 
-		   bool irrIvalIsLoop, bool fwdSubstOff, bool isDbg)
+		   bool isIrrIvalLoop, bool fwdSubstOff, 
+		   ProcNameMgr* procNmMgr, bool isDbg)
 {
   typedef std::list<QNode> MyQueue;
 
@@ -696,7 +699,8 @@
       // below ensure that this context has been fully explored.
       Struct::ACodeNode* myScope;
       myScope = buildLoopAndStmts(locMgr, qnode.enclosingStrct, p,
-				  tarj, cfg, qnode.fgNode, irrIvalIsLoop);
+				  tarj, cfg, qnode.fgNode, isIrrIvalLoop, 
+				  procNmMgr);
       isNodeProcessed[qnode.fgNode] = true;
       qnode.scope = myScope;
       if (myScope->type() == Struct::ANode::TyLOOP) {
@@ -716,7 +720,7 @@
     do {
       Struct::ACodeNode* myScope;
       myScope = buildLoopAndStmts(locMgr, qnode.scope, p, 
-				  tarj, cfg, kid, irrIvalIsLoop);
+				  tarj, cfg, kid, isIrrIvalLoop, procNmMgr);
       isNodeProcessed[kid] = true;
       if (myScope->type() == Struct::ANode::TyLOOP) {
 	nLoops++;
@@ -757,7 +761,8 @@
   for (uint i = 1; i < isNodeProcessed.size(); ++i) {
     if (!isNodeProcessed[i]) {
       // INVARIANT: return value is never a Struct::Loop
-      buildLoopAndStmts(locMgr, enclosingProc, p, tarj, cfg, i, irrIvalIsLoop);
+      buildLoopAndStmts(locMgr, enclosingProc, p, tarj, cfg, i, isIrrIvalLoop,
+			procNmMgr);
     }
   }
 
@@ -775,7 +780,8 @@
 		  Struct::ACodeNode* enclosingStrct, BinUtil::Proc* p,
 		  OA::OA_ptr<OA::NestedSCR> tarj,
 		  OA::OA_ptr<OA::CFG::CFGInterface> cfg, 
-		  OA::RIFG::NodeId fgNode, bool irrIvalIsLoop)
+		  OA::RIFG::NodeId fgNode, 
+		  bool isIrrIvalLoop, ProcNameMgr* procNmMgr)
 {
   OA::OA_ptr<OA::RIFG> rifg = tarj->getRIFG();
   OA::OA_ptr<OA::CFG::NodeInterface> bb = 
@@ -795,21 +801,21 @@
     // -----------------------------------------------------
   }
   else if (ity == OA::NestedSCR::NODE_INTERVAL || 
-	   (irrIvalIsLoop && ity == OA::NestedSCR::NODE_IRREDUCIBLE)) {
+	   (isIrrIvalLoop && ity == OA::NestedSCR::NODE_IRREDUCIBLE)) {
     // -----------------------------------------------------
     // INTERVAL or IRREDUCIBLE as a loop: Loop head
     // -----------------------------------------------------
     string fnm, pnm;
     SrcFile::ln line;
     findLoopBegLineInfo(p, bb, fnm, pnm, line);
-    pnm = BinUtil::canonicalizeProcName(pnm);
+    pnm = BinUtil::canonicalizeProcName(pnm, procNmMgr);
     
     Struct::Loop* loop = new Struct::Loop(NULL, line, line);
     loop->vmaSet().insert(begVMA, begVMA + 1); // a loop id
     locMgr.locate(loop, enclosingStrct, fnm, pnm, line);
     childScope = loop;
   }
-  else if (!irrIvalIsLoop && ity == OA::NestedSCR::NODE_IRREDUCIBLE) {
+  else if (!isIrrIvalLoop && ity == OA::NestedSCR::NODE_IRREDUCIBLE) {
     // -----------------------------------------------------
     // IRREDUCIBLE as no loop: May contain loops
     // -----------------------------------------------------
@@ -821,7 +827,7 @@
   // -----------------------------------------------------
   // Process instructions within BB
   // -----------------------------------------------------
-  buildStmts(locMgr, childScope, p, bb);
+  buildStmts(locMgr, childScope, p, bb, procNmMgr);
 
   return childScope;
 }
@@ -833,7 +839,7 @@
 static int 
 buildStmts(bloop::LocationMgr& locMgr,
 	   Struct::ACodeNode* enclosingStrct, BinUtil::Proc* p,
-	   OA::OA_ptr<OA::CFG::NodeInterface> bb)
+	   OA::OA_ptr<OA::CFG::NodeInterface> bb, ProcNameMgr* procNmMgr)
 {
   static int call_sortId = 0;
 
@@ -852,7 +858,7 @@
     string filenm, procnm;
     SrcFile::ln line;
     p->GetSourceFileInfo(vma, opIdx, procnm, filenm, line); 
-    procnm = BinUtil::canonicalizeProcName(procnm);
+    procnm = BinUtil::canonicalizeProcName(procnm, procNmMgr);
 
     // 2. create a VMA interval
     // the next (or hypothetically next) insn begins no earlier than:
@@ -895,7 +901,7 @@
 		   OA::OA_ptr<OA::NestedSCR> tarj,
 		   OA::OA_ptr<OA::CFG::Interface> cfg, 
 		   OA::RIFG::NodeId fgNode, 
-		   int addStmts, bool irrIvalIsLoop)
+		   int addStmts, bool isIrrIvalLoop)
 {
   int localLoops = 0;
   OA::OA_ptr<OA::RIFG> rifg = tarj->getRIFG();
@@ -926,7 +932,7 @@
       }
     }
     else if (ity == OA::NestedSCR::NODE_INTERVAL || 
-	     (irrIvalIsLoop && ity == OA::NestedSCR::NODE_IRREDUCIBLE)) {
+	     (isIrrIvalLoop && ity == OA::NestedSCR::NODE_IRREDUCIBLE)) {
       // -----------------------------------------------------
       // INTERVAL or IRREDUCIBLE as a loop: Loop head
       // -----------------------------------------------------
@@ -934,15 +940,15 @@
       // add alien context if necessary....
       Struct::Loop* lScope = new Struct::Loop(enclosingStrct, line, line);
       int num = buildProcLoopNests(lScope, p, tarj, cfg, kid, mp,
-				   1, irrIvalIsLoop);
+				   1, isIrrIvalLoop);
       localLoops += (num + 1);
     }
-    else if (!irrIvalIsLoop && ity == OA::NestedSCR::NODE_IRREDUCIBLE) {
+    else if (!isIrrIvalLoop && ity == OA::NestedSCR::NODE_IRREDUCIBLE) {
       // -----------------------------------------------------
       // IRREDUCIBLE as no loop: May contain loops
       // -----------------------------------------------------
       int num = buildProcLoopNests(enclosingStrct, p, tarj, cfg, kid, mp,
-				   addStmts, irrIvalIsLoop);
+				   addStmts, isIrrIvalLoop);
       localLoops += num;
     }
     else {
@@ -1155,7 +1161,7 @@
 //   instances.
 // E.g.: lca ---...--- s1
 //          \---...--- s2
-static bool CDS_unsafeNormalizations = true;
+static bool CDS_doNormalizeUnsafe = true;
 
 static bool
 coalesceDuplicateStmts(Struct::ACodeNode* scope, SortIdToStmtMap* stmtMap, 
@@ -1178,10 +1184,10 @@
 }
 
 static bool
-coalesceDuplicateStmts(Prof::Struct::LM* lmStrct, bool unsafeNormalizations)
+coalesceDuplicateStmts(Prof::Struct::LM* lmStrct, bool doNormalizeUnsafe)
 {
   bool changed = false;
-  CDS_unsafeNormalizations = unsafeNormalizations;
+  CDS_doNormalizeUnsafe = doNormalizeUnsafe;
   SortIdToStmtMap stmtMap;    // line to statement data map
   Struct::ANodeSet visitedScopes; // all children of a scope have been visited
   Struct::ANodeSet toDelete;      // nodes to delete
@@ -1372,7 +1378,7 @@
       DIAG_DevMsgIf(DBG_CDS, "  Delete: " << toRemove);
       changed = true;
     } 
-    else if (CDS_unsafeNormalizations) {
+    else if (CDS_doNormalizeUnsafe) {
       // Case 2: Duplicate statements in different loops (or scopes).
       // Merge the nodes from stmt2->lca into those from stmt1->lca.
       DIAG_DevMsgIf(DBG_CDS, "  Merge: " << stmt1 << " <- " << stmt2);

Modified: trunk/src/lib/banal/bloop.hpp
===================================================================
--- trunk/src/lib/banal/bloop.hpp	2009-01-28 17:52:52 UTC (rev 1905)
+++ trunk/src/lib/banal/bloop.hpp	2009-01-28 22:07:26 UTC (rev 1906)
@@ -72,10 +72,10 @@
   
   Prof::Struct::LM* 
   makeStructure(BinUtil::LM* lm, 
-		bool normalizeScopeTree = true,
-		bool unsafeNormalizations = true,
-		bool irreducibleIntervalIsLoop = false,
-		bool forwardSubstitutionOff = false,
+		bool doNormalize = true,
+		bool doNormalizeUnsafe = true,
+		bool isIrrIvalLoop = false,
+		bool fwdSubstOff = false,
 		ProcNameMgr* procNameMgr = NULL,
 		const std::string& dbgProcGlob = "");
   
@@ -84,7 +84,7 @@
 
 
   bool 
-  normalize(Prof::Struct::LM* lmStrct, bool unsafeNormalizations = true);
+  normalize(Prof::Struct::LM* lmStrct, bool doNormalizeUnsafe = true);
 
   void
   writeStructure(std::ostream& os, Prof::Struct::Tree* strctTree,

Modified: trunk/src/lib/support/ProcNameMgr.cpp
===================================================================
--- trunk/src/lib/support/ProcNameMgr.cpp	2009-01-28 17:52:52 UTC (rev 1905)
+++ trunk/src/lib/support/ProcNameMgr.cpp	2009-01-28 22:07:26 UTC (rev 1906)
@@ -69,24 +69,78 @@
 // CilkNameMgr
 //***************************************************************************
 
-const string CilkNameMgr::s_slow_pfx = "_cilk_";
-const string CilkNameMgr::s_slow_sfx = "_slow";
+// Cilk creates four specializations of each procedure:
+//   fast:    <x>
+//   slow:   _cilk_<x>_slow
+//   import: _cilk_<x>_import
+//   export: mt_<x>
 
+const string CilkNameMgr::s_procSlow_pfx   = "_cilk_";
+const string CilkNameMgr::s_procSlow_sfx   = "_slow";
 
+const string CilkNameMgr::s_procImport_pfx = "_cilk_";
+const string CilkNameMgr::s_procImport_sfx = "_import";
+
+const string CilkNameMgr::s_procExport_pfx = "mt_";
+const string CilkNameMgr::s_procExport_sfx = "";
+
+
+// Cilk 'outlines' an inlet <x> within a procedure <proc>, creating
+// three specializations:
+//   norm: _cilk_<proc>_<x>_inlet
+//   fast: _cilk_<proc>_<x>_inlet_fast
+//   slow: _cilk_<proc>_<x>_inlet_slow
+
+const string CilkNameMgr::s_inletNorm_pfx = "_cilk_";
+const string CilkNameMgr::s_inletNorm_sfx = "_inlet";
+
+const string CilkNameMgr::s_inletFast_pfx = "_cilk_";
+const string CilkNameMgr::s_inletFast_sfx = "_inlet_fast";
+
+const string CilkNameMgr::s_inletSlow_pfx = "_cilk_";
+const string CilkNameMgr::s_inletSlow_sfx = "_inlet_slow";
+
+
 string
 CilkNameMgr::canonicalize(const string& name)
 {
-  if (name == "_cilk_cilk_main_import") {
-    // 1. _cilk_cilk_main_import --> invoke_main_slow    
+  // ------------------------------------------------------------
+  // inlets: must test before procedures because of _slow suffix
+  // ------------------------------------------------------------
+  if (isGenerated(name, s_inletNorm_pfx, s_inletNorm_sfx)) {
+    return basename(name, s_inletNorm_pfx, s_inletNorm_sfx);
+  }
+  else if (isGenerated(name, s_inletFast_pfx, s_inletFast_sfx)) {
+    return basename(name, s_inletFast_pfx, s_inletFast_sfx);
+  }
+  else if (isGenerated(name, s_inletSlow_pfx, s_inletSlow_sfx)) {
+    return basename(name, s_inletSlow_pfx, s_inletSlow_sfx);
+  }
+
+  // ------------------------------------------------------------
+  // procedures
+  // ------------------------------------------------------------
+  else if (isGenerated(name, s_procSlow_pfx, s_procSlow_sfx)) {
+    return basename(name, s_procSlow_pfx, s_procSlow_sfx);
+  }
+  else if (isGenerated(name, s_procImport_pfx, s_procImport_sfx)) {
+    return basename(name, s_procImport_pfx, s_procImport_sfx);
+  }
+  else if (isGenerated(name, s_procExport_pfx, s_procExport_sfx)) {
+    return basename(name, s_procExport_pfx, s_procExport_sfx);
+  }
+
+  // ------------------------------------------------------------
+  // special case
+  // ------------------------------------------------------------
+  else if (name == "_cilk_cilk_main_import") {
+    // _cilk_cilk_main_import --> invoke_main_slow
     return "invoke_main_slow";
   }
-  else if (is_slow_proc(name)) {
-    // 2. if '_cilk' is a prefix of name, apply:
-    //      _cilk_<x>_slow --> <x>  (_cilk_cilk_main_slow --> cilk_main)
-    int len = name.length() - s_slow_pfx.length() - s_slow_sfx.length();
-    string canon_nm = name.substr(s_slow_pfx.length(), len);
-    return canon_nm;
-  }
+
+  // ------------------------------------------------------------
+  // default
+  // ------------------------------------------------------------
   else {
     return name;
   }

Modified: trunk/src/lib/support/ProcNameMgr.hpp
===================================================================
--- trunk/src/lib/support/ProcNameMgr.hpp	2009-01-28 17:52:52 UTC (rev 1905)
+++ trunk/src/lib/support/ProcNameMgr.hpp	2009-01-28 22:07:26 UTC (rev 1906)
@@ -99,14 +99,35 @@
 private:
 
   bool 
-  is_slow_proc(const std::string& x)
+  isGenerated(const std::string& x, 
+	      const std::string& pfx, const std::string& sfx)
   {
-    return (x.compare(0, s_slow_pfx.length(), s_slow_pfx) == 0);
+    bool isSane = (x.length() > (pfx.length() + sfx.length()));
+    size_t sfx_pos = x.length() - sfx.length();
+
+    // test suffix first becuase it fails more than the prefix comparison
+    return (isSane && 
+	    x.compare(sfx_pos, sfx.length(), sfx) == 0 &&
+	    x.compare(0, pfx.length(), pfx) == 0);
   }
 
+  std::string 
+  basename(const std::string& x, 
+	   const std::string& pfx, const std::string& sfx)
+  {
+    // Assume: x.length() > (pfx.length() + sfx.length())
+    int len = x.length() - pfx.length() - sfx.length();
+    return x.substr(pfx.length(), len);
+  }
+
 private:
-  static const std::string s_slow_pfx;
-  static const std::string s_slow_sfx;
+  static const std::string s_procSlow_pfx,   s_procSlow_sfx;
+  static const std::string s_procImport_pfx, s_procImport_sfx;
+  static const std::string s_procExport_pfx, s_procExport_sfx;
+
+  static const std::string s_inletNorm_pfx, s_inletNorm_sfx;
+  static const std::string s_inletFast_pfx, s_inletFast_sfx;
+  static const std::string s_inletSlow_pfx, s_inletSlow_sfx;
 };
 
 



More information about the Hpctoolkit-commits mailing list