Browse Source

New option -d for starpu_fxt_tool to specify in which directory to generate files

Nathalie Furmento 5 years ago
parent
commit
871c28f9b6
4 changed files with 67 additions and 0 deletions
  1. 2 0
      ChangeLog
  2. 3 0
      include/starpu_fxt.h
  3. 50 0
      src/debug/traces/starpu_fxt.c
  4. 12 0
      tools/starpu_fxt_tool.c

+ 2 - 0
ChangeLog

@@ -53,6 +53,8 @@ StarPU 1.3.5 (git revision xxx)
 Small features:
   * New environment variable STARPU_FXT_SUFFIX to set the filename in
     which to save the fxt trace
+  * New option -d for starpu_fxt_tool to specify in which directory to
+    generate files
 
 Small changes:
   * Move MPI cache functions into the public API

+ 3 - 0
include/starpu_fxt.h

@@ -69,6 +69,7 @@ struct starpu_fxt_options
 	char *number_events_path;
 	char *anim_path;
 	char *states_path;
+	char *dir;
 	char worker_names[STARPU_NMAXWORKERS][256];
 	int nworkers;
 	struct starpu_perfmodel_arch worker_archtypes[STARPU_NMAXWORKERS];
@@ -104,6 +105,8 @@ struct starpu_fxt_options
 };
 
 void starpu_fxt_options_init(struct starpu_fxt_options *options);
+void starpu_fxt_options_shutdown(struct starpu_fxt_options *options);
+void starpu_fxt_options_set_dir(struct starpu_fxt_options *options);
 void starpu_fxt_generate_trace(struct starpu_fxt_options *options);
 
 /**

+ 50 - 0
src/debug/traces/starpu_fxt.c

@@ -4265,6 +4265,56 @@ void starpu_fxt_options_init(struct starpu_fxt_options *options)
 	options->sched_tasks_path = "sched_tasks.rec";
 }
 
+void _set_dir(char *dir, char **option)
+{
+	if (*option)
+	{
+		char *tmp = strdup(*option);
+		_STARPU_MALLOC(*option, 256);
+		snprintf(*option, 256, "%s/%s", dir, tmp);
+		free(tmp);
+	}
+}
+
+void starpu_fxt_options_set_dir(struct starpu_fxt_options *options)
+{
+	if (!options->dir)
+		return;
+
+	_starpu_mkpath_and_check(options->dir, S_IRWXU);
+	_set_dir(options->dir, &options->out_paje_path);
+	_set_dir(options->dir, &options->dag_path);
+	_set_dir(options->dir, &options->tasks_path);
+	_set_dir(options->dir, &options->comms_path);
+	_set_dir(options->dir, &options->number_events_path);
+	_set_dir(options->dir, &options->data_path);
+	_set_dir(options->dir, &options->papi_path);
+	_set_dir(options->dir, &options->anim_path);
+	_set_dir(options->dir, &options->states_path);
+	_set_dir(options->dir, &options->distrib_time_path);
+	_set_dir(options->dir, &options->activity_path);
+	_set_dir(options->dir, &options->sched_tasks_path);
+}
+
+void starpu_fxt_options_shutdown(struct starpu_fxt_options *options)
+{
+	if (options->dir)
+	{
+		free(options->out_paje_path);
+		free(options->dag_path);
+		free(options->tasks_path);
+		free(options->comms_path);
+		free(options->number_events_path);
+		free(options->data_path);
+		free(options->papi_path);
+		free(options->anim_path);
+		free(options->states_path);
+		free(options->distrib_time_path);
+		free(options->activity_path);
+		free(options->sched_tasks_path);
+	}
+}
+
 static
 void _starpu_fxt_distrib_file_init(struct starpu_fxt_options *options)
 {

+ 12 - 0
tools/starpu_fxt_tool.c

@@ -77,6 +77,13 @@ static int parse_args(int argc, char **argv)
 			continue;
 		}
 
+		if (strcmp(argv[i], "-d") == 0)
+		{
+			options.dir = argv[++i];
+			reading_input_filenames = 0;
+			continue;
+		}
+
 		if (strcmp(argv[i], "-i") == 0)
 		{
 			if (options.ninputfiles >= STARPU_FXT_MAX_FILES)
@@ -193,6 +200,9 @@ static int parse_args(int argc, char **argv)
                 usage();
 		return 77;
 	}
+
+	starpu_fxt_options_set_dir(&options);
+
 	return 0;
 }
 
@@ -203,5 +213,7 @@ int main(int argc, char **argv)
 
 	starpu_fxt_generate_trace(&options);
 
+	starpu_fxt_options_shutdown(&options);
+
 	return 0;
 }