瀏覽代碼

The starpu_machine_display program displays the different workers found by
StarPU (this is typically intended to easily detect whether StarPU managed to
find the GPU devices or not).

Cédric Augonnet 14 年之前
父節點
當前提交
eaad7087df
共有 2 個文件被更改,包括 62 次插入0 次删除
  1. 4 0
      tools/Makefile.am
  2. 58 0
      tools/starpu_machine_display.c

+ 4 - 0
tools/Makefile.am

@@ -44,6 +44,10 @@ endif
 bin_PROGRAMS +=	starpu_perfmodel_display
 starpu_perfmodel_display_SOURCES = starpu_perfmodel_display.c
 
+bin_PROGRAMS += starpu_machine_display
+
+starpu_machine_display_SOURCES = starpu_machine_display.c
+
 noinst_PROGRAMS =	cbc2paje lp2paje
 
 noinst_HEADERS = \

+ 58 - 0
tools/starpu_machine_display.c

@@ -0,0 +1,58 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2011  Université de Bordeaux 1
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#include <stdio.h>
+#include <starpu.h>
+
+static void display_worker_names(enum starpu_archtype type)
+{
+	unsigned nworkers = starpu_worker_get_count();
+
+	unsigned i;
+	for (i = 0; i < nworkers; i++)
+	{
+		if (starpu_worker_get_type(i) == type)
+		{
+			char name[256];
+			starpu_worker_get_name(i, name, 256);
+			fprintf(stdout, "\t\t%s\n", name);
+		}
+	}
+}
+
+int main(int argc, char **argv)
+{
+	starpu_init(NULL);
+
+	unsigned ncpu = starpu_cpu_worker_get_count();
+	unsigned ncuda = starpu_cuda_worker_get_count();
+	unsigned nopencl = starpu_opencl_worker_get_count();
+
+	fprintf(stdout, "StarPU has found :\n");
+
+	fprintf(stdout, "\t%d CPU cores\n", ncpu);
+	display_worker_names(STARPU_CPU_WORKER);
+
+	fprintf(stdout, "\t%d CUDA devices\n", ncuda);
+	display_worker_names(STARPU_CUDA_WORKER);
+
+	fprintf(stdout, "\t%d OpenCL devices\n", nopencl);
+	display_worker_names(STARPU_OPENCL_WORKER);
+
+	starpu_shutdown();
+
+	return 0;
+}