commit fefbba23644a740816523eb61626084b7ce6414c
parent 4a054cc8eeb9a632029c54ae7b4ee9b20ea606ea
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 1 Dec 2021 15:28:43 +0100
Add the mpi_waiting_for_message function
Diffstat:
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/src/sdis_mpi.c b/src/sdis_mpi.c
@@ -93,6 +93,34 @@ mpi_waiting_for_request(struct sdis_device* dev, MPI_Request* req)
}
void
+mpi_waiting_for_message
+ (struct sdis_device* dev,
+ const int iproc,
+ const enum mpi_sdis_message msg,
+ MPI_Status* status)
+{
+ struct timespec t;
+ ASSERT(dev && dev->use_mpi && status);
+
+ /* Setup the suspend time of the process while waiting for a message */
+ t.tv_sec = 0;
+ t.tv_nsec = 10000000; /* 10ms */
+
+ /* Wait for process synchronisation */
+ for(;;) {
+ int flag;
+
+ /* Asynchronously probe for green function data */
+ mutex_lock(dev->mpi_mutex);
+ MPI(Iprobe(iproc, msg, MPI_COMM_WORLD, &flag, status));
+ mutex_unlock(dev->mpi_mutex);
+
+ if(flag) break;
+ nanosleep(&t, NULL);
+ }
+}
+
+void
mpi_barrier(struct sdis_device* dev)
{
MPI_Request req;
diff --git a/src/sdis_mpi.h b/src/sdis_mpi.h
@@ -20,6 +20,8 @@
#error "Invalid inclusion. Stardis-Solver is compiled without MPI support"
#endif
+#include "sdis_c.h"
+
#include <rsys/rsys.h>
#include <mpi.h>
@@ -46,6 +48,15 @@ mpi_waiting_for_request
(struct sdis_device* dev,
MPI_Request* req);
+/* Actively wait for a message from the process iproc */
+extern LOCAL_SYM void
+mpi_waiting_for_message
+ (struct sdis_device* dev,
+ const int iproc,
+ const enum mpi_sdis_message msg,
+ MPI_Status* status);
+
+/* Waiting for all processes */
extern LOCAL_SYM void
mpi_barrier
(struct sdis_device* dev);