浏览代码

tools/starpu_perfmodel_plot.c: test given CUDA device id is valid

Nathalie Furmento 12 年之前
父节点
当前提交
6b24262000
共有 1 个文件被更改,包括 14 次插入7 次删除
  1. 14 7
      tools/starpu_perfmodel_plot.c

+ 14 - 7
tools/starpu_perfmodel_plot.c

@@ -68,7 +68,7 @@ given perfmodel\n");
         fprintf(stderr, "   -l                  display all available models\n");
         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)\n");
+        fprintf(stderr, "   -a <arch>           specify the architecture (e.g. cpu, cpu:x, cuda, cuda_d)\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);
@@ -309,8 +309,7 @@ static void display_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *mod
 	{
 		for (implid = 0; implid < STARPU_MAXIMPLEMENTATIONS; implid++)
 		{
-			display_perf_model(gnuplot_file, model, (enum starpu_perf_archtype) arch, first,
-implid);
+			display_perf_model(gnuplot_file, model, (enum starpu_perf_archtype) arch, first, implid);
 		}
 	}
 	display_history_based_perf_models(gnuplot_file, model, arch1, arch2, first);
@@ -375,8 +374,8 @@ static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel
 			for (impl = 0; impl < STARPU_MAXIMPLEMENTATIONS; impl++)
 			{
 				display_perf_model(gnuplot_file, model,
-							STARPU_CPU_DEFAULT,
-							&first, impl);
+						   STARPU_CPU_DEFAULT,
+						   &first, impl);
 			}
 			return;
 		}
@@ -408,8 +407,16 @@ static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel
 		if (nmatched == 1)
 		{
 			int archid = STARPU_CUDA_DEFAULT+ gpuid;
-			display_perf_models(gnuplot_file, model, (enum starpu_perf_archtype) archid, (enum starpu_perf_archtype) (archid + 1), &first);
-			return;
+			if (archid < STARPU_OPENCL_DEFAULT)
+			{
+				display_perf_models(gnuplot_file, model, (enum starpu_perf_archtype) archid, (enum starpu_perf_archtype) (archid + 1), &first);
+				return;
+			}
+			else
+			{
+				fprintf(stderr, "Invalid CUDA device %d (last valid one is %d)\n", gpuid, STARPU_MAXCUDADEVS-1);
+				exit(-1);
+			}
 		}
 
 		fprintf(stderr, "Unknown architecture requested, aborting.\n");