1 /* Copyright (c) 2016-2022. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include "smpi_f2c.hpp"
11 #include "smpi_comm.hpp"
15 #include <string_view>
18 // Methods used to parse and store the values for timing injections in smpi
19 struct s_smpi_factor_t {
21 std::vector<double> values;
24 namespace simgrid::smpi::utils {
27 const std::string& name_;
28 std::vector<s_smpi_factor_t> factors_;
29 double default_value_;
30 const std::function<double(s_smpi_factor_t const&, double)> lambda_;
31 bool initialized_ = false;
34 // Parse the factor from a string
36 const std::string& name, double default_value = 1,
37 std::function<double(s_smpi_factor_t const&, double)> const& lambda = [](s_smpi_factor_t const& factor, double) {
38 return factor.values.front();
40 void parse(const std::string& values);
41 bool is_initialized() const { return initialized_; }
42 // Get the default factor, the one that is not a function of the size
44 // Get the factor to use for the provided size
45 double operator()(double size);
47 XBT_PUBLIC std::vector<s_smpi_factor_t> parse_factor(const std::string& smpi_coef_string);
48 XBT_PUBLIC void add_benched_time(double time);
49 XBT_PUBLIC void account_malloc_size(size_t size, std::string_view file, int line, const void* ptr);
50 XBT_PUBLIC void account_shared_size(size_t size);
51 XBT_PUBLIC void print_time_analysis(double time);
52 XBT_PUBLIC void print_buffer_info();
53 XBT_PUBLIC void print_memory_analysis();
54 XBT_PUBLIC void print_current_handle();
55 XBT_PUBLIC void set_current_handle(F2C* handle);
56 XBT_PUBLIC void set_current_buffer(int i, const char* name, const void* handle);
57 XBT_PUBLIC size_t get_buffer_size(const void* ptr);
58 XBT_PUBLIC void account_free(const void* ptr);
59 XBT_PUBLIC int check_collectives_ordering(MPI_Comm comm, const std::string& call);
61 } // namespace simgrid::smpi::utils