ソースを参照

Add a --help and --version option to starpu_perfmodel_plot.

Cyril Roelandt 13 年 前
コミット
585b1421c1
共有1 個のファイルを変更した21 個の追加4 個の削除を含む
  1. 21 4
      tools/starpu_perfmodel_plot.c

+ 21 - 4
tools/starpu_perfmodel_plot.c

@@ -16,6 +16,7 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
+#include <config.h>
 #include <assert.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -31,6 +32,8 @@
 #include <windows.h>
 #endif
 
+#define PROGNAME "starpu_perfmodel_plot"
+
 static struct starpu_perfmodel model;
 
 /* display all available models */
@@ -58,7 +61,9 @@ static char gnuplot_file_name[256];
 
 static void usage(char **argv)
 {
-	fprintf(stderr, "Usage: %s [ options ]\n", argv[0]);
+	fprintf(stderr, "Draw a graph corresponding to the execution time of a \
+given perfmodel\n");
+	fprintf(stderr, "Usage: %s [ options ]\n", PROGNAME);
         fprintf(stderr, "\n");
 	fprintf(stderr, "One must specify a symbol with the -s option or use -l\n");
         fprintf(stderr, "Options:\n");
@@ -66,7 +71,9 @@ static void usage(char **argv)
         fprintf(stderr, "   -s <symbol>         specify the symbol\n");
 	fprintf(stderr, "   -i <Fxt files>      input FxT files generated by StarPU\n");
         fprintf(stderr, "   -a <arch>           specify the architecture (e.g. cpu, cpu:k, cuda_k, gordon)\n");
-        fprintf(stderr, "\n");
+	fprintf(stderr, "   -h, --help          display this help and exit\n");
+	fprintf(stderr, "   -v, --version       output version information and exit\n\n");
+        fprintf(stderr, "Report bugs to <%s>.", PACKAGE_BUGREPORT);
 }
 
 static void parse_args(int argc, char **argv)
@@ -114,9 +121,19 @@ static void parse_args(int argc, char **argv)
 			continue;
 		}
 
-		if (strcmp(argv[i], "-h") == 0) {
+		if (strcmp(argv[i], "-h") == 0 ||
+		    strcmp(argv[i], "--help") == 0) {
 			usage(argv);
-		        exit(-1);
+			exit(EXIT_SUCCESS);
+		}
+
+		if (strcmp(argv[i], "-v") == 0 ||
+		    strcmp(argv[i], "--version") == 0) {
+
+			(void) fprintf(stdout, "%s %d.%d\n",
+					PROGNAME, STARPU_MAJOR_VERSION,
+					STARPU_MINOR_VERSION);
+			exit(EXIT_SUCCESS);
 		}
 
 		/* If the reading_input_filenames flag is set, and that the