Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / include / smpi / smpi.h
index 6d5245e..e110d69 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -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));
@@ -1148,6 +1150,9 @@ XBT_PUBLIC void smpi_execute_flops_benched(double flops);
 XBT_PUBLIC void smpi_execute(double duration);
 XBT_PUBLIC void smpi_execute_benched(double duration);
 
+XBT_PUBLIC void smpi_bench_begin();
+XBT_PUBLIC void smpi_bench_end();
+
 XBT_PUBLIC unsigned long long smpi_rastro_resolution();
 XBT_PUBLIC unsigned long long smpi_rastro_timestamp();
 XBT_PUBLIC void smpi_sample_1(int global, const char* file, const char* tag, int iters, double threshold);
@@ -1237,7 +1242,7 @@ XBT_PUBLIC void SMPI_thread_create();
 
 SG_END_DECL
 
-/* C++ declarations for shared_malloc */
+/* C++ declarations for shared_malloc and default copy buffer callback */
 #ifdef __cplusplus
 XBT_PUBLIC int smpi_is_shared(const void* ptr, std::vector<std::pair<size_t, size_t>>& private_blocks, size_t* offset);
 
@@ -1245,6 +1250,31 @@ std::vector<std::pair<size_t, size_t>> shift_and_frame_private_blocks(const std:
                                                                       size_t offset, size_t buff_size);
 std::vector<std::pair<size_t, size_t>> merge_private_blocks(const std::vector<std::pair<size_t, size_t>>& src,
                                                             const std::vector<std::pair<size_t, size_t>>& dst);
+
+/* 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