Sfoglia il codice sorgente

- Bug fix: actually use mpi_isend.c in the mpi_isend test :)
- Add a mpi_irecv test

Cédric Augonnet 15 anni fa
parent
commit
744f2a8624
3 ha cambiato i file con 85 aggiunte e 1 eliminazioni
  1. 7 1
      mpi/Makefile.am
  2. 2 0
      mpi/starpu_mpi.c
  3. 76 0
      mpi/tests/mpi_irecv.c

+ 7 - 1
mpi/Makefile.am

@@ -52,6 +52,7 @@ check_PROGRAMS =
 check_PROGRAMS +=					\
 	tests/pingpong					\
 	tests/mpi_isend					\
+	tests/mpi_irecv					\
 	tests/ring					\
 	tests/block_interface
 
@@ -59,8 +60,13 @@ tests_mpi_isend_LDADD =					\
 	libstarpumpi.la
 
 tests_mpi_isend_SOURCES =				\
-	tests/pingpong.c
+	tests/mpi_isend.c
+
+tests_mpi_irecv_LDADD =					\
+	libstarpumpi.la
 
+tests_mpi_irecv_SOURCES =				\
+	tests/mpi_irecv.c
 
 tests_pingpong_LDADD =					\
 	libstarpumpi.la

+ 2 - 0
mpi/starpu_mpi.c

@@ -63,6 +63,8 @@ static void _handle_new_mpi_irecv(struct starpu_mpi_req_s *req)
 }
 
 
+/* NB: there is no status field here as we (may) return before the request is
+ * actually transmitted to MPI. */
 int starpu_mpi_irecv(starpu_data_handle data_handle, struct starpu_mpi_req_s *req,
 		int source, int mpi_tag, MPI_Comm comm,
 		void (*callback)(void *))

+ 76 - 0
mpi/tests/mpi_irecv.c

@@ -0,0 +1,76 @@
+/*
+ * StarPU
+ * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#include <starpu_mpi.h>
+
+#define NITER	2048
+#define SIZE	16
+
+float *tab;
+starpu_data_handle tab_handle;
+
+int main(int argc, char **argv)
+{
+	MPI_Init(NULL, NULL);
+
+	int rank, size;
+
+	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+	MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+	if (size != 2)
+	{
+		if (rank == 0)
+			fprintf(stderr, "We need exactly 2 processes.\n");
+
+		MPI_Finalize();
+		return 0;
+	}
+
+	starpu_init(NULL);
+	starpu_mpi_initialize();
+
+	tab = malloc(SIZE*sizeof(float));
+
+	starpu_register_vector_data(&tab_handle, 0, (uintptr_t)tab, SIZE, sizeof(float));
+
+	unsigned nloops = NITER;
+	unsigned loop;
+
+	int other_rank = (rank + 1)%2;
+
+	for (loop = 0; loop < nloops; loop++)
+	{
+		if ((loop % 2) == rank)
+		{
+			starpu_mpi_send(tab_handle, other_rank, loop, MPI_COMM_WORLD);
+		}
+		else {
+			MPI_Status status;
+			struct starpu_mpi_req_s req;
+			starpu_mpi_irecv(tab_handle, &req, other_rank, loop,
+					MPI_COMM_WORLD, NULL);
+			starpu_mpi_wait(&req, &status);
+		}
+	}
+	
+	starpu_mpi_shutdown();
+	starpu_shutdown();
+
+	MPI_Finalize();
+
+	return 0;
+}