#if HAVE_PAPI
typedef std::vector<std::pair</* counter name */ std::string, /* counter value */ long long>> papi_counter_t;
+struct papi_process_data {
+ papi_counter_t counter_data;
+ int event_set;
+};
+extern std::map</* computation unit name */ std::string, papi_process_data> units2papi_setup;
#endif
extern std::unordered_map<std::string, double> location2speedup;
TRACE_smpi_setup_container(rank, sg_host_self());
#if HAVE_PAPI
- container_t container = simgrid::instr::Container::by_name(str);
+ container_t container = smpi_container(rank);
papi_counter_t counters = smpi_process()->papi_counters();
for (auto const& it : counters) {
* Check whether this variable already exists or not. Otherwise, it will be created
* multiple times but only the last one would be used...
*/
- if (s_type::getOrNull(it.first.c_str(), container->type_) == nullptr) {
- Type::variableNew(it.first.c_str(), "", container->type_);
- }
+ container->type_->by_name_or_create(it.first, "");
}
#endif
}
* An MPI function has been called and now is the right time to update
* our PAPI counters for this process.
*/
- if (simgrid::config::get_value<std::string>("smpi/papi-events")[0] != '\0') {
+ if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
papi_counter_t& counter_data = smpi_process()->papi_counters();
int event_set = smpi_process()->papi_event_set();
std::vector<long long> event_values = std::vector<long long>(counter_data.size());
}
#if HAVE_PAPI
- if (simgrid::config::get_value<std::string>("smpi/papi-events")[0] != '\0' && TRACE_smpi_is_enabled()) {
+ if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty() && TRACE_smpi_is_enabled()) {
container_t container =
- new simgrid::instr::Container(std::string("rank-") + std::to_string(simgrid::s4u::this_actor::get_pid()));
+ simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(simgrid::s4u::this_actor::get_pid()));
papi_counter_t& counter_data = smpi_process()->papi_counters();
for (auto const& pair : counter_data) {
- new simgrid::instr::SetVariableEvent(
- surf_get_clock(), container, PJ_type_get(/* countername */ pair.first.c_str(), container->type), pair.second);
+ simgrid::instr::VariableType* variable = static_cast<simgrid::instr::VariableType*>(container->type_->by_name(pair.first));
+ variable->set_event(surf_get_clock(), pair.second);
}
}
#endif
#if HAVE_PAPI
#include "papi.h"
-const char* papi_default_config_name = "default";
-
-struct papi_process_data {
- papi_counter_t counter_data;
- int event_set;
-};
+std::string papi_default_config_name = "default";
+std::map</* computation unit name */ std::string, papi_process_data> units2papi_setup;
#endif
using simgrid::s4u::Actor;
// This map holds for each computation unit (such as "default" or "process1" etc.)
// the configuration as given by the user (counter data as a pair of (counter_name, counter_counter))
// and the (computed) event_set.
- std::map</* computation unit name */ std::string, papi_process_data> units2papi_setup;
if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT)
XBT_ERROR("Could not initialize PAPI library; is it correctly installed and linked?"
- " Expected version is %i",
- PAPI_VER_CURRENT);
+ " Expected version is %u", PAPI_VER_CURRENT);
typedef boost::tokenizer<boost::char_separator<char>> Tokenizer;
boost::char_separator<char> separator_units(";");
#include "src/msg/msg_private.hpp"
#include "src/simix/smx_private.hpp"
+#if HAVE_PAPI
+#include "papi.h"
+extern std::string papi_default_config_name;
+#endif
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_process, smpi, "Logging specific to SMPI (kernel)");
namespace simgrid{
MC_ignore_heap(timer_, xbt_os_timer_size());
#if HAVE_PAPI
- if (simgrid::config::get_value<std::string>("smpi/papi-events")[0] != '\0') {
+ if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
// TODO: Implement host/process/thread based counters. This implementation
// just always takes the values passed via "default", like this:
// "default:COUNTER1:COUNTER2:COUNTER3;".
if (it != units2papi_setup.end()) {
papi_event_set_ = it->second.event_set;
papi_counter_data_ = it->second.counter_data;
- XBT_DEBUG("Setting PAPI set for process %i", i);
+ XBT_DEBUG("Setting PAPI set for process %li", actor->get_pid());
} else {
papi_event_set_ = PAPI_NULL;
- XBT_DEBUG("No PAPI set for process %i", i);
+ XBT_DEBUG("No PAPI set for process %li", actor->get_pid());
}
}
#endif