Forráskód Böngészése

Show topology in starpu_machine_display

Samuel Thibault 13 éve
szülő
commit
844951370b
4 módosított fájl, 48 hozzáadás és 0 törlés
  1. 4 0
      doc/chapters/basic-api.texi
  2. 3 0
      include/starpu.h
  3. 38 0
      src/core/topology.c
  4. 3 0
      tools/starpu_machine_display.c

+ 4 - 0
doc/chapters/basic-api.texi

@@ -1986,6 +1986,10 @@ prints a matrix of bus bandwidths on @var{f}.
 prints the affinity devices on @var{f}.
 @end deftypefun
 
+@deftypefun void starpu_topology_print ({FILE *}@var{f})
+prints a description of the topology on @var{f}.
+@end deftypefun
+
 @deftypefun void starpu_perfmodel_update_history ({struct starpu_perfmodel *}@var{model}, {struct starpu_task *}@var{task}, {enum starpu_perf_archtype} @var{arch}, unsigned @var{cpuid}, unsigned @var{nimpl}, double @var{measured});
 This feeds the performance model @var{model} with an explicit measurement
 @var{measured}, in addition to measurements done by StarPU itself. This can be

+ 3 - 0
include/starpu.h

@@ -146,6 +146,9 @@ int starpu_init(struct starpu_conf *conf) STARPU_WARN_UNUSED_RESULT;
  * shutdown */
 void starpu_shutdown(void);
 
+/* Print topology configuration */
+void starpu_topology_print(FILE *output);
+
 /* This function returns the number of workers (ie. processing units executing
  * StarPU tasks). The returned value should be at most STARPU_NMAXWORKERS. */
 unsigned starpu_worker_get_count(void);

+ 38 - 0
src/core/topology.c

@@ -897,3 +897,41 @@ void _starpu_destroy_topology(struct _starpu_machine_config *config __attribute_
 	may_bind_automatically = 0;
 #endif
 }
+
+void starpu_topology_print(FILE *output)
+{
+	struct _starpu_machine_config *config = _starpu_get_machine_config();
+	struct starpu_machine_topology *topology = &config->topology;
+	unsigned core;
+	unsigned worker;
+	unsigned nworkers = starpu_worker_get_count();
+	unsigned ncombinedworkers = topology->ncombinedworkers;
+
+	for (core = 0; core < topology->nhwcpus; core++) {
+		fprintf(output, "core %d\t", core);
+		for (worker = 0; worker < nworkers + ncombinedworkers; worker++)
+		{
+			if (worker < nworkers)
+			{
+				if (topology->workers_bindid[worker] == core)
+				{
+					char name[256];
+					starpu_worker_get_name(worker, name, sizeof(name));
+					fprintf(output, "%s\t", name);
+				}
+			}
+			else
+			{
+				int worker_size, i;
+				int *combined_workerid;
+				starpu_combined_worker_get_description(worker, &worker_size, &combined_workerid);
+				for (i = 0; i < worker_size; i++)
+				{
+					if (topology->workers_bindid[combined_workerid[i]] == core)
+						fprintf(output, "comb %d\t", worker-nworkers);
+				}
+			}
+		}
+		fprintf(output, "\n");
+	}
+}

+ 3 - 0
tools/starpu_machine_display.c

@@ -151,6 +151,9 @@ int main(int argc, char **argv)
 	fprintf(stdout, "\nbandwidth ...\n");
 	starpu_bus_print_bandwidth(stdout);
 
+	fprintf(stdout, "\ntopology ...\n");
+	starpu_topology_print(stdout);
+
 	starpu_shutdown();
 
 	return 0;