Browse Source

perfmodel: new public function starpu_bus_print_affinity() to print the affinity devices

Nathalie Furmento 13 years ago
parent
commit
e478d30094
3 changed files with 41 additions and 0 deletions
  1. 4 0
      doc/chapters/basic-api.texi
  2. 1 0
      include/starpu_perfmodel.h
  3. 36 0
      src/core/perfmodel/perfmodel_bus.c

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

@@ -1952,6 +1952,10 @@ prints a list of all performance models on @var{output}.
 prints a matrix of bus bandwidths on @var{f}.
 @end deftypefun
 
+@deftypefun void starpu_bus_print_affinity ({FILE *}@var{f})
+prints the affinity devices on @var{f}.
+@end deftypefun
+
 @node Profiling API
 @section Profiling API
 

+ 1 - 0
include/starpu_perfmodel.h

@@ -211,6 +211,7 @@ int starpu_list_models(FILE *output);
 
 void starpu_force_bus_sampling(void);
 void starpu_bus_print_bandwidth(FILE *f);
+void starpu_bus_print_affinity(FILE *f);
 
 #ifdef __cplusplus
 }

+ 36 - 0
src/core/perfmodel/perfmodel_bus.c

@@ -766,6 +766,42 @@ int *_starpu_get_opencl_affinity_vector(unsigned gpuid)
 }
 #endif /* STARPU_USE_OPENCL */
 
+void starpu_bus_print_affinity(FILE *f)
+{
+	unsigned cpu;
+	int gpu;
+
+	fprintf(f, "# GPU\t");
+	for(cpu = 0 ; cpu < ncpus ; cpu++)
+	{
+		fprintf(f, "CPU%d\t", cpu);
+	}
+	fprintf(f, "\n");
+
+#ifdef STARPU_USE_CUDA
+	for(gpu = 0 ; gpu<ncuda ; gpu++)
+	{
+		fprintf(f, "%d\t", gpu);
+		for (cpu = 0; cpu < ncpus; cpu++)
+		{
+			fprintf(f, "%d\t", cuda_affinity_matrix[gpu][cpu]);
+		}
+		fprintf(f, "\n");
+	}
+#endif
+#ifdef STARPU_USE_OPENCL
+	for(gpu = 0 ; gpu<nopencl ; gpu++)
+	{
+		fprintf(f, "%d\t", gpu);
+		for (cpu = 0; cpu < ncpus; cpu++)
+		{
+			fprintf(f, "%d\t", cuda_affinity_matrix[gpu][cpu]);
+		}
+		fprintf(f, "\n");
+	}
+#endif
+}
+
 /*
  *	Latency
  */