Browse Source

Factorize _starpu_mpi_request_init and _starpu_mpi_request_destroy

between mpi_mpi and mpi_nmad
Samuel Thibault 7 years ago
parent
commit
bfd3b67f90
4 changed files with 112 additions and 144 deletions
  1. 2 1
      mpi/src/Makefile.am
  2. 0 75
      mpi/src/mpi/starpu_mpi_mpi.c
  3. 0 68
      mpi/src/nmad/starpu_mpi_nmad.c
  4. 110 0
      mpi/src/starpu_mpi_req.c

+ 2 - 1
mpi/src/Makefile.am

@@ -2,7 +2,7 @@
 #
 #
 # Copyright (C) 2012                                     Inria
 # Copyright (C) 2012                                     Inria
 # Copyright (C) 2010-2017                                CNRS
 # Copyright (C) 2010-2017                                CNRS
-# Copyright (C) 2009-2014                                Université de Bordeaux
+# Copyright (C) 2009-2014, 2018                                Université de Bordeaux
 #
 #
 # StarPU is free software; you can redistribute it and/or modify
 # 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
 # it under the terms of the GNU Lesser General Public License as published by
@@ -78,6 +78,7 @@ noinst_HEADERS =					\
 
 
 libstarpumpi_@STARPU_EFFECTIVE_VERSION@_la_SOURCES =	\
 libstarpumpi_@STARPU_EFFECTIVE_VERSION@_la_SOURCES =	\
 	starpu_mpi.c					\
 	starpu_mpi.c					\
+	starpu_mpi_req.c				\
 	starpu_mpi_helper.c				\
 	starpu_mpi_helper.c				\
 	starpu_mpi_datatype.c				\
 	starpu_mpi_datatype.c				\
 	starpu_mpi_task_insert.c			\
 	starpu_mpi_task_insert.c			\

+ 0 - 75
mpi/src/mpi/starpu_mpi_mpi.c

@@ -110,81 +110,6 @@ extern void smpi_process_set_user_data(void *);
 #endif
 #endif
 #endif
 #endif
 
 
-void _starpu_mpi_request_init(struct _starpu_mpi_req **req)
-{
-	_STARPU_MPI_CALLOC(*req, 1, sizeof(struct _starpu_mpi_req));
-
-	/* Initialize the request structure */
-	(*req)->data_handle = NULL;
-	(*req)->prio = 0;
-
-	(*req)->datatype = 0;
-	(*req)->datatype_name = NULL;
-	(*req)->ptr = NULL;
-	(*req)->count = -1;
-	(*req)->registered_datatype = -1;
-
-	(*req)->node_tag.rank = -1;
-	(*req)->node_tag.data_tag = -1;
-	(*req)->node_tag.comm = 0;
-
-	(*req)->func = NULL;
-
-	(*req)->status = NULL;
-	(*req)->data_request = 0;
-	(*req)->flag = NULL;
-
-	(*req)->ret = -1;
-	STARPU_PTHREAD_MUTEX_INIT(&((*req)->req_mutex), NULL);
-	STARPU_PTHREAD_COND_INIT(&((*req)->req_cond), NULL);
-	STARPU_PTHREAD_MUTEX_INIT(&((*req)->posted_mutex), NULL);
-	STARPU_PTHREAD_COND_INIT(&((*req)->posted_cond), NULL);
-
-	(*req)->request_type = UNKNOWN_REQ;
-
-	(*req)->submitted = 0;
-	(*req)->completed = 0;
-	(*req)->posted = 0;
-
-	(*req)->other_request = NULL;
-
-	(*req)->sync = 0;
-	(*req)->detached = -1;
-	(*req)->callback = NULL;
-	(*req)->callback_arg = NULL;
-
-	(*req)->size_req = 0;
-	(*req)->internal_req = NULL;
-	(*req)->is_internal_req = 0;
-	(*req)->to_destroy = 1;
-	(*req)->early_data_handle = NULL;
-	(*req)->envelope = NULL;
-	(*req)->sequential_consistency = 1;
-	(*req)->pre_sync_jobid = -1;
-	(*req)->post_sync_jobid = -1;
-
-#ifdef STARPU_SIMGRID
-	starpu_pthread_queue_init(&((*req)->queue));
-	starpu_pthread_queue_register(&wait, &((*req)->queue));
-	(*req)->done = 0;
-#endif
-}
-
-void _starpu_mpi_request_destroy(struct _starpu_mpi_req *req)
-{
-	STARPU_PTHREAD_MUTEX_DESTROY(&req->req_mutex);
-	STARPU_PTHREAD_COND_DESTROY(&req->req_cond);
-	STARPU_PTHREAD_MUTEX_DESTROY(&req->posted_mutex);
-	STARPU_PTHREAD_COND_DESTROY(&req->posted_cond);
-	free(req->datatype_name);
-	req->datatype_name = NULL;
-#ifdef STARPU_SIMGRID
-	starpu_pthread_queue_unregister(&wait, &req->queue);
-	starpu_pthread_queue_destroy(&req->queue);
-#endif
-	free(req);
-}
-
  /********************************************************/
  /********************************************************/
  /*                                                      */
  /*                                                      */
  /*  Send/Receive functionalities                        */
  /*  Send/Receive functionalities                        */

+ 0 - 68
mpi/src/nmad/starpu_mpi_nmad.c

@@ -72,74 +72,6 @@ static callback_lfstack_t callback_stack = NULL;
 
 
 static starpu_sem_t callback_sem;
 static starpu_sem_t callback_sem;
 
 
-void _starpu_mpi_request_init(struct _starpu_mpi_req **req)
-{
-	_STARPU_MPI_CALLOC(*req, 1, sizeof(struct _starpu_mpi_req));
-
-	/* Initialize the request structure */
-	(*req)->data_handle = NULL;
-	(*req)->prio = 0;
-	(*req)->completed = 0;
-
-	(*req)->datatype = 0;
-	(*req)->datatype_name = NULL;
-	(*req)->ptr = NULL;
-	(*req)->count = -1;
-	(*req)->registered_datatype = -1;
-
-	(*req)->node_tag.rank = -1;
-	(*req)->node_tag.data_tag = -1;
-	(*req)->node_tag.comm = 0;
-
-	(*req)->func = NULL;
-
-	(*req)->status = NULL;
-	//	(*req)->data_request = 0;
-	(*req)->flag = NULL;
-
-	(*req)->ret = -1;
-	piom_cond_init(&((*req)->req_cond), 0);
-	//STARPU_PTHREAD_MUTEX_INIT(&((*req)->req_mutex), NULL);
-	//STARPU_PTHREAD_COND_INIT(&((*req)->req_cond), NULL);
-	//	STARPU_PTHREAD_MUTEX_INIT(&((*req)->posted_mutex), NULL);
-	//STARPU_PTHREAD_COND_INIT(&((*req)->posted_cond), NULL);
-
-	(*req)->request_type = UNKNOWN_REQ;
-
-	(*req)->submitted = 0;
-	(*req)->completed = 0;
-	(*req)->posted = 0;
-
-	//(*req)->other_request = NULL;
-
-	(*req)->sync = 0;
-	(*req)->detached = -1;
-	(*req)->callback = NULL;
-	(*req)->callback_arg = NULL;
-
-	//	(*req)->size_req = 0;
-	//(*req)->internal_req = NULL;
-	//(*req)->is_internal_req = 0;
-	//(*req)->to_destroy = 1;
-	//(*req)->early_data_handle = NULL;
-	//(*req)->envelope = NULL;
-	(*req)->sequential_consistency = 1;
-	(*req)->pre_sync_jobid = -1;
-	(*req)->post_sync_jobid = -1;
-
-#ifdef STARPU_SIMGRID
-	starpu_pthread_queue_init(&((*req)->queue));
-	starpu_pthread_queue_register(&wait, &((*req)->queue));
-	(*req)->done = 0;
-#endif
-}
-
-void _starpu_mpi_request_destroy(struct _starpu_mpi_req *req)
-{
-	piom_cond_destroy(&(req->req_cond));
-	free(req);
-}
-
 /********************************************************/
 /********************************************************/
 /*                                                      */
 /*                                                      */
 /*  Send/Receive functionalities                        */
 /*  Send/Receive functionalities                        */

+ 110 - 0
mpi/src/starpu_mpi_req.c

@@ -0,0 +1,110 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2012-2013,2016-2017                      Inria
+ * Copyright (C) 2009-2018                                Université de Bordeaux
+ * Copyright (C) 2017                                     Guillaume Beauchamp
+ * Copyright (C) 2010-2017                                CNRS
+ *
+ * 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
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU 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_private.h>
+
+void _starpu_mpi_request_init(struct _starpu_mpi_req **req)
+{
+	_STARPU_MPI_CALLOC(*req, 1, sizeof(struct _starpu_mpi_req));
+
+	/* Initialize the request structure */
+	(*req)->data_handle = NULL;
+	(*req)->prio = 0;
+
+	(*req)->datatype = 0;
+	(*req)->datatype_name = NULL;
+	(*req)->ptr = NULL;
+	(*req)->count = -1;
+	(*req)->registered_datatype = -1;
+
+	(*req)->node_tag.rank = -1;
+	(*req)->node_tag.data_tag = -1;
+	(*req)->node_tag.comm = 0;
+
+	(*req)->func = NULL;
+
+	(*req)->status = NULL;
+#ifdef STARPU_USE_MPI_MPI
+	(*req)->data_request = 0;
+#endif
+	(*req)->flag = NULL;
+
+	(*req)->ret = -1;
+#ifdef STARPU_USE_MPI_NMAD
+	piom_cond_init(&((*req)->req_cond), 0);
+#elif defined(STARPU_USE_MPI_MPI)
+	STARPU_PTHREAD_MUTEX_INIT(&((*req)->req_mutex), NULL);
+	STARPU_PTHREAD_COND_INIT(&((*req)->req_cond), NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&((*req)->posted_mutex), NULL);
+	STARPU_PTHREAD_COND_INIT(&((*req)->posted_cond), NULL);
+#endif
+
+	(*req)->request_type = UNKNOWN_REQ;
+
+	(*req)->submitted = 0;
+	(*req)->completed = 0;
+	(*req)->posted = 0;
+
+#ifdef STARPU_USE_MPI_MPI
+	(*req)->other_request = NULL;
+#endif
+
+	(*req)->sync = 0;
+	(*req)->detached = -1;
+	(*req)->callback = NULL;
+	(*req)->callback_arg = NULL;
+
+#ifdef STARPU_USE_MPI_MPI
+	(*req)->size_req = 0;
+	(*req)->internal_req = NULL;
+	(*req)->is_internal_req = 0;
+	(*req)->to_destroy = 1;
+	(*req)->early_data_handle = NULL;
+	(*req)->envelope = NULL;
+#endif
+	(*req)->sequential_consistency = 1;
+	(*req)->pre_sync_jobid = -1;
+	(*req)->post_sync_jobid = -1;
+
+#ifdef STARPU_SIMGRID
+	starpu_pthread_queue_init(&((*req)->queue));
+	starpu_pthread_queue_register(&wait, &((*req)->queue));
+	(*req)->done = 0;
+#endif
+}
+
+void _starpu_mpi_request_destroy(struct _starpu_mpi_req *req)
+{
+#ifdef STARPU_USE_MPI_NMAD
+	piom_cond_destroy(&(req->req_cond));
+#elif defined(STARPU_USE_MPI_MPI)
+	STARPU_PTHREAD_MUTEX_DESTROY(&req->req_mutex);
+	STARPU_PTHREAD_COND_DESTROY(&req->req_cond);
+	STARPU_PTHREAD_MUTEX_DESTROY(&req->posted_mutex);
+	STARPU_PTHREAD_COND_DESTROY(&req->posted_cond);
+	free(req->datatype_name);
+	req->datatype_name = NULL;
+#endif
+#ifdef STARPU_SIMGRID
+	starpu_pthread_queue_unregister(&wait, &req->queue);
+	starpu_pthread_queue_destroy(&req->queue);
+#endif
+	free(req);
+}
+