소스 검색

simgrid: fix starpu_mpi_test

Samuel Thibault 5 년 전
부모
커밋
fc521e9485
9개의 변경된 파일66개의 추가작업 그리고 44개의 파일을 삭제
  1. 30 20
      mpi/src/mpi/starpu_mpi_mpi.c
  2. 12 12
      mpi/tests/Makefile.am
  3. 4 1
      mpi/tests/driver.c
  4. 4 1
      mpi/tests/mpi_earlyrecv.c
  5. 2 2
      mpi/tests/mpi_earlyrecv2.c
  6. 2 2
      mpi/tests/mpi_earlyrecv2_sync.c
  7. 4 1
      mpi/tests/mpi_test.c
  8. 4 1
      mpi/tests/multiple_send.c
  9. 4 4
      mpi/tests/pingpong.c

+ 30 - 20
mpi/src/mpi/starpu_mpi_mpi.c

@@ -501,10 +501,10 @@ void _starpu_mpi_irecv_size_func(struct _starpu_mpi_req *req)
 	{
 		_STARPU_MPI_COMM_FROM_DEBUG(req, req->count, req->datatype, req->node_tag.node.rank, _STARPU_MPI_TAG_DATA, req->node_tag.data_tag, req->node_tag.node.comm);
 		req->ret = MPI_Irecv(req->ptr, req->count, req->datatype, req->node_tag.node.rank, _STARPU_MPI_TAG_DATA, req->node_tag.node.comm, &req->backend->data_request);
+	}
 #ifdef STARPU_SIMGRID
-		_starpu_mpi_simgrid_wait_req(&req->backend->data_request, &req->status_store, &req->queue, &req->done);
+	_starpu_mpi_simgrid_wait_req(&req->backend->data_request, &req->status_store, &req->queue, &req->done);
 #endif
-	}
 	STARPU_MPI_ASSERT_MSG(req->ret == MPI_SUCCESS, "MPI_IRecv returning %s", _starpu_mpi_get_mpi_error_code(req->ret));
 
 	_STARPU_MPI_TRACE_IRECV_SUBMIT_END(req->node_tag.node.rank, req->node_tag.data_tag);
@@ -620,6 +620,7 @@ int _starpu_mpi_wait(starpu_mpi_req *public_req, MPI_Status *status)
 /*                                                      */
 /********************************************************/
 
+#ifndef STARPU_SIMGRID
 void _starpu_mpi_test_func(struct _starpu_mpi_req *testing_req)
 {
 	_STARPU_MPI_LOG_IN();
@@ -632,12 +633,7 @@ void _starpu_mpi_test_func(struct _starpu_mpi_req *testing_req)
 
 	_STARPU_MPI_TRACE_UTESTING_BEGIN(req->node_tag.node.rank, req->node_tag.data_tag);
 
-#ifdef STARPU_SIMGRID
-	req->ret = _starpu_mpi_simgrid_mpi_test(&req->done, testing_req->flag);
-	memcpy(testing_req->status, &req->status_store, sizeof(*testing_req->status));
-#else
 	req->ret = MPI_Test(&req->backend->data_request, testing_req->flag, testing_req->status);
-#endif
 
 	STARPU_MPI_ASSERT_MSG(req->ret == MPI_SUCCESS, "MPI_Test returning %s", _starpu_mpi_get_mpi_error_code(req->ret));
 
@@ -655,6 +651,7 @@ void _starpu_mpi_test_func(struct _starpu_mpi_req *testing_req)
 	STARPU_PTHREAD_MUTEX_UNLOCK(&testing_req->backend->req_mutex);
 	_STARPU_MPI_LOG_OUT();
 }
+#endif
 
 int _starpu_mpi_test(starpu_mpi_req *public_req, int *flag, MPI_Status *status)
 {
@@ -667,6 +664,15 @@ int _starpu_mpi_test(starpu_mpi_req *public_req, int *flag, MPI_Status *status)
 
 	STARPU_MPI_ASSERT_MSG(!req->detached, "MPI_Test cannot be called on a detached request");
 
+#ifdef STARPU_SIMGRID
+	ret = req->ret = _starpu_mpi_simgrid_mpi_test(&req->done, flag);
+	if (*flag)
+	{
+		if (status)
+			*status = req->status_store;
+		_starpu_mpi_handle_request_termination(req);
+	}
+#else
 	STARPU_PTHREAD_MUTEX_LOCK(&req->backend->req_mutex);
 	unsigned submitted = req->submitted;
 	STARPU_PTHREAD_MUTEX_UNLOCK(&req->backend->req_mutex);
@@ -695,25 +701,26 @@ int _starpu_mpi_test(starpu_mpi_req *public_req, int *flag, MPI_Status *status)
 
 		ret = testing_req->ret;
 
-		if (*(testing_req->flag))
-		{
-			/* The request was completed so we free the internal
-			 * request structure which was automatically allocated
-			 * */
-			*public_req = NULL;
-			if (req->backend->internal_req)
-			{
-				_starpu_mpi_request_destroy(req->backend->internal_req);
-			}
-			_starpu_mpi_request_destroy(req);
-		}
-
 		_starpu_mpi_request_destroy(testing_req);
 	}
 	else
 	{
 		*flag = 0;
 	}
+#endif
+
+	if (*flag)
+	{
+		/* The request was completed so we free the internal
+		 * request structure which was automatically allocated
+		 * */
+		*public_req = NULL;
+		if (req->backend->internal_req)
+		{
+			_starpu_mpi_request_destroy(req->backend->internal_req);
+		}
+		_starpu_mpi_request_destroy(req);
+	}
 
 	_STARPU_MPI_LOG_OUT();
 	return ret;
@@ -949,6 +956,9 @@ static void _starpu_mpi_early_data_cb(void* arg)
 			args->req->submitted = 1;
 			STARPU_PTHREAD_COND_BROADCAST(&args->req->backend->req_cond);
 			STARPU_PTHREAD_MUTEX_UNLOCK(&args->req->backend->req_mutex);
+#ifdef STARPU_SIMGRID
+			args->req->done = 1;
+#endif
 		}
 	}
 

+ 12 - 12
mpi/tests/Makefile.am

@@ -99,9 +99,13 @@ starpu_mpi_TESTS +=				\
 	cache					\
 	cache_disable				\
 	callback				\
+	driver					\
 	early_request				\
+	gather					\
+	gather2					\
 	insert_task				\
 	insert_task_block			\
+	insert_task_count			\
 	insert_task_dyn_handles			\
 	insert_task_node_choice			\
 	insert_task_owner			\
@@ -111,12 +115,16 @@ starpu_mpi_TESTS +=				\
 	matrix2					\
 	mpi_barrier				\
 	mpi_detached_tag			\
+	mpi_earlyrecv				\
 	mpi_irecv				\
 	mpi_irecv_detached			\
 	mpi_isend				\
 	mpi_isend_detached			\
 	mpi_reduction				\
+	mpi_redux				\
 	mpi_scatter_gather			\
+	mpi_test				\
+	multiple_send				\
 	pingpong				\
 	policy_register				\
 	policy_register_many			\
@@ -125,35 +133,27 @@ starpu_mpi_TESTS +=				\
 	ring					\
 	ring_async				\
 	ring_async_implicit			\
+	ring_sync				\
+	ring_sync_detached			\
 	temporary				\
 	user_defined_datatype			\
 	early_stuff				\
 	sendrecv_bench
 
 if !STARPU_SIMGRID
+# missing support in simgrid
 starpu_mpi_TESTS +=				\
 	attr					\
-	mpi_test				\
-	mpi_earlyrecv				\
 	mpi_earlyrecv2				\
 	mpi_earlyrecv2_sync			\
-	mpi_redux				\
-	ring_sync				\
-	ring_sync_detached			\
 	block_interface				\
 	block_interface_pinned			\
-	matrix2					\
 	insert_task_compute			\
 	insert_task_sent_cache			\
 	insert_task_recv_cache			\
-	insert_task_count			\
 	insert_task_seq				\
-	multiple_send				\
 	tags_checking				\
-	sync					\
-	gather					\
-	gather2					\
-	driver
+	sync
 
 if STARPU_USE_MPI_MPI
 starpu_mpi_TESTS +=				\

+ 4 - 1
mpi/tests/driver.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2017,2018                                CNRS
- * Copyright (C) 2018                                     Université de Bordeaux
+ * Copyright (C) 2018,2020                                Université de Bordeaux
  *
  * 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
@@ -100,6 +100,9 @@ int main(int argc, char **argv)
 			}
 		}
 		finished = request[0] == NULL && request[1] == NULL;
+#ifdef STARPU_SIMGRID
+		starpu_sleep(0.001);
+#endif
 	}
 
 	if (rank%2 == 0)

+ 4 - 1
mpi/tests/mpi_earlyrecv.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2015,2017                           CNRS
- * Copyright (C) 2009,2010,2014,2015,2017,2018            Université de Bordeaux
+ * Copyright (C) 2009,2010,2014,2015,2017,2018,2020       Université de Bordeaux
  * Copyright (C) 2013                                     Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -98,6 +98,9 @@ int main(int argc, char **argv)
 			}
 		}
 		finished = request[0] == NULL && request[1] == NULL;
+#ifdef STARPU_SIMGRID
+		starpu_sleep(0.001);
+#endif
 	}
 
 	if (rank%2 == 0)

+ 2 - 2
mpi/tests/mpi_earlyrecv2.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2017                                CNRS
- * Copyright (C) 2009,2010,2014,2015,2017,2018            Université de Bordeaux
+ * Copyright (C) 2009,2010,2014,2015,2017,2018,2020       Université de Bordeaux
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2013                                     Inria
  *
@@ -73,7 +73,7 @@ int exchange(int rank, starpu_data_handle_t *handles, check_func func, int detac
 		}
 
 		// We sleep to make sure that the data for the tag 9 will be received before the recv is posted
-		usleep(2000000);
+		starpu_sleep(2);
 		for(i=1 ; i<NB ; i++)
 		{
 			if (detached)

+ 2 - 2
mpi/tests/mpi_earlyrecv2_sync.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2017                                CNRS
- * Copyright (C) 2009,2010,2015,2018                      Université de Bordeaux
+ * Copyright (C) 2009,2010,2015,2018,2020                 Université de Bordeaux
  *
  * 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
@@ -65,7 +65,7 @@ int exchange(int rank, starpu_data_handle_t *handles, check_func func)
 		STARPU_ASSERT(req[1] != NULL);
 
 		// We sleep to make sure that the data for the tag 8 and the tag 9 will be received before the recv are posted
-		usleep(2000000);
+		starpu_sleep(2);
 		for(i=2 ; i<NB ; i++)
 		{
 			starpu_mpi_irecv(handles[i], &req[i], other_rank, i, MPI_COMM_WORLD);

+ 4 - 1
mpi/tests/mpi_test.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011,2014,2015,2017,2018            Université de Bordeaux
+ * Copyright (C) 2010,2011,2014,2015,2017,2018,2020       Université de Bordeaux
  * Copyright (C) 2013                                     Inria
  * Copyright (C) 2010-2013,2015-2017                      CNRS
  *
@@ -79,6 +79,9 @@ int main(int argc, char **argv)
 		{
 			MPI_Status status;
 			starpu_mpi_test(&req, &finished, &status);
+#ifdef STARPU_SIMGRID
+			starpu_sleep(0.001);
+#endif
 		}
 		while (!finished);
 	}

+ 4 - 1
mpi/tests/multiple_send.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2013                                     Inria
  * Copyright (C) 2011-2013,2015,2017                      CNRS
- * Copyright (C) 2011,2015,2018                           Université de Bordeaux
+ * Copyright (C) 2011,2015,2018,2020                      Université de Bordeaux
  *
  * 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
@@ -80,6 +80,9 @@ int main(int argc, char **argv)
 					}
 				}
 			}
+#ifdef STARPU_SIMGRID
+			starpu_sleep(0.001);
+#endif
 		}
 	}
 	FPRINTF(stderr, "[%d] All requests finished\n", rank);

+ 4 - 4
mpi/tests/pingpong.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2011,2014,2015,2017,2018            Université de Bordeaux
+ * Copyright (C) 2009-2011,2014,2015,2017,2018,2020       Université de Bordeaux
  * Copyright (C) 2013                                     Inria
  * Copyright (C) 2010-2013,2015-2017                      CNRS
  *
@@ -153,7 +153,7 @@ int main(int argc, char **argv)
 				starpu_mpi_recv(tab_handle, other_rank, loop, MPI_COMM_WORLD, &status);
 			}
 
-			usleep(sleep_time * 1000);
+			starpu_sleep(sleep_time / 1000);
 		}
 	}
 	else // broadcasts
@@ -168,7 +168,7 @@ int main(int argc, char **argv)
 					if (r != rank)
 					{
 						starpu_mpi_send(tab_handle, r, (r * niter) + loop, MPI_COMM_WORLD);
-						usleep(sleep_time * 1000);
+						starpu_sleep(sleep_time / 1000);
 					}
 				}
 			}
@@ -178,7 +178,7 @@ int main(int argc, char **argv)
 				starpu_mpi_recv(tab_handle, sender, (rank * niter) + loop, MPI_COMM_WORLD, &status);
 
 				for (int r = 0; r < (size-1); r++)
-					usleep(sleep_time * 1000);
+					starpu_sleep(sleep_time / 1000);
 			}
 		}
 	}