瀏覽代碼

mpi/examples/matrix_decomposition: fix correctness check

Nathalie Furmento 5 年之前
父節點
當前提交
6b5aceb1db

+ 2 - 2
mpi/examples/matrix_decomposition/mpi_cholesky.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2013,2015-2017                      CNRS
+ * Copyright (C) 2010-2013,2015-2017,2020                 CNRS
  * Copyright (C) 2009-2012,2014,2015,2018                 Université de Bordeaux
  * Copyright (C) 2012                                     Inria
  * Copyright (C) 2010                                     Mehdi Juhoor
@@ -63,7 +63,7 @@ int main(int argc, char **argv)
 #ifndef STARPU_SIMGRID
 	matrix_display(bmat, rank);
 
-	dw_cholesky_check_computation(bmat, rank, nodes, &correctness, &flops);
+	dw_cholesky_check_computation(bmat, rank, nodes, &correctness, &flops, 1.0);
 #endif
 
 	matrix_free(&bmat, rank, nodes, 1);

+ 3 - 3
mpi/examples/matrix_decomposition/mpi_cholesky_codelets.c

@@ -184,7 +184,7 @@ void dw_cholesky(float ***matA, unsigned ld, int rank, int nodes, double *timing
 	}
 }
 
-void dw_cholesky_check_computation(float ***matA, int rank, int nodes, int *correctness, double *flops)
+void dw_cholesky_check_computation(float ***matA, int rank, int nodes, int *correctness, double *flops, double epsilon)
 {
 	unsigned i,j,x,y;
 	float *rmat = malloc(size*size*sizeof(float));
@@ -256,9 +256,9 @@ void dw_cholesky_check_computation(float ***matA, int rank, int nodes, int *corr
 						{
 							float orig = (1.0f/(1.0f+i+j)) + ((i == j)?1.0f*size:0.0f);
 							float err = fabsf(test_mat[j +i*size] - orig);
-							if (err > 0.00001)
+							if (err > epsilon)
 							{
-								FPRINTF(stderr, "[%d] Error[%u, %u] --> %2.2f != %2.2f (err %2.2f)\n", rank, i, j, test_mat[j +i*size], orig, err);
+								FPRINTF(stderr, "[%d] Error[%u, %u] --> %2.20f != %2.20f (err %2.20f)\n", rank, i, j, test_mat[j +i*size], orig, err);
 								*correctness = 0;
 								*flops = 0;
 								break;

+ 2 - 2
mpi/examples/matrix_decomposition/mpi_cholesky_codelets.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2013,2015,2017                      CNRS
+ * Copyright (C) 2010-2013,2015,2017,2020                 CNRS
  * Copyright (C) 2009,2010,2014                           Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -25,6 +25,6 @@
  */
 void dw_cholesky(float ***matA, unsigned ld, int rank, int nodes, double *timing, double *flops);
 
-void dw_cholesky_check_computation(float ***matA, int rank, int nodes, int *correctness, double *flops);
+void dw_cholesky_check_computation(float ***matA, int rank, int nodes, int *correctness, double *flops, double epsilon);
 
 #endif /* __MPI_CHOLESKY_CODELETS_H__ */

+ 16 - 1
mpi/examples/matrix_decomposition/mpi_cholesky_distributed.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2013,2015,2017                      CNRS
+ * Copyright (C) 2010-2013,2015,2017,2020                 CNRS
  * Copyright (C) 2009-2011,2014,2015,2017,2018            Université de Bordeaux
  * Copyright (C) 2012                                     Inria
  * Copyright (C) 2010                                     Mehdi Juhoor
@@ -33,6 +33,9 @@ int main(int argc, char **argv)
 	float ***bmat;
 	int rank, nodes, ret;
 	double timing, flops;
+#ifndef STARPU_SIMGRID
+	int correctness=1;
+#endif
 
 	ret = starpu_mpi_init_conf(&argc, &argv, 1, MPI_COMM_WORLD, NULL);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_conf");
@@ -49,8 +52,20 @@ int main(int argc, char **argv)
 	starpu_cublas_shutdown();
 	starpu_mpi_shutdown();
 
+#ifndef STARPU_SIMGRID
+	if (rank == 0)
+	{
+		matrix_display(bmat, rank);
+
+		dw_cholesky_check_computation(bmat, rank, nodes, &correctness, &flops, 1e-3);
+	}
+#endif
 	matrix_free(&bmat, rank, nodes, 0);
 
+#ifndef STARPU_SIMGRID
+	assert(correctness);
+#endif
+
 	if (rank == 0)
 	{
 		FPRINTF(stdout, "Computation time (in ms): %2.2f\n", timing/1000);