creat different directories for different replicas
authorYanhuaSun <sun51@illinois.edu>
Thu, 31 Jan 2013 00:36:59 +0000 (18:36 -0600)
committerNikhil Jain <nikhil@illinois.edu>
Mon, 4 Feb 2013 07:12:23 +0000 (01:12 -0600)
src/ck-perf/trace-common.C

index ce749b77dfb775ec73c4634f74ae0e714dea9f03..3f677cefae28754e390c99bab23b7edd421da4a7 100644 (file)
@@ -3,6 +3,9 @@
 */
 /*@{*/
 
+#include <sys/stat.h>
+#include <sys/types.h>
+
 #include "charm.h"
 #include "middle.h"
 #include "cklists.h"
@@ -79,6 +82,10 @@ static void traceCommonInit(char **argv)
   char *temproot2;
   CkpvInitialize(char*, traceRoot);
   CkpvInitialize(int, traceRootBaseLength);
+
+  char subdir[20];
+  sprintf(subdir, "%d%s", CmiMyPartition(), PATHSEPSTR);
+
   if (CmiGetArgStringDesc(argv, "+traceroot", &temproot, "Directory to write trace files to")) {
     int i;
     // Trying to decide if the traceroot path is absolute or not. If it is not
@@ -96,18 +103,25 @@ static void traceCommonInit(char **argv)
     for (i=strlen(argv[0])-1; i>=0; i--) if (argv[0][i] == PATHSEP) break;
     i++;
     CkpvAccess(traceRootBaseLength) = strlen(root)+1;
-    CkpvAccess(traceRoot) = (char *)malloc(strlen(argv[0]+i) + strlen(root) + 2);    _MEMCHECK(CkpvAccess(traceRoot));
+    CkpvAccess(traceRoot) = (char *)malloc(strlen(argv[0]+i) + strlen(root) + 2 +strlen(subdir));    _MEMCHECK(CkpvAccess(traceRoot));
     strcpy(CkpvAccess(traceRoot), root);
     strcat(CkpvAccess(traceRoot), PATHSEPSTR);
+    strcat(CkpvAccess(traceRoot), subdir);
+    if(CmiMyPe() == 0)
+        CmiMkdir(CkpvAccess(traceRoot));
     strcat(CkpvAccess(traceRoot), argv[0]+i);
     if (CkMyPe() == 0) 
       CmiPrintf("Trace: traceroot: %s\n", CkpvAccess(traceRoot));
   }
   else {
-    CkpvAccess(traceRoot) = (char *) malloc(strlen(argv[0])+1);
+    CkpvAccess(traceRoot) = (char *) malloc(strlen(argv[0])+1 +strlen(subdir));
     _MEMCHECK(CkpvAccess(traceRoot));
-    strcpy(CkpvAccess(traceRoot), argv[0]);
+    strcpy(CkpvAccess(traceRoot), subdir);
+    if(CmiMyPe() == 0)
+        CmiMkdir(CkpvAccess(traceRoot));
+    strcat(CkpvAccess(traceRoot), argv[0]);
   }
+  CkpvAccess(traceRootBaseLength)  +=  strlen(subdir);
        /* added for TAU trace module. */
        char *cwd;
   CkpvInitialize(char*, selective);