Prechádzať zdrojové kódy

tools/starpu_machine_display.c: new option --force to force bus sampling, and also display affinity matrix

Nathalie Furmento 13 rokov pred
rodič
commit
c39d1a57db
1 zmenil súbory, kde vykonal 48 pridanie a 29 odobranie
  1. 48 29
      tools/starpu_machine_display.c

+ 48 - 29
tools/starpu_machine_display.c

@@ -49,7 +49,7 @@ static void display_combined_worker(unsigned workerid)
 		char name[256];
 
 		starpu_worker_get_name(combined_workerid[i], name, 256);
-		
+
 		fprintf(stdout, "%s\t", name);
 	}
 
@@ -72,50 +72,65 @@ static void display_all_combined_workers(void)
 		display_combined_worker(nworkers + i);
 }
 
-static void parse_args(int argc, char **argv)
+static void parse_args(int argc, char **argv, int *force)
 {
+	int i;
+
 	if (argc == 1)
 		return;
 
-	if (argc > 2 || /* Argc should be either 1 or 2 */
-	    strncmp(argv[1], "--help", 6) == 0 ||
-	    strncmp(argv[1], "-h", 2) == 0)
+	for (i = 1; i < argc; i++)
 	{
-		(void) fprintf(stderr, "\
-Show the processing units that StarPU can use, and the \
-bandwitdh 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\
-                                                              \n\
-Report bugs to <" PACKAGE_BUGREPORT ">.",
+		if (strncmp(argv[i], "--force", 7) == 0 || strncmp(argv[i], "-f", 2) == 0)
+		{
+			*force = 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                   \n	\
+                                                              \n	\
+Report bugs to <" PACKAGE_BUGREPORT ">.\n",
 PROGNAME);
+			exit(EXIT_FAILURE);
+		}
+		else if (strncmp(argv[i], "--version", 9) == 0 || strncmp(argv[i], "-v", 2) == 0)
+		{
+			(void) fprintf(stderr, "%s %d.%d\n",
+				       PROGNAME, STARPU_MAJOR_VERSION, STARPU_MINOR_VERSION);
+			exit(EXIT_FAILURE);
+		}
+		else
+		{
+			fprintf(stderr, "Unknown arg %s\n", argv[1]);
+			exit(EXIT_FAILURE);
+		}
 	}
-	else if (strncmp(argv[1], "--version", 9) == 0 ||
-		 strncmp(argv[1], "-v", 2) == 0)
-	{
-		(void) fprintf(stderr, "%s %d.%d\n",
-			PROGNAME, STARPU_MAJOR_VERSION, STARPU_MINOR_VERSION);
-	}
-	else
-	{
-		fprintf(stderr, "Unknown arg %s\n", argv[1]);
-	}
-
-	exit(EXIT_FAILURE);
 }
 
 int main(int argc, char **argv)
 {
-	parse_args(argc, argv);
+	int force = 0;
+
+	parse_args(argc, argv, &force);
 
 	/* Even if starpu_init returns -ENODEV, we should go on : we will just
 	 * print that we found no device. */
 	(void) starpu_init(NULL);
 
+	if (force)
+	{
+		starpu_force_bus_sampling();
+	}
+
 	unsigned ncpu = starpu_cpu_worker_get_count();
 	unsigned ncuda = starpu_cuda_worker_get_count();
 	unsigned nopencl = starpu_opencl_worker_get_count();
@@ -133,8 +148,12 @@ int main(int argc, char **argv)
 
 	display_all_combined_workers();
 
+	fprintf(stdout, "\nbandwidth ...\n");
 	starpu_bus_print_bandwidth(stdout);
 
+	fprintf(stdout, "\naffinity ...\n");
+	starpu_bus_print_affinity(stdout);
+
 	starpu_shutdown();
 
 	return 0;