|
@@ -17,6 +17,7 @@
|
|
|
*/
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
+#include <limits.h>
|
|
|
#include <starpu_mpi.h>
|
|
|
#include <starpu_mpi_datatype.h>
|
|
|
#include <starpu_mpi_private.h>
|
|
@@ -50,7 +51,7 @@ static char *_starpu_mpi_request_type(enum _starpu_mpi_request_type request_type
|
|
|
#endif
|
|
|
static struct _starpu_mpi_req *_starpu_mpi_isend_common(starpu_data_handle_t data_handle,
|
|
|
int dest, int data_tag, MPI_Comm comm,
|
|
|
- unsigned detached, unsigned sync, void (*callback)(void *), void *arg,
|
|
|
+ unsigned detached, unsigned sync, int prio, void (*callback)(void *), void *arg,
|
|
|
int sequential_consistency);
|
|
|
static struct _starpu_mpi_req *_starpu_mpi_irecv_common(starpu_data_handle_t data_handle,
|
|
|
int source, int data_tag, MPI_Comm comm,
|
|
@@ -61,7 +62,7 @@ static void _starpu_mpi_handle_detached_request(struct _starpu_mpi_req *req);
|
|
|
static void _starpu_mpi_early_data_cb(void* arg);
|
|
|
|
|
|
/* The list of ready requests */
|
|
|
-static struct _starpu_mpi_req_list ready_requests;
|
|
|
+static struct _starpu_mpi_req_prio_list ready_requests;
|
|
|
|
|
|
/* The list of detached requests that have already been submitted to MPI */
|
|
|
static struct _starpu_mpi_req_list detached_requests;
|
|
@@ -105,6 +106,7 @@ static void _starpu_mpi_request_init(struct _starpu_mpi_req **req)
|
|
|
|
|
|
/* Initialize the request structure */
|
|
|
(*req)->data_handle = NULL;
|
|
|
+ (*req)->prio = 0;
|
|
|
|
|
|
(*req)->datatype = 0;
|
|
|
(*req)->datatype_name = NULL;
|
|
@@ -222,7 +224,7 @@ static void _starpu_mpi_submit_ready_request(void *arg)
|
|
|
_STARPU_MPI_DEBUG(3, "Pushing internal starpu_mpi_irecv request %p type %s tag %d src %d data %p ptr %p datatype '%s' count %d registered_datatype %d \n",
|
|
|
req, _starpu_mpi_request_type(req->request_type), req->node_tag.data_tag, req->node_tag.rank, req->data_handle, req->ptr,
|
|
|
req->datatype_name, (int)req->count, req->registered_datatype);
|
|
|
- _starpu_mpi_req_list_push_front(&ready_requests, req);
|
|
|
+ _starpu_mpi_req_prio_list_push_front(&ready_requests, req);
|
|
|
|
|
|
/* inform the starpu mpi thread that the request has been pushed in the ready_requests list */
|
|
|
STARPU_PTHREAD_MUTEX_UNLOCK(&progress_mutex);
|
|
@@ -288,7 +290,7 @@ static void _starpu_mpi_submit_ready_request(void *arg)
|
|
|
STARPU_ASSERT(req->count);
|
|
|
_STARPU_MPI_MALLOC(req->ptr, req->count);
|
|
|
}
|
|
|
- _starpu_mpi_req_list_push_front(&ready_requests, req);
|
|
|
+ _starpu_mpi_req_prio_list_push_front(&ready_requests, req);
|
|
|
_starpu_mpi_request_destroy(sync_req);
|
|
|
}
|
|
|
else
|
|
@@ -301,7 +303,7 @@ static void _starpu_mpi_submit_ready_request(void *arg)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _starpu_mpi_req_list_push_front(&ready_requests, req);
|
|
|
+ _starpu_mpi_req_prio_list_push_front(&ready_requests, req);
|
|
|
_STARPU_MPI_DEBUG(3, "Pushing new request %p type %s tag %d src %d data %p ptr %p datatype '%s' count %d registered_datatype %d \n",
|
|
|
req, _starpu_mpi_request_type(req->request_type), req->node_tag.data_tag, req->node_tag.rank, req->data_handle, req->ptr,
|
|
|
req->datatype_name, (int)req->count, req->registered_datatype);
|
|
@@ -323,7 +325,7 @@ static void nop_acquire_cb(void *arg)
|
|
|
|
|
|
static struct _starpu_mpi_req *_starpu_mpi_isend_irecv_common(starpu_data_handle_t data_handle,
|
|
|
int srcdst, int data_tag, MPI_Comm comm,
|
|
|
- unsigned detached, unsigned sync, void (*callback)(void *), void *arg,
|
|
|
+ unsigned detached, unsigned sync, int prio, void (*callback)(void *), void *arg,
|
|
|
enum _starpu_mpi_request_type request_type, void (*func)(struct _starpu_mpi_req *),
|
|
|
enum starpu_data_access_mode mode,
|
|
|
int sequential_consistency,
|
|
@@ -347,6 +349,7 @@ static struct _starpu_mpi_req *_starpu_mpi_isend_irecv_common(starpu_data_handle
|
|
|
/* Initialize the request structure */
|
|
|
_starpu_mpi_request_init(&req);
|
|
|
req->request_type = request_type;
|
|
|
+ req->prio = prio;
|
|
|
req->data_handle = data_handle;
|
|
|
req->node_tag.rank = srcdst;
|
|
|
req->node_tag.data_tag = data_tag;
|
|
@@ -534,10 +537,10 @@ static void _starpu_mpi_isend_size_func(struct _starpu_mpi_req *req)
|
|
|
|
|
|
static struct _starpu_mpi_req *_starpu_mpi_isend_common(starpu_data_handle_t data_handle,
|
|
|
int dest, int data_tag, MPI_Comm comm,
|
|
|
- unsigned detached, unsigned sync, void (*callback)(void *), void *arg,
|
|
|
+ unsigned detached, unsigned sync, int prio, void (*callback)(void *), void *arg,
|
|
|
int sequential_consistency)
|
|
|
{
|
|
|
- return _starpu_mpi_isend_irecv_common(data_handle, dest, data_tag, comm, detached, sync, callback, arg, SEND_REQ, _starpu_mpi_isend_size_func,
|
|
|
+ return _starpu_mpi_isend_irecv_common(data_handle, dest, data_tag, comm, detached, sync, prio, callback, arg, SEND_REQ, _starpu_mpi_isend_size_func,
|
|
|
#ifdef STARPU_MPI_PEDANTIC_ISEND
|
|
|
STARPU_RW,
|
|
|
#else
|
|
@@ -546,14 +549,14 @@ static struct _starpu_mpi_req *_starpu_mpi_isend_common(starpu_data_handle_t dat
|
|
|
sequential_consistency, 0, 0);
|
|
|
}
|
|
|
|
|
|
-int starpu_mpi_isend(starpu_data_handle_t data_handle, starpu_mpi_req *public_req, int dest, int data_tag, MPI_Comm comm)
|
|
|
+int starpu_mpi_isend_prio(starpu_data_handle_t data_handle, starpu_mpi_req *public_req, int dest, int data_tag, int prio, MPI_Comm comm)
|
|
|
{
|
|
|
_STARPU_MPI_LOG_IN();
|
|
|
STARPU_MPI_ASSERT_MSG(public_req, "starpu_mpi_isend needs a valid starpu_mpi_req");
|
|
|
|
|
|
struct _starpu_mpi_req *req;
|
|
|
_STARPU_MPI_TRACE_ISEND_COMPLETE_BEGIN(dest, data_tag, 0);
|
|
|
- req = _starpu_mpi_isend_common(data_handle, dest, data_tag, comm, 0, 0, NULL, NULL, 1);
|
|
|
+ req = _starpu_mpi_isend_common(data_handle, dest, data_tag, comm, 0, 0, prio, NULL, NULL, 1);
|
|
|
_STARPU_MPI_TRACE_ISEND_COMPLETE_END(dest, data_tag, 0);
|
|
|
|
|
|
STARPU_MPI_ASSERT_MSG(req, "Invalid return for _starpu_mpi_isend_common");
|
|
@@ -562,17 +565,26 @@ int starpu_mpi_isend(starpu_data_handle_t data_handle, starpu_mpi_req *public_re
|
|
|
_STARPU_MPI_LOG_OUT();
|
|
|
return 0;
|
|
|
}
|
|
|
+int starpu_mpi_isend(starpu_data_handle_t data_handle, starpu_mpi_req *public_req, int dest, int data_tag, MPI_Comm comm)
|
|
|
+{
|
|
|
+ return starpu_mpi_isend_prio(data_handle, public_req, dest, data_tag, 0, comm);
|
|
|
+}
|
|
|
|
|
|
-int starpu_mpi_isend_detached(starpu_data_handle_t data_handle,
|
|
|
- int dest, int data_tag, MPI_Comm comm, void (*callback)(void *), void *arg)
|
|
|
+int starpu_mpi_isend_detached_prio(starpu_data_handle_t data_handle,
|
|
|
+ int dest, int data_tag, int prio, MPI_Comm comm, void (*callback)(void *), void *arg)
|
|
|
{
|
|
|
_STARPU_MPI_LOG_IN();
|
|
|
- _starpu_mpi_isend_common(data_handle, dest, data_tag, comm, 1, 0, callback, arg, 1);
|
|
|
+ _starpu_mpi_isend_common(data_handle, dest, data_tag, comm, 1, 0, prio, callback, arg, 1);
|
|
|
_STARPU_MPI_LOG_OUT();
|
|
|
return 0;
|
|
|
}
|
|
|
+int starpu_mpi_isend_detached(starpu_data_handle_t data_handle,
|
|
|
+ int dest, int data_tag, MPI_Comm comm, void (*callback)(void *), void *arg)
|
|
|
+{
|
|
|
+ return starpu_mpi_isend_detached_prio(data_handle, dest, data_tag, 0, comm, callback, arg);
|
|
|
+}
|
|
|
|
|
|
-int starpu_mpi_send(starpu_data_handle_t data_handle, int dest, int data_tag, MPI_Comm comm)
|
|
|
+int starpu_mpi_send_prio(starpu_data_handle_t data_handle, int dest, int data_tag, int prio, MPI_Comm comm)
|
|
|
{
|
|
|
starpu_mpi_req req;
|
|
|
MPI_Status status;
|
|
@@ -580,20 +592,24 @@ int starpu_mpi_send(starpu_data_handle_t data_handle, int dest, int data_tag, MP
|
|
|
_STARPU_MPI_LOG_IN();
|
|
|
memset(&status, 0, sizeof(MPI_Status));
|
|
|
|
|
|
- starpu_mpi_isend(data_handle, &req, dest, data_tag, comm);
|
|
|
+ starpu_mpi_isend_prio(data_handle, &req, dest, data_tag, prio, comm);
|
|
|
starpu_mpi_wait(&req, &status);
|
|
|
|
|
|
_STARPU_MPI_LOG_OUT();
|
|
|
return 0;
|
|
|
}
|
|
|
+int starpu_mpi_send(starpu_data_handle_t data_handle, int dest, int data_tag, MPI_Comm comm)
|
|
|
+{
|
|
|
+ return starpu_mpi_send_prio(data_handle, dest, data_tag, 0, comm);
|
|
|
+}
|
|
|
|
|
|
-int starpu_mpi_issend(starpu_data_handle_t data_handle, starpu_mpi_req *public_req, int dest, int data_tag, MPI_Comm comm)
|
|
|
+int starpu_mpi_issend_prio(starpu_data_handle_t data_handle, starpu_mpi_req *public_req, int dest, int data_tag, int prio, MPI_Comm comm)
|
|
|
{
|
|
|
_STARPU_MPI_LOG_IN();
|
|
|
STARPU_MPI_ASSERT_MSG(public_req, "starpu_mpi_issend needs a valid starpu_mpi_req");
|
|
|
|
|
|
struct _starpu_mpi_req *req;
|
|
|
- req = _starpu_mpi_isend_common(data_handle, dest, data_tag, comm, 0, 1, NULL, NULL, 1);
|
|
|
+ req = _starpu_mpi_isend_common(data_handle, dest, data_tag, comm, 0, 1, prio, NULL, NULL, 1);
|
|
|
|
|
|
STARPU_MPI_ASSERT_MSG(req, "Invalid return for _starpu_mpi_isend_common");
|
|
|
*public_req = req;
|
|
@@ -601,16 +617,24 @@ int starpu_mpi_issend(starpu_data_handle_t data_handle, starpu_mpi_req *public_r
|
|
|
_STARPU_MPI_LOG_OUT();
|
|
|
return 0;
|
|
|
}
|
|
|
+int starpu_mpi_issend(starpu_data_handle_t data_handle, starpu_mpi_req *public_req, int dest, int data_tag, MPI_Comm comm)
|
|
|
+{
|
|
|
+ return starpu_mpi_issend_prio(data_handle, public_req, dest, data_tag, 0, comm);
|
|
|
+}
|
|
|
|
|
|
-int starpu_mpi_issend_detached(starpu_data_handle_t data_handle, int dest, int data_tag, MPI_Comm comm, void (*callback)(void *), void *arg)
|
|
|
+int starpu_mpi_issend_detached_prio(starpu_data_handle_t data_handle, int dest, int data_tag, int prio, MPI_Comm comm, void (*callback)(void *), void *arg)
|
|
|
{
|
|
|
_STARPU_MPI_LOG_IN();
|
|
|
|
|
|
- _starpu_mpi_isend_common(data_handle, dest, data_tag, comm, 1, 1, callback, arg, 1);
|
|
|
+ _starpu_mpi_isend_common(data_handle, dest, data_tag, comm, 1, 1, prio, callback, arg, 1);
|
|
|
|
|
|
_STARPU_MPI_LOG_OUT();
|
|
|
return 0;
|
|
|
}
|
|
|
+int starpu_mpi_issend_detached(starpu_data_handle_t data_handle, int dest, int data_tag, MPI_Comm comm, void (*callback)(void *), void *arg)
|
|
|
+{
|
|
|
+ return starpu_mpi_issend_detached_prio(data_handle, dest, data_tag, 0, comm, callback, arg);
|
|
|
+}
|
|
|
|
|
|
/********************************************************/
|
|
|
/* */
|
|
@@ -670,7 +694,7 @@ static void _starpu_mpi_irecv_data_func(struct _starpu_mpi_req *req)
|
|
|
|
|
|
static struct _starpu_mpi_req *_starpu_mpi_irecv_common(starpu_data_handle_t data_handle, int source, int data_tag, MPI_Comm comm, unsigned detached, unsigned sync, void (*callback)(void *), void *arg, int sequential_consistency, int is_internal_req, starpu_ssize_t count)
|
|
|
{
|
|
|
- return _starpu_mpi_isend_irecv_common(data_handle, source, data_tag, comm, detached, sync, callback, arg, RECV_REQ, _starpu_mpi_irecv_data_func, STARPU_W, sequential_consistency, is_internal_req, count);
|
|
|
+ return _starpu_mpi_isend_irecv_common(data_handle, source, data_tag, comm, detached, sync, 0, callback, arg, RECV_REQ, _starpu_mpi_irecv_data_func, STARPU_W, sequential_consistency, is_internal_req, count);
|
|
|
}
|
|
|
|
|
|
int starpu_mpi_irecv(starpu_data_handle_t data_handle, starpu_mpi_req *public_req, int source, int data_tag, MPI_Comm comm)
|
|
@@ -795,6 +819,7 @@ int starpu_mpi_wait(starpu_mpi_req *public_req, MPI_Status *status)
|
|
|
|
|
|
/* Initialize the request structure */
|
|
|
_starpu_mpi_request_init(&waiting_req);
|
|
|
+ waiting_req->prio = INT_MAX;
|
|
|
waiting_req->status = status;
|
|
|
waiting_req->other_request = req;
|
|
|
waiting_req->func = _starpu_mpi_wait_func;
|
|
@@ -886,6 +911,7 @@ int starpu_mpi_test(starpu_mpi_req *public_req, int *flag, MPI_Status *status)
|
|
|
|
|
|
/* Initialize the request structure */
|
|
|
_starpu_mpi_request_init(&testing_req);
|
|
|
+ testing_req->prio = INT_MAX;
|
|
|
testing_req->flag = flag;
|
|
|
testing_req->status = status;
|
|
|
testing_req->other_request = req;
|
|
@@ -978,6 +1004,7 @@ int _starpu_mpi_barrier(MPI_Comm comm)
|
|
|
|
|
|
/* Initialize the request structure */
|
|
|
_starpu_mpi_request_init(&barrier_req);
|
|
|
+ barrier_req->prio = INT_MAX;
|
|
|
barrier_req->func = _starpu_mpi_barrier_func;
|
|
|
barrier_req->request_type = BARRIER_REQ;
|
|
|
barrier_req->node_tag.comm = comm;
|
|
@@ -1316,7 +1343,7 @@ static void _starpu_mpi_receive_early_data(struct _starpu_mpi_envelope *envelope
|
|
|
|
|
|
// Handle the request immediatly to make sure the mpi_irecv is
|
|
|
// posted before receiving an other envelope
|
|
|
- _starpu_mpi_req_list_erase(&ready_requests, early_data_handle->req);
|
|
|
+ _starpu_mpi_req_prio_list_erase(&ready_requests, early_data_handle->req);
|
|
|
STARPU_PTHREAD_MUTEX_UNLOCK(&progress_mutex);
|
|
|
_starpu_mpi_handle_ready_request(early_data_handle->req);
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&progress_mutex);
|
|
@@ -1392,13 +1419,13 @@ static void *_starpu_mpi_progress_thread_func(void *arg)
|
|
|
|
|
|
int envelope_request_submitted = 0;
|
|
|
|
|
|
- while (running || posted_requests || !(_starpu_mpi_req_list_empty(&ready_requests)) || !(_starpu_mpi_req_list_empty(&detached_requests)))// || !(_starpu_mpi_early_request_count()) || !(_starpu_mpi_sync_data_count()))
|
|
|
+ while (running || posted_requests || !(_starpu_mpi_req_prio_list_empty(&ready_requests)) || !(_starpu_mpi_req_list_empty(&detached_requests)))// || !(_starpu_mpi_early_request_count()) || !(_starpu_mpi_sync_data_count()))
|
|
|
{
|
|
|
#ifdef STARPU_SIMGRID
|
|
|
starpu_pthread_wait_reset(&wait);
|
|
|
#endif
|
|
|
/* shall we block ? */
|
|
|
- unsigned block = _starpu_mpi_req_list_empty(&ready_requests) && _starpu_mpi_early_request_count() == 0 && _starpu_mpi_sync_data_count() == 0 && _starpu_mpi_req_list_empty(&detached_requests);
|
|
|
+ unsigned block = _starpu_mpi_req_prio_list_empty(&ready_requests) && _starpu_mpi_early_request_count() == 0 && _starpu_mpi_sync_data_count() == 0 && _starpu_mpi_req_list_empty(&detached_requests);
|
|
|
|
|
|
if (block)
|
|
|
{
|
|
@@ -1415,7 +1442,7 @@ static void *_starpu_mpi_progress_thread_func(void *arg)
|
|
|
|
|
|
/* get one request */
|
|
|
int n = 0;
|
|
|
- while (!_starpu_mpi_req_list_empty(&ready_requests))
|
|
|
+ while (!_starpu_mpi_req_prio_list_empty(&ready_requests))
|
|
|
{
|
|
|
struct _starpu_mpi_req *req;
|
|
|
|
|
@@ -1423,7 +1450,7 @@ static void *_starpu_mpi_progress_thread_func(void *arg)
|
|
|
/* Already spent some time on submitting ready requests, poll before processing more ready requests */
|
|
|
break;
|
|
|
|
|
|
- req = _starpu_mpi_req_list_pop_back(&ready_requests);
|
|
|
+ req = _starpu_mpi_req_prio_list_pop_back(&ready_requests);
|
|
|
|
|
|
/* handling a request is likely to block for a while
|
|
|
* (on a sync_data_with_mem call), we want to let the
|
|
@@ -1585,7 +1612,7 @@ static void *_starpu_mpi_progress_thread_func(void *arg)
|
|
|
#endif
|
|
|
|
|
|
STARPU_MPI_ASSERT_MSG(_starpu_mpi_req_list_empty(&detached_requests), "List of detached requests not empty");
|
|
|
- STARPU_MPI_ASSERT_MSG(_starpu_mpi_req_list_empty(&ready_requests), "List of ready requests not empty");
|
|
|
+ STARPU_MPI_ASSERT_MSG(_starpu_mpi_req_prio_list_empty(&ready_requests), "List of ready requests not empty");
|
|
|
STARPU_MPI_ASSERT_MSG(posted_requests == 0, "Number of posted request is not zero");
|
|
|
_starpu_mpi_early_request_check_termination();
|
|
|
_starpu_mpi_early_data_check_termination();
|
|
@@ -1647,7 +1674,7 @@ int _starpu_mpi_progress_init(struct _starpu_mpi_argc_argv *argc_argv)
|
|
|
STARPU_PTHREAD_MUTEX_INIT(&progress_mutex, NULL);
|
|
|
STARPU_PTHREAD_COND_INIT(&progress_cond, NULL);
|
|
|
STARPU_PTHREAD_COND_INIT(&barrier_cond, NULL);
|
|
|
- _starpu_mpi_req_list_init(&ready_requests);
|
|
|
+ _starpu_mpi_req_prio_list_init(&ready_requests);
|
|
|
|
|
|
STARPU_PTHREAD_MUTEX_INIT(&detached_requests_mutex, NULL);
|
|
|
_starpu_mpi_req_list_init(&detached_requests);
|