소스 검색

tools/starpu_fxt_data_trace.c: recognize options -h --help -v --version, and also display name of gnuplot file on success

Nathalie Furmento 11 년 전
부모
커밋
4f398beb95
1개의 변경된 파일43개의 추가작업 그리고 9개의 파일을 삭제
  1. 43 9
      tools/starpu_fxt_data_trace.c

+ 43 - 9
tools/starpu_fxt_data_trace.c

@@ -6,17 +6,53 @@
 #define PROGNAME "starpu_fxt_data_trace"
 #define MAX_LINE_SIZE 100
 
-static void usage(char *progname)
+static void usage()
 {
-	fprintf(stderr, "Usage : %s <filename> [codelet...]\n", progname);
-	exit(77);
+	fprintf(stderr, "Get statistics about tasks lengths and data size\n\n");
+	fprintf(stderr, "Usage: %s [ options ] <filename> [<codelet1> <codelet2> .... <codeletn>]\n", PROGNAME);
+        fprintf(stderr, "\n");
+        fprintf(stderr, "Options:\n");
+	fprintf(stderr, "   -h, --help          display this help and exit\n");
+	fprintf(stderr, "   -v, --version       output version information and exit\n\n");
+	fprintf(stderr, "    filename           specify the FxT trace input file.\n");
+	fprintf(stderr, "    codeletX           specify the codelet name to profile (by default, all codelets are profiled)\n");
+        fprintf(stderr, "Reports bugs to <"PACKAGE_BUGREPORT">.");
+        fprintf(stderr, "\n");
 }
 
-static void write_plt(int argc, char **argv){
+static void parse_args(int argc, char **argv)
+{
+	int i;
+
+	if(argc < 2)
+	{
+		fprintf(stderr, "Incorrect usage, aborting\n");
+                usage();
+		exit(77);
+	}
+
+	for (i = 1; i < argc; i++)
+	{
+		if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
+		{
+			usage();
+			exit(EXIT_SUCCESS);
+		}
+
+		if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
+		{
+		        fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
+			exit(EXIT_SUCCESS);
+		}
+	}
+}
+
+static void write_plt(int argc, char **argv)
+{
 	FILE *codelet_list = fopen("codelet_list", "r");
 	if(!codelet_list)
 	{
-		perror("Error while opening codelet list:");
+		perror("Error while opening codelet_list:");
 		exit(-1);
 	}
 	char codelet_name[MAX_LINE_SIZE];
@@ -73,6 +109,7 @@ static void write_plt(int argc, char **argv){
 	}
 	fprintf(plt, "\n");
 
+	fprintf(stdout, "Gnuplot file <data_trace.gp> has been successfully created.\n");
 	if(fclose(codelet_list))
 	{
 		perror("close failed :");
@@ -88,10 +125,7 @@ static void write_plt(int argc, char **argv){
 
 int main(int argc, char **argv)
 {
-	if(argc < 2)
-	{
-		usage(argv[0]);
-	}
+	parse_args(argc, argv);
 	starpu_fxt_write_data_trace(argv[1]);
 	write_plt(argc - 2, argv + 2);
 	return 0;