Browse Source

Add bound support to gemm

Samuel Thibault 11 years ago
parent
commit
8ede268af6
1 changed files with 27 additions and 5 deletions
  1. 27 5
      examples/mult/xgemm.c

+ 27 - 5
examples/mult/xgemm.c

@@ -46,11 +46,13 @@ static unsigned ydim = 1024;
 static unsigned zdim = 1024;
 static unsigned zdim = 1024;
 #endif
 #endif
 static unsigned check = 0;
 static unsigned check = 0;
+static unsigned bound = 0;
 
 
 static TYPE *A, *B, *C;
 static TYPE *A, *B, *C;
 static starpu_data_handle_t A_handle, B_handle, C_handle;
 static starpu_data_handle_t A_handle, B_handle, C_handle;
 
 
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
+#define PRINTF(fmt, ...) do { if (!getenv("STARPU_SSILENT")) {printf(fmt, ## __VA_ARGS__); }} while(0)
 
 
 static void check_output(void)
 static void check_output(void)
 {
 {
@@ -262,6 +264,11 @@ static void parse_args(int argc, char **argv)
 			niter = strtol(argv[++i], &argptr, 10);
 			niter = strtol(argv[++i], &argptr, 10);
 		}
 		}
 
 
+		else if (strcmp(argv[i], "-bound") == 0)
+		{
+			bound = 1;
+		}
+
 		else if (strcmp(argv[i], "-check") == 0)
 		else if (strcmp(argv[i], "-check") == 0)
 		{
 		{
 			check = 1;
 			check = 1;
@@ -274,7 +281,7 @@ static void parse_args(int argc, char **argv)
 
 
 		else if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
 		else if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
 		{
 		{
-			fprintf(stderr,"Usage: %s [-nblocks n] [-nblocksx x] [-nblocksy y] [-x x] [-y y] [-z z] [-iter iter] [-check] [-spmd]\n", argv[0]);
+			fprintf(stderr,"Usage: %s [-nblocks n] [-nblocksx x] [-nblocksy y] [-x x] [-y y] [-z z] [-iter iter] [-bound] [-check] [-spmd]\n", argv[0]);
 			fprintf(stderr,"Currently selected: %ux%u * %ux%u and %ux%u blocks, %u iterations\n", zdim, ydim, xdim, zdim, nslicesx, nslicesy, niter);
 			fprintf(stderr,"Currently selected: %ux%u * %ux%u and %ux%u blocks, %u iterations\n", zdim, ydim, xdim, zdim, nslicesx, nslicesy, niter);
 			exit(EXIT_SUCCESS);
 			exit(EXIT_SUCCESS);
 		}
 		}
@@ -307,6 +314,9 @@ int main(int argc, char **argv)
 	init_problem_data();
 	init_problem_data();
 	partition_mult_data();
 	partition_mult_data();
 
 
+	if (bound)
+		starpu_bound_start(0, 0);
+
 	start = starpu_timing_now();
 	start = starpu_timing_now();
 
 
 	unsigned x, y, iter;
 	unsigned x, y, iter;
@@ -340,13 +350,25 @@ int main(int argc, char **argv)
 
 
 	end = starpu_timing_now();
 	end = starpu_timing_now();
 
 
-	double timing = end - start;
-
-	FPRINTF(stderr, "Time: %2.2f ms\n", timing/1000.0);
+	if (bound)
+		starpu_bound_stop();
 
 
+	double timing = end - start;
+	double min;
 	double flops = 2.0*((unsigned long)niter)*((unsigned long)xdim)
 	double flops = 2.0*((unsigned long)niter)*((unsigned long)xdim)
 				*((unsigned long)ydim)*((unsigned long)zdim);
 				*((unsigned long)ydim)*((unsigned long)zdim);
-	FPRINTF(stderr, "GFlop/s: %.2f\n", flops/timing/1000.0);
+
+	if (bound)
+	starpu_bound_compute(&min, NULL, 0);
+
+	PRINTF("# x\ty\tz\tms\tGFlops");
+	if (bound)
+		PRINTF("\tTms\tTGFlops");
+	PRINTF("\n");
+	PRINTF("%u\t%u\t%u\t%.0f\t%.1f", xdim, ydim, zdim, timing/niter/1000.0, flops/timing/1000.0);
+	if (bound)
+		PRINTF("\t%.0f\t%.1f", min, flops/min/1000000.0);
+	PRINTF("\n");
 
 
 enodev:
 enodev:
 	starpu_data_unpartition(C_handle, STARPU_MAIN_RAM);
 	starpu_data_unpartition(C_handle, STARPU_MAIN_RAM);