Forráskód Böngészése

mpi: simplify locking

We do not actually need a separate posted_mutex: we already hold the
progress mutex where we use it, better avoid releasing/reacquiring mutexes.
Samuel Thibault 4 éve
szülő
commit
0c53bfa718

+ 2 - 8
mpi/src/mpi/starpu_mpi_mpi.c

@@ -213,12 +213,8 @@ void _starpu_mpi_submit_ready_request(void *arg)
 			_STARPU_MPI_INC_READY_REQUESTS(+1);
 
 			/* inform the starpu mpi thread that the request has been pushed in the ready_requests list */
-			STARPU_PTHREAD_MUTEX_UNLOCK(&progress_mutex);
-			STARPU_PTHREAD_MUTEX_LOCK(&req->backend->posted_mutex);
 			req->posted = 1;
 			STARPU_PTHREAD_COND_BROADCAST(&req->backend->posted_cond);
-			STARPU_PTHREAD_MUTEX_UNLOCK(&req->backend->posted_mutex);
-			STARPU_PTHREAD_MUTEX_LOCK(&progress_mutex);
 		}
 		else
 		{
@@ -1193,11 +1189,9 @@ static void _starpu_mpi_receive_early_data(struct _starpu_mpi_envelope *envelope
 
 	// We wait until the request is pushed in the
 	// ready_request list
-	STARPU_PTHREAD_MUTEX_UNLOCK(&progress_mutex);
-	STARPU_PTHREAD_MUTEX_LOCK(&(early_data_handle->req->backend->posted_mutex));
 	while (!(early_data_handle->req->posted))
-		STARPU_PTHREAD_COND_WAIT(&(early_data_handle->req->backend->posted_cond), &(early_data_handle->req->backend->posted_mutex));
-	STARPU_PTHREAD_MUTEX_UNLOCK(&(early_data_handle->req->backend->posted_mutex));
+		STARPU_PTHREAD_COND_WAIT(&(early_data_handle->req->backend->posted_cond), &progress_mutex);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&progress_mutex);
 
 #ifdef STARPU_DEVEL
 #warning check if req_ready is still necessary

+ 0 - 2
mpi/src/mpi/starpu_mpi_mpi_backend.c

@@ -54,7 +54,6 @@ void _starpu_mpi_mpi_backend_request_init(struct _starpu_mpi_req *req)
 
 	STARPU_PTHREAD_MUTEX_INIT0(&req->backend->req_mutex, NULL);
 	STARPU_PTHREAD_COND_INIT0(&req->backend->req_cond, NULL);
-	STARPU_PTHREAD_MUTEX_INIT0(&req->backend->posted_mutex, NULL);
 	STARPU_PTHREAD_COND_INIT0(&req->backend->posted_cond, NULL);
 
 	//req->backend->other_request = NULL;
@@ -80,7 +79,6 @@ void _starpu_mpi_mpi_backend_request_destroy(struct _starpu_mpi_req *req)
 {
 	STARPU_PTHREAD_MUTEX_DESTROY(&req->backend->req_mutex);
 	STARPU_PTHREAD_COND_DESTROY(&req->backend->req_cond);
-	STARPU_PTHREAD_MUTEX_DESTROY(&req->backend->posted_mutex);
 	STARPU_PTHREAD_COND_DESTROY(&req->backend->posted_cond);
 	free(req->backend);
 	req->backend = NULL;

+ 0 - 1
mpi/src/mpi/starpu_mpi_mpi_backend.h

@@ -54,7 +54,6 @@ struct _starpu_mpi_req_backend
 
 	starpu_pthread_mutex_t req_mutex;
 	starpu_pthread_cond_t req_cond;
-	starpu_pthread_mutex_t posted_mutex;
 	starpu_pthread_cond_t posted_cond;
 	/** In the case of a Wait/Test request, we are going to post a request
 	 * to test the completion of another request */