Ver código fonte

fxt: fix parsing of options when using variable STARPU_GENERATE_TRACE_OPTIONS

Nathalie Furmento 3 anos atrás
pai
commit
829fe8b9ca
3 arquivos alterados com 20 adições e 90 exclusões
  1. 10 3
      src/common/fxt.c
  2. 2 0
      src/common/fxt.h
  3. 8 87
      tools/starpu_fxt_tool.c

+ 10 - 3
src/common/fxt.c

@@ -213,7 +213,7 @@ void _starpu_fxt_init_profiling(uint64_t trace_buffer_size)
 	return;
 }
 
-static void _starpu_generate_paje_trace_read_option(const char *option, struct starpu_fxt_options *options)
+int _starpu_generate_paje_trace_read_option(const char *option, struct starpu_fxt_options *options)
 {
 	if (strcmp(option, "-c") == 0)
 	{
@@ -255,10 +255,15 @@ static void _starpu_generate_paje_trace_read_option(const char *option, struct s
 	{
 		options->label_deps = 1;
 	}
+	else if (strcmp(option, "-number-events") == 0)
+	{
+		options->number_events_path = strdup("number_events.data");
+	}
 	else
 	{
-		_STARPU_MSG("Option <%s> is not a valid option for starpu_fxt_tool\n", option);
+		return 1;
 	}
+	return 0;
 }
 
 static void _starpu_generate_paje_trace(char *input_fxt_filename, char *output_paje_filename, char *dirname)
@@ -273,7 +278,9 @@ static void _starpu_generate_paje_trace(char *input_fxt_filename, char *output_p
 		char *option = strtok(trace_options, " ");
 		while (option)
 		{
-			_starpu_generate_paje_trace_read_option(option, &options);
+			int ret = _starpu_generate_paje_trace_read_option(option, &options);
+			if (ret == 1)
+				_STARPU_MSG("Option <%s> is not a valid option for starpu_fxt_tool\n", option);
 			option = strtok(NULL, " ");
 		}
 	}

+ 2 - 0
src/common/fxt.h

@@ -316,6 +316,8 @@ static inline unsigned long _starpu_fxt_get_submit_order(void)
 
 long _starpu_gettid(void) STARPU_ATTRIBUTE_VISIBILITY_DEFAULT;
 
+int _starpu_generate_paje_trace_read_option(const char *option, struct starpu_fxt_options *options) STARPU_ATTRIBUTE_VISIBILITY_DEFAULT;
+
 /** Initialize the FxT library. */
 void _starpu_fxt_init_profiling(uint64_t trace_buffer_size);
 

+ 8 - 87
tools/starpu_fxt_tool.c

@@ -21,6 +21,7 @@
 
 #include <starpu.h>
 #include <common/config.h>
+#include <common/fxt.h>
 
 #define PROGNAME "starpu_fxt_tool"
 
@@ -65,29 +66,23 @@ static int parse_args(int argc, char **argv)
 	int i;
 	for (i = 1; i < argc; i++)
 	{
-		if (strcmp(argv[i], "-c") == 0)
+		int ret = _starpu_generate_paje_trace_read_option(argv[i], &options);
+		if (ret == 0)
 		{
-			options.per_task_colour = 1;
 			reading_input_filenames = 0;
-			continue;
 		}
-
-		if (strcmp(argv[i], "-o") == 0)
+		else if (strcmp(argv[i], "-o") == 0)
 		{
 			free(options.out_paje_path);
 			options.out_paje_path = strdup(argv[++i]);
 			reading_input_filenames = 0;
-			continue;
 		}
-
-		if (strcmp(argv[i], "-d") == 0)
+		else if (strcmp(argv[i], "-d") == 0)
 		{
 			options.dir = argv[++i];
 			reading_input_filenames = 0;
-			continue;
 		}
-
-		if (strcmp(argv[i], "-i") == 0)
+		else if (strcmp(argv[i], "-i") == 0)
 		{
 			if (options.ninputfiles >= STARPU_FXT_MAX_FILES)
 			{
@@ -96,87 +91,13 @@ static int parse_args(int argc, char **argv)
 			}
 			options.filenames[options.ninputfiles++] = argv[++i];
 			reading_input_filenames = 1;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-no-events") == 0)
-		{
-			options.no_events = 1;
-			reading_input_filenames = 0;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-number-events") == 0)
-		{
-			options.number_events_path = strdup("number_events.data");
-			reading_input_filenames = 0;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-no-counter") == 0)
-		{
-			options.no_counter = 1;
-			reading_input_filenames = 0;
-			continue;
 		}
-
-		if (strcmp(argv[i], "-no-bus") == 0)
-		{
-			options.no_bus = 1;
-			reading_input_filenames = 0;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-no-flops") == 0)
-		{
-			options.no_flops = 1;
-			reading_input_filenames = 0;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-no-smooth") == 0)
-		{
-			options.no_smooth = 1;
-			reading_input_filenames = 0;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-no-acquire") == 0)
-		{
-			options.no_acquire = 1;
-			reading_input_filenames = 0;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-memory-states") == 0)
-		{
-			options.memory_states = 1;
-			reading_input_filenames = 0;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-internal") == 0)
-		{
-			options.internal = 1;
-			reading_input_filenames = 0;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-label-deps") == 0)
-		{
-			options.label_deps = 1;
-			reading_input_filenames = 0;
-			continue;
-		}
-
-		if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
+		else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
 		{
 			usage();
 			return 77;
 		}
-
-		if (strcmp(argv[i], "-v") == 0
-		 || strcmp(argv[i], "--version") == 0)
+		else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
 		{
 		        fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
 			return 77;