|
@@ -24,6 +24,9 @@
|
|
static int mpi_initialized;
|
|
static int mpi_initialized;
|
|
static int src_node_id;
|
|
static int src_node_id;
|
|
|
|
|
|
|
|
+#define STARPU_MPI_MS_MSG_TAG 42
|
|
|
|
+
|
|
|
|
+
|
|
static void _starpu_mpi_set_src_node_id()
|
|
static void _starpu_mpi_set_src_node_id()
|
|
{
|
|
{
|
|
int node_id = starpu_get_env_number("STARPU_MPI_MASTER_NODE");
|
|
int node_id = starpu_get_env_number("STARPU_MPI_MASTER_NODE");
|
|
@@ -65,12 +68,13 @@ int _starpu_mpi_common_mp_init()
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
-void _starpu_mpi_src_mp_deinit()
|
|
|
|
|
|
+void _starpu_mpi_common_mp_deinit()
|
|
{
|
|
{
|
|
MPI_Finalize();
|
|
MPI_Finalize();
|
|
mpi_initialized = 0;
|
|
mpi_initialized = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
int _starpu_mpi_common_is_src_node()
|
|
int _starpu_mpi_common_is_src_node()
|
|
{
|
|
{
|
|
int id_proc;
|
|
int id_proc;
|
|
@@ -78,8 +82,67 @@ int _starpu_mpi_common_is_src_node()
|
|
return id_proc == src_node_id;
|
|
return id_proc == src_node_id;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+int _starpu_mpi_common_get_src_node()
|
|
|
|
+{
|
|
|
|
+ return src_node_id;
|
|
|
|
+}
|
|
|
|
+
|
|
int _starpu_mpi_common_is_mp_initialized()
|
|
int _starpu_mpi_common_is_mp_initialized()
|
|
{
|
|
{
|
|
return mpi_initialized;
|
|
return mpi_initialized;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* common parts to initialize a source or a sink node */
|
|
|
|
+void _starpu_mpi_common_mp_initialize_src_sink(struct _starpu_mp_node *node)
|
|
|
|
+{
|
|
|
|
+ /* TODO : use hwloc */
|
|
|
|
+ node->nb_cores = 4;
|
|
|
|
+
|
|
|
|
+ /* TODO next */
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int _starpu_mpi_common_recv_is_ready(const struct _starpu_mp_node *mp_node)
|
|
|
|
+{
|
|
|
|
+ int res;
|
|
|
|
+ int flag = 0;
|
|
|
|
+
|
|
|
|
+ res = MPI_Iprobe(MPI_ANY_SOURCE, STARPU_MPI_MS_MSG_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
|
|
|
|
+ STARPU_ASSERT_MSG(res == MPI_SUCCESS, "MPI Master/Slave cannot test if we received a message !");
|
|
|
|
+
|
|
|
|
+ return flag;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* SEND to source node */
|
|
|
|
+void _starpu_mpi_common_send(const struct _starpu_mp_node *node, void *msg, int len)
|
|
|
|
+{
|
|
|
|
+ printf("envoi %d B to %d \n", len, node->mp_connection.mpi_remote_nodeid);
|
|
|
|
+ int res;
|
|
|
|
+ res = MPI_Send(msg, len, MPI_BYTE, node->mp_connection.mpi_remote_nodeid, STARPU_MPI_MS_MSG_TAG, MPI_COMM_WORLD);
|
|
|
|
+ STARPU_ASSERT_MSG(res == MPI_SUCCESS, "MPI Master/Slave cannot receive a msg with a size of %d Bytes !", len);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* RECV to source node */
|
|
|
|
+void _starpu_mpi_common_recv(const struct _starpu_mp_node *node, void *msg, int len)
|
|
|
|
+{
|
|
|
|
+ printf("recv %d B from %d \n", len, node->mp_connection.mpi_remote_nodeid);
|
|
|
|
+ int res;
|
|
|
|
+ res = MPI_Recv(msg, len, MPI_BYTE, node->mp_connection.mpi_remote_nodeid, STARPU_MPI_MS_MSG_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|
|
|
+ STARPU_ASSERT_MSG(res == MPI_SUCCESS, "MPI Master/Slave cannot receive a msg with a size of %d Bytes !", len);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* SEND to any node */
|
|
|
|
+void _starpu_mpi_common_send_to_device(const struct _starpu_mp_node *node, int dst_devid, void *msg, int len)
|
|
|
|
+{
|
|
|
|
+ int res;
|
|
|
|
+ res = MPI_Send(msg, len, MPI_BYTE, dst_devid, STARPU_MPI_MS_MSG_TAG, MPI_COMM_WORLD);
|
|
|
|
+ STARPU_ASSERT_MSG(res == MPI_SUCCESS, "MPI Master/Slave cannot receive a msg with a size of %d Bytes !", len);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* RECV to any node */
|
|
|
|
+void _starpu_mpi_common_recv_from_device(const struct _starpu_mp_node *node, int src_devid, void *msg, int len)
|
|
|
|
+{
|
|
|
|
+ int res;
|
|
|
|
+ res = MPI_Recv(msg, len, MPI_BYTE, src_devid, STARPU_MPI_MS_MSG_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|
|
|
+ STARPU_ASSERT_MSG(res == MPI_SUCCESS, "MPI Master/Slave cannot receive a msg with a size of %d Bytes !", len);
|
|
|
|
+}
|