-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2021. 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. */
#ifndef WIN32
#include <sys/mman.h>
#endif
+#include <cerrno>
#include <cmath>
#if HAVE_PAPI
#if HAVE_PAPI
if (not smpi_cfg_papi_events_file().empty() && TRACE_smpi_is_enabled()) {
- const simgrid::instr::Container* container =
+ simgrid::instr::Container* container =
simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(simgrid::s4u::this_actor::get_pid()));
const papi_counter_t& counter_data = smpi_process()->papi_counters();
for (auto const& pair : counter_data) {
- auto* variable = static_cast<simgrid::instr::VariableType*>(container->type_->by_name(pair.first));
- variable->set_event(SIMIX_get_clock(), pair.second);
+ container->get_variable(pair.first)->set_event(SIMIX_get_clock(), pair.second);
}
}
#endif
#if _POSIX_TIMERS > 0
int smpi_clock_gettime(clockid_t clk_id, struct timespec* tp)
{
+ if (not tp) {
+ errno = EFAULT;
+ return -1;
+ }
if (not smpi_process())
return clock_gettime(clk_id, tp);
//there is only one time in SMPI, so clk_id is ignored.
smpi_bench_end();
double now = SIMIX_get_clock();
- if (tp) {
- tp->tv_sec = static_cast<time_t>(now);
- tp->tv_nsec = static_cast<long int>((now - tp->tv_sec) * 1e9);
- }
+ tp->tv_sec = static_cast<time_t>(now);
+ tp->tv_nsec = static_cast<long int>((now - tp->tv_sec) * 1e9);
if (smpi_wtime_sleep > 0)
simgrid::s4u::this_actor::sleep_for(smpi_wtime_sleep);
smpi_bench_begin();