-/* 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. */
#include <xbt/misc.h>
#ifdef __cplusplus
+#include <functional>
#include <vector>
#endif
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));
XBT_PUBLIC int smpi_sample_exit(int global, const char* file, const char* tag, int iter_count);
/**
* Need a public setter for SMPI copy_callback function, so users can define
- * their own while still using default SIMIX_copy_callback for S4U copies.
+ * their own while still using default copy callback for S4U copies.
*/
XBT_PUBLIC void smpi_comm_set_copy_data_callback(void (*callback)(smx_activity_t, void*, size_t));
/* 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