Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sonar code smells
[simgrid.git] / include / smpi / smpi.h
index e5209d4..0322577 100644 (file)
@@ -17,6 +17,7 @@
 #include <xbt/misc.h>
 
 #ifdef __cplusplus
+#include <functional>
 #include <vector>
 #endif
 
@@ -1048,8 +1049,9 @@ MPI_CALL(XBT_PUBLIC int, MPI_Dist_graph_create, (MPI_Comm comm_old, int n, const
                           const int* weights, MPI_Info info, int reorder, MPI_Comm* comm_dist_graph));
 MPI_CALL(XBT_PUBLIC int, MPI_Dist_graph_create_adjacent, (MPI_Comm comm_old, int indegree, const int* sources, const int* sourceweights,
                           int outdegree, const int* destinations, const int* destweights, MPI_Info info, int reorder, MPI_Comm* comm_dist_graph));
-MPI_CALL(XBT_PUBLIC int, MPI_Dist_graph_neighbors, (MPI_Comm comm, int maxindegree, int* sources, int* sourceweights, 
-                          int maxoutdegree, int* destinations, int* destweights));
+MPI_CALL(XBT_PUBLIC int, MPI_Dist_graph_neighbors,
+         (MPI_Comm comm, int maxindegree, int* sources, int* sourceweights, int maxoutdegree, int* destinations,
+          int* destweights));
 MPI_CALL(XBT_PUBLIC int, MPI_Dist_graph_neighbors_count, (MPI_Comm comm, int *indegree, int *outdegree, int *weighted));
 
 MPI_CALL(XBT_PUBLIC int, MPI_Win_test, (MPI_Win win, int* flag));
@@ -1252,6 +1254,27 @@ std::vector<std::pair<size_t, size_t>> merge_private_blocks(const std::vector<st
 /* May be used by S4U simulations to manually initialize SMPI */
 XBT_PUBLIC void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, void* buff,
                                                 size_t buff_size);
+
+/**
+ * @brief Callback to set cost for SMPI operations (send, recv, isend)
+ *
+ * This callback replaces the configuration parameters smpi/or, smpi/os, smpi/ois.
+ * It offers more flexibility for cost functions.
+ *
+ * @param size Size of message being received/sent
+ * @param source Source host
+ * @param dst Destination host
+ */
+using SmpiOpCostCb = std::function<double(size_t size, simgrid::s4u::Host* source, simgrid::s4u::Host* dst)>;
+/** @brief SMPI functions that accept cost functions */
+enum class SmpiOperation { RECV = 2, SEND = 1, ISEND = 0 };
+/**
+ * @brief Register a cost callback for some SMPI function (MPI_Send, MPI_ISend or MPI_Recv)
+ *
+ * @param op SMPI function
+ * @param cb User's callback
+ */
+XBT_PUBLIC void smpi_register_op_cost_callback(SmpiOperation op, const SmpiOpCostCb& cb);
 #endif
 
-#endif 
+#endif