Kaynağa Gözat

* create a public function starpu_start_fxt_profiling
* add option to starpu_config to choose if we want to
start profiling at starpu init or leave the appl do it later

Andra Hugo 12 yıl önce
ebeveyn
işleme
d6a15c7e7c
5 değiştirilmiş dosya ile 19 ekleme ve 5 silme
  1. 4 0
      include/starpu.h
  2. 1 0
      include/starpu_fxt.h
  3. 11 3
      src/common/fxt.c
  4. 1 1
      src/common/fxt.h
  5. 2 1
      src/core/workers.c

+ 4 - 0
include/starpu.h

@@ -147,6 +147,10 @@ struct starpu_conf
 	/* A driver that the application will run in one of its own threads. */
 	struct starpu_driver *not_launched_drivers;
 	unsigned n_not_launched_drivers;
+
+	/* Indicates whether we start the profiling automatically
+	   or we leave the appl start it if it wants to */
+	unsigned no_auto_profile;
 };
 
 /* Initialize a starpu_conf structure with default values. */

+ 1 - 0
include/starpu_fxt.h

@@ -65,5 +65,6 @@ struct starpu_fxt_options
 
 void starpu_fxt_options_init(struct starpu_fxt_options *options);
 void starpu_fxt_generate_trace(struct starpu_fxt_options *options);
+void starpu_start_fxt_profiling();
 
 #endif /* __STARPU_FXT_H__ */

+ 11 - 3
src/common/fxt.c

@@ -101,7 +101,13 @@ void starpu_set_profiling_id(int new_id)
 	_starpu_profile_set_tracefile(NULL);
 }
 
-void _starpu_start_fxt_profiling(void)
+void starpu_start_fxt_profiling()
+{
+	threadid = _starpu_gettid();
+	fut_keychange(FUT_ENABLE, FUT_KEYMASKALL, threadid);
+}
+
+void _starpu_init_fxt_profiling(unsigned no_auto_profile)
 {
 	unsigned threadid;
 
@@ -127,13 +133,15 @@ void _starpu_start_fxt_profiling(void)
 
 	atexit(_starpu_stop_fxt_profiling);
 
-	if (fut_setup(_STARPU_PROF_BUFFER_SIZE, FUT_KEYMASKALL, threadid) < 0)
+	unsigned int key_mask = no_auto_profile ? 0 : FUT_KEYMASKALL;
+
+	if (fut_setup(_STARPU_PROF_BUFFER_SIZE, key_mask, threadid) < 0)
 	{
 		perror("fut_setup");
 		STARPU_ABORT();
 	}
 
-	fut_keychange(FUT_ENABLE, FUT_KEYMASKALL, threadid);
+	fut_keychange(FUT_ENABLE, key_mask, threadid);
 
 	return;
 }

+ 1 - 1
src/common/fxt.h

@@ -122,7 +122,7 @@ void fut_set_filename(char *filename);
 long _starpu_gettid(void);
 
 /* Initialize the FxT library. */
-void _starpu_start_fxt_profiling(void);
+void _starpu_start_fxt_profiling(unsigned no_auto_profile);
 
 /* Stop the FxT library, and generate the trace file. */
 void _starpu_stop_fxt_profiling(void);

+ 2 - 1
src/core/workers.c

@@ -654,6 +654,7 @@ int starpu_conf_init(struct starpu_conf *conf)
 		conf->disable_asynchronous_opencl_copy = 0;
 #endif
 
+	conf->no_auto_profile = 0;
 	return 0;
 }
 
@@ -780,7 +781,7 @@ int starpu_init(struct starpu_conf *user_conf)
 	_starpu_init_tags();
 
 #ifdef STARPU_USE_FXT
-	_starpu_start_fxt_profiling();
+	_starpu_init_fxt_profiling(config.no_auto_profile);
 #endif
 
 	_starpu_open_debug_logfile();