소스 검색

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

Cédric Augonnet 15 년 전
부모
커밋
ca41b1537d
3개의 변경된 파일21개의 추가작업 그리고 8개의 파일을 삭제
  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();
 }