Browse Source

mpi/examples/cholesky: add a command-line parameter -display to display input and output matrices

Nathalie Furmento 14 years ago
parent
commit
3a698d7c20
2 changed files with 53 additions and 49 deletions
  1. 46 47
      mpi/examples/cholesky/mpi_cholesky.c
  2. 7 2
      mpi/examples/cholesky/mpi_cholesky.h

+ 46 - 47
mpi/examples/cholesky/mpi_cholesky.c

@@ -192,24 +192,23 @@ int main(int argc, char **argv)
 	}
 
 
-        //#define PRINT_OUTPUT
-#ifdef PRINT_OUTPUT
-	printf("[%d] Input :\n", rank);
-
-	for (j = 0; j < size; j++)
-	{
-		for (i = 0; i < size; i++)
-		{
-			if (i <= j) {
-				printf("%2.2f\t", mat[j +i*size]);
-			}
-			else {
-				printf(".\t");
-			}
-		}
-		printf("\n");
-	}
-#endif
+        if (display) {
+                printf("[%d] Input :\n", rank);
+
+                for (j = 0; j < size; j++)
+                {
+                        for (i = 0; i < size; i++)
+                        {
+                                if (i <= j) {
+                                        printf("%2.2f\t", mat[j +i*size]);
+                                }
+                                else {
+                                        printf(".\t");
+                                }
+                        }
+                        printf("\n");
+                }
+        }
 
 	dw_cholesky(mat, size, size, nblocks, rank, nodes);
 
@@ -217,23 +216,23 @@ int main(int argc, char **argv)
 	starpu_mpi_shutdown();
 	starpu_shutdown();
 
-#ifdef PRINT_OUTPUT
-	printf("[%d] Results :\n", rank);
+        if (display) {
+                printf("[%d] Results :\n", rank);
 
-	for (j = 0; j < size; j++)
-	{
-		for (i = 0; i < size; i++)
+                for (j = 0; j < size; j++)
 		{
-			if (i <= j) {
-				printf("%2.2f\t", mat[j +i*size]);
-			}
-			else {
-				printf(".\t");
-			}
-		}
-		printf("\n");
-	}
-#endif
+                        for (i = 0; i < size; i++)
+			{
+                                if (i <= j) {
+                                        printf("%2.2f\t", mat[j +i*size]);
+                                }
+                                else {
+                                        printf(".\t");
+                                }
+                        }
+                        printf("\n");
+                }
+        }
 
 	fprintf(stderr, "[%d] compute explicit LLt ...\n", rank);
 	for (j = 0; j < size; j++)
@@ -252,21 +251,21 @@ int main(int argc, char **argv)
 				mat, size, 0.0f, test_mat, size);
 
 	fprintf(stderr, "[%d] comparing results ...\n", rank);
-#ifdef PRINT_OUTPUT
-	for (j = 0; j < size; j++)
-	{
-		for (i = 0; i < size; i++)
+        if (display) {
+                for (j = 0; j < size; j++)
 		{
-			if (i <= j) {
-				printf("%2.2f\t", test_mat[j +i*size]);
-			}
-			else {
-				printf(".\t");
-			}
-		}
-		printf("\n");
-	}
-#endif
+                        for (i = 0; i < size; i++)
+			{
+                                if (i <= j) {
+                                        printf("%2.2f\t", test_mat[j +i*size]);
+                                }
+                                else {
+                                        printf(".\t");
+                                }
+                        }
+                        printf("\n");
+                }
+        }
 
         int x, y;
         for(x = 0; x < nblocks ;  x++)

+ 7 - 2
mpi/examples/cholesky/mpi_cholesky.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -72,6 +72,7 @@ static unsigned nblocks = 16;
 static unsigned nbigblocks = 8;
 static unsigned pinned = 0;
 static unsigned noprio = 0;
+static unsigned display = 0;
 
 void chol_cpu_codelet_update_u11(void **, void *);
 void chol_cpu_codelet_update_u21(void **, void *);
@@ -117,8 +118,12 @@ static void __attribute__((unused)) parse_args(int argc, char **argv)
 			noprio = 1;
 		}
 
+		if (strcmp(argv[i], "-display") == 0) {
+			display = 1;
+		}
+
 		if (strcmp(argv[i], "-h") == 0) {
-			printf("usage : %s [-pin] [-size size] [-nblocks nblocks]\n", argv[0]);
+			printf("usage : %s [-display] [-pin] [-size size] [-nblocks nblocks]\n", argv[0]);
 		}
 	}
 	if (nblocks > size) nblocks = size;