Преглед изворни кода

perfmodel: new function starpu_bus_print_filenames() to display filenames storing bandwidth/affinity/latency information, available through starpu_machine_display -i

Nathalie Furmento пре 8 година
родитељ
комит
07c6821f4f

+ 4 - 0
doc/doxygen/chapters/api/performance_model.doxy

@@ -254,6 +254,10 @@ prints a matrix of bus bandwidths on \p f.
 \ingroup API_Performance_Model
 prints the affinity devices on \p f.
 
+\fn void starpu_bus_print_filenames(FILE *f)
+\ingroup API_Performance_Model
+prints on \p f the name of the files containing the matrix of bus bandwidths, the affinity devices and the latency.
+
 \fn void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
 \ingroup API_Performance_Model
 This feeds the performance model model with an explicit

+ 1 - 0
include/starpu_perfmodel.h

@@ -176,6 +176,7 @@ void starpu_perfmodel_directory(FILE *output);
 
 void starpu_bus_print_bandwidth(FILE *f);
 void starpu_bus_print_affinity(FILE *f);
+void starpu_bus_print_filenames(FILE *f);
 
 double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
 double starpu_transfer_latency(unsigned src_node, unsigned dst_node);

+ 17 - 1
src/core/perfmodel/perfmodel_bus.c

@@ -776,12 +776,13 @@ static void get_bus_path(const char *type, char *path, size_t maxlen)
  *	Affinity
  */
 
-#ifndef STARPU_SIMGRID
 static void get_affinity_path(char *path, size_t maxlen)
 {
 	get_bus_path("affinity", path, maxlen);
 }
 
+#ifndef STARPU_SIMGRID
+
 static void load_bus_affinity_file_content(void)
 {
 #if defined(STARPU_USE_CUDA) || defined(STARPU_USE_OPENCL)
@@ -1419,6 +1420,21 @@ static void write_bus_bandwidth_file_content(void)
 }
 #endif /* STARPU_SIMGRID */
 
+void starpu_bus_print_filenames(FILE *output)
+{
+	char bandwidth_path[256];
+	char affinity_path[256];
+	char latency_path[256];
+
+	get_bandwidth_path(bandwidth_path, sizeof(bandwidth_path));
+	get_affinity_path(affinity_path, sizeof(affinity_path));
+	get_latency_path(latency_path, sizeof(latency_path));
+
+	fprintf(output, "bandwidth: <%s>\n", bandwidth_path);
+	fprintf(output, " affinity: <%s>\n", affinity_path);
+	fprintf(output, "  latency: <%s>\n", latency_path);
+}
+
 void starpu_bus_print_bandwidth(FILE *f)
 {
 	unsigned src, dst, maxnode;

+ 33 - 16
tools/starpu_machine_display.c

@@ -21,6 +21,22 @@
 
 #define PROGNAME "starpu_machine_display"
 
+static void usage()
+{
+	fprintf(stderr, "Show the processing units that StarPU can use,\n");
+	fprintf(stderr, "and the bandwitdh and affinity measured between the memory nodes.\n");
+	fprintf(stderr, "\n");
+	fprintf(stderr, "Usage: %s [OPTION]\n", PROGNAME);
+	fprintf(stderr, "\n");
+	fprintf(stderr, "Options:\n");
+	fprintf(stderr, "\t-h, --help       display this help and exit\n");
+	fprintf(stderr, "\t-v, --version    output version information and exit\n");
+	fprintf(stderr, "\t-i, --info       display the name of the files containing the information\n");
+	fprintf(stderr, "\t-f, --force      force bus sampling and show measures \n");
+	fprintf(stderr, "\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);
@@ -77,7 +93,7 @@ static void display_all_combined_workers(void)
 		display_combined_worker(nworkers + i);
 }
 
-static void parse_args(int argc, char **argv, int *force)
+static void parse_args(int argc, char **argv, int *force, int *info)
 {
 	int i;
 
@@ -90,21 +106,13 @@ static void parse_args(int argc, char **argv, int *force)
 		{
 			*force = 1;
 		}
+		else if (strncmp(argv[i], "--info", 6) == 0 || strncmp(argv[i], "-i", 2) == 0)
+		{
+			*info = 1;
+		}
 		else if (strncmp(argv[i], "--help", 6) == 0 || strncmp(argv[i], "-h", 2) == 0)
 		{
-			(void) fprintf(stderr, "\
-Show the processing units that StarPU can use, and the	      \n	\
-bandwitdh and affinity measured between the memory nodes.     \n	\
-                                                              \n	\
-Usage: %s [OPTION]                                            \n	\
-                                                              \n	\
-Options:                                                      \n	\
-	-h, --help       display this help and exit           \n	\
-	-v, --version    output version information and exit  \n	\
-	-f, --force      force bus sampling and show measures \n	\
-                                                              \n	\
-Report bugs to <" PACKAGE_BUGREPORT ">.\n",
-PROGNAME);
+			usage();
 			exit(EXIT_FAILURE);
 		}
 		else if (strncmp(argv[i], "--version", 9) == 0 || strncmp(argv[i], "-v", 2) == 0)
@@ -115,6 +123,7 @@ PROGNAME);
 		else
 		{
 			fprintf(stderr, "Unknown arg %s\n", argv[1]);
+			usage();
 			exit(EXIT_FAILURE);
 		}
 	}
@@ -124,9 +133,10 @@ int main(int argc, char **argv)
 {
 	int ret;
 	int force = 0;
+	int info = 0;
 	struct starpu_conf conf;
 
-	parse_args(argc, argv, &force);
+	parse_args(argc, argv, &force, &info);
 
 	starpu_conf_init(&conf);
 	if (force)
@@ -140,6 +150,13 @@ int main(int argc, char **argv)
 		return ret;
 	}
 
+	if (info)
+	{
+		starpu_busçtopology_directory(stdout);
+		starpu_shutdown();
+		return 0;
+	}
+
 	unsigned ncpu = starpu_cpu_worker_get_count();
 	unsigned ncuda = starpu_cuda_worker_get_count();
 	unsigned nopencl = starpu_opencl_worker_get_count();
@@ -175,8 +192,8 @@ int main(int argc, char **argv)
 		fprintf(stdout, "\nbandwidth and latency ...\n");
 		starpu_bus_print_bandwidth(stdout);
 
-		starpu_shutdown();
 	}
 
+	starpu_shutdown();
 	return 0;
 }