Quellcode durchsuchen

New function starpu_worker_display_names to display the names of all the workers of a specified type.

Nathalie Furmento vor 8 Jahren
Ursprung
Commit
422cad39ec

+ 2 - 0
ChangeLog

@@ -35,6 +35,8 @@ Small features:
   * New configure option --enable-mpi-pedantic-isend (disabled by
   * New configure option --enable-mpi-pedantic-isend (disabled by
     default) to acquire data in STARPU_RW (instead of STARPU_R) before
     default) to acquire data in STARPU_RW (instead of STARPU_R) before
     performing MPI_Isend call
     performing MPI_Isend call
+  * New function starpu_worker_display_names to display the names of
+    all the workers of a specified type.
 
 
 Changes:
 Changes:
   * Vastly improve simgrid simulation time.
   * Vastly improve simgrid simulation time.

+ 5 - 0
doc/doxygen/chapters/api/workers.doxy

@@ -233,6 +233,11 @@ ensuring that \p dst is a valid pointer to a buffer of \p maxlen bytes
 at least. Calling this function on an invalid identifier results in an
 at least. Calling this function on an invalid identifier results in an
 unspecified behaviour.
 unspecified behaviour.
 
 
+\fn void starpu_worker_display_names(FILE *output, enum starpu_worker_archtype type)
+\ingroup API_Workers_Properties
+Display on \output the list (if any) of all the workers of the given
+\p type.
+
 \fn unsigned starpu_worker_get_memory_node(unsigned workerid)
 \fn unsigned starpu_worker_get_memory_node(unsigned workerid)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Return the identifier of the memory node associated to the worker
 Return the identifier of the memory node associated to the worker

+ 1 - 0
examples/Makefile.am

@@ -207,6 +207,7 @@ STARPU_EXAMPLES +=				\
 if !STARPU_SIMGRID
 if !STARPU_SIMGRID
 STARPU_EXAMPLES +=				\
 STARPU_EXAMPLES +=				\
 	basic_examples/hello_world		\
 	basic_examples/hello_world		\
+	basic_examples/topology			\
 	basic_examples/vector_scal		\
 	basic_examples/vector_scal		\
 	basic_examples/mult			\
 	basic_examples/mult			\
 	basic_examples/block			\
 	basic_examples/block			\

+ 34 - 0
examples/basic_examples/topology.c

@@ -0,0 +1,34 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2017  CNRS
+ *
+ * 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 <stdint.h>
+#include <starpu.h>
+
+#define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
+
+int main(int argc, char **argv)
+{
+	int ret = starpu_init(NULL);
+	if (ret == -ENODEV) return 77;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
+	starpu_worker_display_names(stdout, STARPU_CPU_WORKER);
+	starpu_topology_print(stdout);
+
+	starpu_shutdown();
+	return 0;
+}

+ 3 - 1
include/starpu_worker.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2009-2013, 2016  Université de Bordeaux
  * Copyright (C) 2009-2013, 2016  Université de Bordeaux
- * Copyright (C) 2010-2014  CNRS
+ * Copyright (C) 2010-2014, 2017  CNRS
  * Copyright (C) 2016, 2017  INRIA
  * Copyright (C) 2016, 2017  INRIA
  * Copyright (C) 2016  Uppsala University
  * Copyright (C) 2016  Uppsala University
  *
  *
@@ -117,6 +117,8 @@ int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid);
 
 
 void starpu_worker_get_name(int id, char *dst, size_t maxlen);
 void starpu_worker_get_name(int id, char *dst, size_t maxlen);
 
 
+void starpu_worker_display_names(FILE *output, enum starpu_worker_archtype type);
+
 int starpu_worker_get_devid(int id);
 int starpu_worker_get_devid(int id);
 
 
 int starpu_worker_get_mp_nodeid(int id);
 int starpu_worker_get_mp_nodeid(int id);

+ 20 - 1
src/core/workers.c

@@ -2389,4 +2389,23 @@ unsigned starpu_worker_get_sched_ctx_id_stream(unsigned stream_workerid)
 	return w->stream_ctx != NULL ? w->stream_ctx->id : STARPU_NMAX_SCHED_CTXS;
 	return w->stream_ctx != NULL ? w->stream_ctx->id : STARPU_NMAX_SCHED_CTXS;
 }
 }
 
 
-
+void starpu_worker_display_names(FILE *output, enum starpu_worker_archtype type)
+{
+	int nworkers = starpu_worker_get_count_by_type(type);
+	if (nworkers <= 0)
+	{
+		fprintf(output, "No %s worker\n", starpu_worker_get_type_as_string(type));
+	}
+	else
+	{
+		int i, ids[nworkers];
+		starpu_worker_get_ids_by_type(type, ids, nworkers);
+		fprintf(output, "%d %s worker%s:\n", nworkers, starpu_worker_get_type_as_string(type), nworkers==1?"":"s");
+		for(i = 0; i < nworkers; i++)
+		{
+			char name[256];
+			starpu_worker_get_name(ids[i], name, 256);
+			fprintf(output, "\t%s\n", name);
+		}
+	}
+}

+ 6 - 53
tools/starpu_machine_display.c

@@ -37,25 +37,6 @@ static void usage()
 	fprintf(stderr, "Report bugs to <" PACKAGE_BUGREPORT ">.\n");
 	fprintf(stderr, "Report bugs to <" PACKAGE_BUGREPORT ">.\n");
 }
 }
 
 
-static void display_worker_names(enum starpu_worker_archtype type)
-{
-	int nworkers = starpu_worker_get_count_by_type(type);
-	if (!nworkers)
-		return;
-	STARPU_ASSERT(nworkers>0);
-
-	int ids[nworkers];
-	starpu_worker_get_ids_by_type(type, ids, nworkers);
-
-	int i;
-	for (i = 0; i < nworkers; i++)
-	{
-		char name[256];
-		starpu_worker_get_name(ids[i], name, 256);
-		fprintf(stdout, "\t\t%s\n", name);
-	}
-}
-
 static void display_combined_worker(unsigned workerid)
 static void display_combined_worker(unsigned workerid)
 {
 {
 	int worker_size;
 	int worker_size;
@@ -157,47 +138,19 @@ int main(int argc, char **argv)
 		return 0;
 		return 0;
 	}
 	}
 
 
-	unsigned ncpu = starpu_cpu_worker_get_count();
-	unsigned ncuda = starpu_cuda_worker_get_count();
-	unsigned nopencl = starpu_opencl_worker_get_count();
-
-#ifdef STARPU_USE_MIC
-	unsigned nmicdevs = starpu_mic_device_get_count();
-	unsigned nmiccores = starpu_mic_worker_get_count();
-#endif
-
-#ifdef STARPU_USE_SCC
-	unsigned scc = starpu_scc_worker_get_count();
-#endif
-
-#ifdef STARPU_USE_MPI_MASTER_SLAVE
-	unsigned mpi_ms = starpu_mpi_ms_worker_get_count();
-#endif
-
 	fprintf(stdout, "StarPU has found :\n");
 	fprintf(stdout, "StarPU has found :\n");
 
 
-	fprintf(stdout, "\t%u CPU threads\n", ncpu);
-	display_worker_names(STARPU_CPU_WORKER);
-
-	fprintf(stdout, "\t%u CUDA devices\n", ncuda);
-	display_worker_names(STARPU_CUDA_WORKER);
-
-	fprintf(stdout, "\t%u OpenCL devices\n", nopencl);
-	display_worker_names(STARPU_OPENCL_WORKER);
-
+	starpu_worker_display_names(stdout, STARPU_CPU_WORKER);
+	starpu_worker_display_names(stdout, STARPU_CUDA_WORKER);
+	starpu_worker_display_names(stdout, STARPU_OPENCL_WORKER);
 #ifdef STARPU_USE_MIC
 #ifdef STARPU_USE_MIC
-	fprintf(stdout, "\t%u MIC cores (from %u devices)\n", nmiccores, nmicdevs);
-	display_worker_names(STARPU_MIC_WORKER);
+	starpu_worker_display_names(stdout, STARPU_MIC_WORKER);
 #endif
 #endif
-
 #ifdef STARPU_USE_SCC
 #ifdef STARPU_USE_SCC
-	fprintf(stdout, "\t%u SCC cores\n", scc);
-	display_worker_names(STARPU_SCC_WORKER);
+	starpu_worker_display_names(stdout, STARPU_SCC_WORKER);
 #endif
 #endif
-
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
 #ifdef STARPU_USE_MPI_MASTER_SLAVE
-	fprintf(stdout, "\t%u MPI Master workers\n", mpi_ms);
-	display_worker_names(STARPU_MPI_MS_WORKER);
+	starpu_worker_display_names(stdout, STARPU_MPI_MS_WORKER);
 #endif
 #endif
 
 
 	display_all_combined_workers();
 	display_all_combined_workers();