Ver código fonte

mpi/examples/complex/mpi_complex.c: make sure data is properly updated in memory

Nathalie Furmento 6 anos atrás
pai
commit
2573fe8b44
1 arquivos alterados com 24 adições e 1 exclusões
  1. 24 1
      mpi/examples/complex/mpi_complex.c

+ 24 - 1
mpi/examples/complex/mpi_complex.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2012,2013,2015-2017                      CNRS
+ * Copyright (C) 2012,2013,2015-2017,2019                      CNRS
  * Copyright (C) 2013-2015,2017,2018                      Université de Bordeaux
  * Copyright (C) 2013                                     Inria
  *
@@ -81,6 +81,7 @@ int main(int argc, char **argv)
 	starpu_complex_data_register(&handle, STARPU_MAIN_RAM, real, imaginary, 2);
 	starpu_complex_data_register(&handle2, -1, real2, imaginary2, 2);
 
+	// Ping-pong
 	if (rank == 0)
 	{
 		int *compare_ptr = &compare;
@@ -99,6 +100,28 @@ int main(int argc, char **argv)
 		starpu_mpi_isend_detached(handle, 0, 20, MPI_COMM_WORLD, NULL, NULL);
 	}
 
+	// Ping
+	if (rank == 0)
+	{
+		starpu_data_handle_t xhandle;
+		double xreal = 4.0;
+		double ximaginary = 8.0;
+		starpu_complex_data_register(&xhandle, STARPU_MAIN_RAM, &xreal, &ximaginary, 1);
+		starpu_mpi_send(xhandle, 1, 10, MPI_COMM_WORLD);
+		starpu_data_unregister(xhandle);
+	}
+	else if (rank == 1)
+	{
+		starpu_data_handle_t xhandle;
+		double xreal = 14.0;
+		double ximaginary = 18.0;
+		starpu_complex_data_register(&xhandle, STARPU_MAIN_RAM, &xreal, &ximaginary, 1);
+		starpu_mpi_recv(xhandle, 0, 10, MPI_COMM_WORLD, NULL);
+		starpu_data_unregister(xhandle);
+		FPRINTF(stderr, "[received] real %f imaginary %f\n", xreal, ximaginary);
+		STARPU_ASSERT_MSG(xreal == 4 && ximaginary == 8, "Incorrect received value\n");
+	}
+
 	starpu_task_wait_for_all();
 
 	starpu_data_unregister(handle);