[Openmp-commits] [PATCH] D21386: [STATS] Adding process id to output filename

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Tue Jun 21 08:27:33 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL273273: [STATS] Adding process id to output filename (authored by jlpeyton).

Changed prior to commit:
  http://reviews.llvm.org/D21386?vs=60848&id=61380#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21386

Files:
  openmp/trunk/runtime/src/kmp_stats.cpp
  openmp/trunk/runtime/src/kmp_stats.h

Index: openmp/trunk/runtime/src/kmp_stats.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_stats.cpp
+++ openmp/trunk/runtime/src/kmp_stats.cpp
@@ -356,7 +356,6 @@
 /* *************************************************************** */
 /* *************  kmp_stats_output_module functions ************** */
 
-const char* kmp_stats_output_module::outputFileName = NULL;
 const char* kmp_stats_output_module::eventsFileName = NULL;
 const char* kmp_stats_output_module::plotFileName   = NULL;
 int kmp_stats_output_module::printPerThreadFlag       = 0;
@@ -372,7 +371,24 @@
     char * threadEvents   = getenv("KMP_STATS_EVENTS");
 
     // set the stats output filenames based on environment variables and defaults
-    outputFileName = statsFileName;
+    if(statsFileName) {
+        // append the process id to the output filename
+        // events.csv --> events-pid.csv
+        size_t index;
+        std::string baseFileName, pid, suffix;
+        std::stringstream ss;
+        outputFileName = std::string(statsFileName);
+        index = outputFileName.find_last_of('.');
+        if(index == std::string::npos) {
+            baseFileName = outputFileName;
+        } else {
+            baseFileName = outputFileName.substr(0, index);
+            suffix = outputFileName.substr(index);
+        }
+        ss << getpid();
+        pid = ss.str();
+        outputFileName = baseFileName + "-" + pid + suffix;
+    }
     eventsFileName = eventsFileName ? eventsFileName : "events.dat";
     plotFileName   = plotFileName   ? plotFileName   : "events.plt";
 
@@ -573,7 +589,7 @@
     statistic totalStats[TIMER_LAST];           /* Synthesized, cross threads versions of normal timer stats */
     statistic allCounters[COUNTER_LAST];
 
-    FILE * statsOut = outputFileName ? fopen (outputFileName, "a+") : stderr;
+    FILE * statsOut = !outputFileName.empty() ? fopen (outputFileName.c_str(), "a+") : stderr;
     if (!statsOut)
         statsOut = stderr;
 
Index: openmp/trunk/runtime/src/kmp_stats.h
===================================================================
--- openmp/trunk/runtime/src/kmp_stats.h
+++ openmp/trunk/runtime/src/kmp_stats.h
@@ -687,7 +687,7 @@
     };
 
  private:
-    static const char* outputFileName;
+    std::string outputFileName;
     static const char* eventsFileName;
     static const char* plotFileName;
     static int printPerThreadFlag;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21386.61380.patch
Type: text/x-patch
Size: 2450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20160621/6ea28cb8/attachment.bin>


More information about the Openmp-commits mailing list