Browse Source

mpi: simplify mechanism to send data size for user-defined datatype

  when exchanging user-defined datatype, we now send the size of the
     data directly before sending the data (we no longer create a
     starpu data handle and use the starpu-mpi mechanism).

  Thanks to Benoit Lizé for suggesting this huge improvment
Nathalie Furmento 12 years ago
parent
commit
762e40a988
2 changed files with 14 additions and 12 deletions
  1. 11 12
      mpi/src/starpu_mpi.c
  2. 3 0
      mpi/src/starpu_mpi_private.h

+ 11 - 12
mpi/src/starpu_mpi.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010-2012  Université de Bordeaux 1
- * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012, 2013  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
@@ -143,12 +143,6 @@ static void _starpu_mpi_isend_data_func(struct _starpu_mpi_req *req)
 	_STARPU_MPI_LOG_OUT();
 }
 
-static void _starpu_mpi_isend_size_callback(void *arg)
-{
-	struct _starpu_mpi_req *req = (struct _starpu_mpi_req *) arg;
-	_starpu_mpi_isend_data_func(req);
-}
-
 static void _starpu_mpi_isend_size_func(struct _starpu_mpi_req *req)
 {
 	_starpu_mpi_handle_allocate_datatype(req->data_handle, &req->datatype, &req->user_datatype);
@@ -160,12 +154,9 @@ static void _starpu_mpi_isend_size_func(struct _starpu_mpi_req *req)
 	}
 	else
 	{
-		starpu_data_handle_t count_handle;
-
 		starpu_handle_pack_data(req->data_handle, &req->ptr, &req->count);
-		starpu_variable_data_register(&count_handle, 0, (uintptr_t)&req->count, sizeof(req->count));
-		_starpu_mpi_isend_common(count_handle, req->srcdst, req->mpi_tag, req->comm, 1, _starpu_mpi_isend_size_callback, req);
-		starpu_data_unregister_submit(count_handle);
+		MPI_Isend(&req->count, sizeof(req->count), MPI_BYTE, req->srcdst, req->mpi_tag, req->comm, &req->size_req);
+		_starpu_mpi_isend_data_func(req);
 	}
 }
 
@@ -636,6 +627,14 @@ static void _starpu_mpi_handle_request_termination(struct _starpu_mpi_req *req)
 	{
 		if (req->user_datatype == 1)
 		{
+			if (req->request_type == SEND_REQ)
+			{
+				// We already know the request to send the size is completed, we just call MPI_Test to make sure that the request object is deallocated
+				MPI_Status status;
+				int flag;
+				MPI_Test(&req->size_req, &flag, &status);
+				STARPU_ASSERT(flag == 1);
+			}
 			if (req->request_type == RECV_REQ)
 				// req->ptr is freed by starpu_handle_unpack_data
 				starpu_handle_unpack_data(req->data_handle, req->ptr, req->count);

+ 3 - 0
mpi/src/starpu_mpi_private.h

@@ -108,6 +108,9 @@ LIST_TYPE(_starpu_mpi_req,
 	unsigned detached;
 	void *callback_arg;
 	void (*callback)(void *);
+
+        /* in the case of user-defined datatypes, we need to send the size of the data */
+	MPI_Request size_req;
 );
 
 #ifdef __cplusplus