Explorar el Código

We do not wait until the termination of the program (with atexit) to actually
write the fxt trace.

Cédric Augonnet hace 15 años
padre
commit
ca41b1537d
Se han modificado 3 ficheros con 21 adiciones y 8 borrados
  1. 16 8
      src/common/fxt.c
  2. 1 0
      src/common/fxt.h
  3. 4 0
      src/core/workers.c

+ 16 - 8
src/common/fxt.c

@@ -25,10 +25,7 @@
 static char PROF_FILE_USER[128];
 static int fxt_started = 0;
 
-static void profile_stop(void)
-{
-	fut_endup(PROF_FILE_USER);
-}
+static int written = 0;
 
 static void profile_set_tracefile(char *fmt, ...)
 {
@@ -49,11 +46,8 @@ static void profile_set_tracefile(char *fmt, ...)
 	snprintf(suffix, 128, "_user_%s_%d", user, pid);
 
 	strcat(PROF_FILE_USER, suffix);
-
-
 }
 
-
 void start_fxt_profiling(void)
 {
 	unsigned threadid;
@@ -65,7 +59,7 @@ void start_fxt_profiling(void)
 
 	threadid = syscall(SYS_gettid);
 
-	atexit(profile_stop);
+	atexit(stop_fxt_profiling);
 
 	if(fut_setup(PROF_BUFFER_SIZE, FUT_KEYMASKALL, threadid) < 0) {
 		perror("fut_setup");
@@ -77,6 +71,20 @@ void start_fxt_profiling(void)
 	return;
 }
 
+void stop_fxt_profiling(void)
+{
+	if (!written)
+	{
+#ifdef VERBOSE
+	        char hostname[128];
+		gethostname(hostname, 128);
+		fprintf(stderr, "Writing FxT traces into file %s:%s\n", hostname, PROF_FILE_USER);
+#endif
+		fut_endup(PROF_FILE_USER);
+		written = 1;
+	}
+}
+
 void fxt_register_thread(unsigned coreid)
 {
 	FUT_DO_PROBE2(FUT_NEW_LWP_CODE, coreid, syscall(SYS_gettid));

+ 1 - 0
src/common/fxt.h

@@ -91,6 +91,7 @@
 #include <fxt/fut.h>
 
 void start_fxt_profiling(void);
+void stop_fxt_profiling(void);
 void fxt_register_thread(unsigned);
 
 /* sometimes we need something a little more specific than the wrappers from

+ 4 - 0
src/core/workers.c

@@ -440,6 +440,10 @@ void starpu_shutdown(void)
 
 	starpu_destroy_topology(&config);
 
+#ifdef USE_FXT
+	stop_fxt_profiling();
+#endif
+
 	_starpu_close_debug_logfile();
 }