examples/cpp/exec-dependent/s4u-exec-dependent
examples/cpp/exec-dvfs/s4u-exec-dvfs
examples/cpp/exec-ptask/s4u-exec-ptask
+examples/cpp/exec-ptask-multicore/s4u-exec-ptask-multicore
examples/cpp/exec-remote/s4u-exec-remote
examples/cpp/exec-unassigned/s4u-exec-unassigned
examples/cpp/exec-waitany/s4u-exec-waitany
- New section: Configuring the logs from the command line.
- New section: Programming API of logs.
+Fixed bugs (FG#.. -> FramaGit bugs; FG!.. -> FG merge requests)
+ (FG: issues on Framagit; GF: issues on GForge; GH: issues on GitHub)
+- FG#37: Parallel tasks are limited to 1 core per host
+
----------------------------------------------------------------------------
SimGrid (3.26) December 15. 2020
include examples/cpp/exec-dependent/s4u-exec-dependent.tesh
include examples/cpp/exec-dvfs/s4u-exec-dvfs.cpp
include examples/cpp/exec-dvfs/s4u-exec-dvfs.tesh
+include examples/cpp/exec-ptask-multicore/s4u-exec-ptask-multicore.cpp
+include examples/cpp/exec-ptask-multicore/s4u-exec-ptask-multicore.tesh
include examples/cpp/exec-ptask/s4u-exec-ptask.cpp
include examples/cpp/exec-ptask/s4u-exec-ptask.tesh
include examples/cpp/exec-remote/s4u-exec-remote.cpp
dht-chord dht-kademlia
energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
engine-filtering
- exec-async exec-basic exec-dvfs exec-ptask exec-remote exec-waitany exec-waitfor exec-dependent exec-unassigned
+ exec-async exec-basic exec-dvfs exec-remote exec-waitany exec-waitfor exec-dependent exec-unassigned
+ exec-ptask exec-ptask-multicore
maestro-set
mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert
- network-wifi
+ network-wifi
io-async io-file-system io-file-remote io-disk-raw io-dependent
platform-failures platform-profile platform-properties
plugin-host-load plugin-link-load
: prev_(prev), next_(next), num_pieces(num_pieces)
{
}
- ~ChainMessage() = default;
};
class FilePiece {
public:
FilePiece() = default;
- ~FilePiece() = default;
};
class Peer {
unsigned int total_pieces = 0;
Peer() { me = simgrid::s4u::Mailbox::by_name(simgrid::s4u::Host::current()->get_cname()); }
- ~Peer() = default;
void joinChain()
{
mailboxes.push_back(simgrid::s4u::Mailbox::by_name(name));
}
}
-
- ~Broadcaster() = default;
};
static void peer()
public:
explicit Answer(unsigned int destination_id) : destination_id_(destination_id) {}
- virtual ~Answer() = default;
unsigned int getDestinationId() const { return destination_id_; }
size_t getSize() const { return nodes_.size(); }
const std::vector<std::pair<unsigned int, unsigned int>>& getNodes() const { return nodes_; }
--- /dev/null
+/* Copyright (c) 2017-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. */
+
+#include <simgrid/s4u.hpp>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_ptask_multicore, "Messages specific for this s4u example");
+
+namespace sg4 = simgrid::s4u;
+
+static void runner()
+{
+ auto e = sg4::Engine::get_instance();
+ std::vector<double> comp(2, 1e9);
+ std::vector<double> comm(4, 0.0);
+ // Different hosts.
+ std::vector<sg4::Host*> hosts_diff = {e->host_by_name("MyHost2"), e->host_by_name("MyHost3")};
+ double start_time = e->get_clock();
+ sg4::this_actor::parallel_execute(hosts_diff, comp, comm);
+ XBT_INFO("Computed 2-core activity on two different hosts. Took %g s", e->get_clock() - start_time);
+
+ // Same host, monocore.
+ std::vector<sg4::Host*> monocore_hosts = {e->host_by_name("MyHost2"), e->host_by_name("MyHost2")};
+ start_time = e->get_clock();
+ sg4::this_actor::parallel_execute(monocore_hosts, comp, comm);
+ XBT_INFO("Computed 2-core activity one 1-core host. Took %g s", e->get_clock() - start_time);
+
+ // Same host, multicore.
+ std::vector<sg4::Host*> multicore_host = {e->host_by_name("MyHost1"), e->host_by_name("MyHost1")};
+ start_time = e->get_clock();
+ sg4::this_actor::parallel_execute(multicore_host, comp, comm);
+ XBT_INFO("Computed 2-core activity on one 2-core host. Took %g s", e->get_clock() - start_time);
+
+ // Same host, using too many cores
+ std::vector<double> comp6(6, 1e9);
+ std::vector<double> comm6(36, 0.0);
+ std::vector<sg4::Host*> multicore_overload(6, e->host_by_name("MyHost1"));
+ start_time = e->get_clock();
+ sg4::this_actor::parallel_execute(multicore_overload, comp6, comm6);
+ XBT_INFO("Computed 6-core activity of a 4-core host. Took %g s", e->get_clock() - start_time);
+}
+
+int main(int argc, char* argv[])
+{
+ sg4::Engine e(&argc, argv);
+
+ xbt_assert(argc == 2, "Usage: %s <platform file>", argv[0]);
+
+ e.load_platform(argv[1]);
+ sg4::Actor::create("test", sg4::Host::by_name("MyHost1"), runner);
+
+ e.run();
+ XBT_INFO("Simulation done.");
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-exec-ptask-multicore ${platfdir}/energy_platform.xml --cfg=host/model:ptask_L07 --log=no_loc "--log=root.fmt:[%10.6r]%e%m%n"
+> [ 0.000000] Configuration change: Set 'host/model' to 'ptask_L07'
+> [ 0.000000] Switching to the L07 model to handle parallel tasks.
+> [ 10.000000] Computed 2-core activity on two different hosts. Took 10 s
+> [ 30.000000] Computed 2-core activity one 1-core host. Took 20 s
+> [ 40.000000] Computed 2-core activity on one 2-core host. Took 10 s
+> [ 55.000000] Computed 6-core activity of a 4-core host. Took 15 s
+> [ 55.000000] Simulation done.
\ No newline at end of file
public:
Future() = default;
explicit Future(std::shared_ptr<FutureState<T>> state) : state_(std::move(state)) {}
- ~Future() = default;
// Move type:
Future(Future&) = delete;
profile::Event* state_event_ = nullptr;
public:
- Resource(const std::string& name) : name_(name){};
+ explicit Resource(const std::string& name) : name_(name){};
virtual ~Resource() = default;
virtual void seal() { sealed_ = true; }
enum class Type { Host, Router, NetZone };
NetPoint(const std::string& name, NetPoint::Type component_type, NetZoneImpl* netzone_p);
- ~NetPoint() = default;
// Our rank in the vertices_ array of the netzone that contains us.
unsigned int id() const { return id_; }
public:
static xbt::Extension<NetPoint, Coords> EXTENSION_ID;
explicit Coords(NetPoint* host, const std::string& str);
- virtual ~Coords() = default;
std::vector<double> coords;
};
explicit WifiZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel);
WifiZone(const WifiZone&) = delete;
WifiZone& operator=(const WifiZone) = delete;
- ~WifiZone() override = default;
void seal() override;
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
/** Creates a barrier for the given amount of actors */
explicit Barrier(unsigned int expected_actors) : expected_actors_(expected_actors) {}
#ifndef DOXYGEN
- ~Barrier() = default;
Barrier(Barrier const&) = delete;
Barrier& operator=(Barrier const&) = delete;
#endif
explicit Exec(kernel::activity::ExecImplPtr pimpl);
public:
- ~Exec() override = default;
#ifndef DOXYGEN
Exec(Exec const&) = delete;
Exec& operator=(Exec const&) = delete;
-
#endif
static xbt::signal<void(Exec const&)> on_start;
static xbt::signal<void(Exec const&)> on_completion;
public:
#ifndef DOXYGEN
friend Disk; // Factory of IOs
-
- ~Io() override = default;
#endif
static xbt::signal<void(Io const&)> on_start;
SG_BEGIN_DECL
XBT_ATTRIB_DEPRECATED_v330("Please use sg_mutex_init()") XBT_PUBLIC smx_mutex_t simcall_mutex_init();
XBT_PUBLIC void simcall_mutex_lock(smx_mutex_t mutex);
-XBT_PUBLIC int simcall_mutex_trylock(smx_mutex_t mutex);
-XBT_ATTRIB_DEPRECATED_v331("Please use s4u::Mutex::unlock()") XBT_PUBLIC void simcall_mutex_unlock(smx_mutex_t mutex);
+XBT_ATTRIB_DEPRECATED_v331("Please use sg_mutex_try_lock()") XBT_PUBLIC int simcall_mutex_trylock(smx_mutex_t mutex);
+XBT_ATTRIB_DEPRECATED_v331("Please use sg_mutex_unlock()") XBT_PUBLIC void simcall_mutex_unlock(smx_mutex_t mutex);
XBT_ATTRIB_DEPRECATED_v330("Please use sg_cond_init()") XBT_PUBLIC smx_cond_t simcall_cond_init();
XBT_PUBLIC void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex);
#endif
/************************** MC simcalls **********************************/
SG_BEGIN_DECL
-XBT_ATTRIB_DEPRECATED_v331("Please use MC_random") XBT_PUBLIC int simcall_mc_random(int min, int max);
+XBT_ATTRIB_DEPRECATED_v331("Please use MC_random()") XBT_PUBLIC int simcall_mc_random(int min, int max);
SG_END_DECL
#endif
: Type(event_type, name, alias, "", father){};
ValueType(PajeEventType event_type, const std::string& name, Type* father)
: Type(event_type, name, name, "", father){};
- ~ValueType() override = default;
void add_entity_value(const std::string& name, const std::string& color);
void add_entity_value(const std::string& name);
EntityValue* get_entity_value(const std::string& name);
public:
ConditionVariableImpl() : piface_(this){};
- ~ConditionVariableImpl() = default;
void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
const s4u::ConditionVariable* get_iface() const { return &piface_; }
{
mutex->lock(simcall->issuer_);
}
-
-int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex)
-{
- return mutex->try_lock(simcall->issuer_);
-}
public:
explicit SemaphoreImpl(unsigned int value) : value_(value){};
- ~SemaphoreImpl() = default;
SemaphoreImpl(SemaphoreImpl const&) = delete;
SemaphoreImpl& operator=(SemaphoreImpl const&) = delete;
auto* res = new s4u::Host(name);
res->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
- surf_cpu_model_pm->create_cpu(res, speed_per_pstate, core_amount);
+ surf_cpu_model_pm->create_cpu(res, speed_per_pstate)->set_core_count(core_amount)->seal();
return res;
}
int original_num = -1; // num field of the VisitedState to which I was declared equal to (used for dot_output)
explicit VisitedState(unsigned long state_number);
- ~VisitedState() = default;
};
class XBT_PRIVATE VisitedStates {
req = &actor->simcall_;
break;
- case Simcall::COMM_TESTANY: {
+ case Simcall::COMM_TESTANY:
state->transition_.times_considered_ = -1;
while (procstate->times_considered < simcall_comm_testany__get__count(&actor->simcall_)) {
if (simgrid::mc::request_is_enabled_by_idx(&actor->simcall_, procstate->times_considered)) {
if (state->transition_.times_considered_ != -1)
req = &actor->simcall_;
break;
- }
case Simcall::COMM_WAIT: {
simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> remote_act =
unsigned long Api::get_maxpid() const
{
+ static const char* name = nullptr;
+ if (not name) {
+ name = "simgrid::kernel::actor::maxpid";
+ if (mc_model_checker->get_remote_simulation().find_variable(name) == nullptr)
+ name = "maxpid"; // We seem to miss the namespaces when compiling with GCC
+ }
unsigned long maxpid;
- const char* name = "simgrid::kernel::actor::maxpid";
- if (mc_model_checker->get_remote_simulation().find_variable(name) == nullptr)
- name = "maxpid"; // We seem to miss the namespaces when compiling with GCC
mc_model_checker->get_remote_simulation().read_variable(name, &maxpid, sizeof(maxpid));
return maxpid;
}
}
break;
- case Simcall::MUTEX_TRYLOCK:
case Simcall::MUTEX_LOCK: {
- if (req->call_ == Simcall::MUTEX_LOCK)
- type = "Mutex LOCK";
- else
- type = "Mutex TRYLOCK";
-
+ type = "Mutex LOCK";
simgrid::mc::Remote<simgrid::kernel::activity::MutexImpl> mutex;
mc_model_checker->get_remote_simulation().read_bytes(mutex.get_buffer(), sizeof(mutex),
- remote(req->call_ == Simcall::MUTEX_LOCK
- ? simcall_mutex_lock__get__mutex(req)
- : simcall_mutex_trylock__get__mutex(req)));
+ remote(simcall_mutex_lock__get__mutex(req)));
args = "locked = " + std::to_string(mutex.get_buffer()->is_locked()) + ", owner = ";
if (mutex.get_buffer()->get_owner() != nullptr)
args += std::to_string(mc_model_checker->get_remote_simulation()
}
break;
- case Simcall::MUTEX_TRYLOCK:
- label = "[" + get_actor_dot_label(issuer) + "] Mutex TRYLOCK";
- break;
-
case Simcall::MUTEX_LOCK:
label = "[" + get_actor_dot_label(issuer) + "] Mutex LOCK";
break;
for (size_t i = 0; i < initial_communications_pattern.size(); i++)
initial_communications_pattern[i].index_comm = state->communication_indices_[i];
- for (unsigned long i = 0; i < api::get().get_maxpid(); i++)
+ const unsigned long maxpid = api::get().get_maxpid();
+ for (unsigned long i = 0; i < maxpid; i++)
patterns_copy(incomplete_communications_pattern[i], state->incomplete_comm_pattern_[i]);
}
void CommunicationDeterminismChecker::prepare()
{
- const auto maxpid = api::get().get_maxpid();
+ const unsigned long maxpid = api::get().get_maxpid();
initial_communications_pattern.resize(maxpid);
incomplete_communications_pattern.resize(maxpid);
static inline bool all_communications_are_finished()
{
- auto maxpid = api::get().get_maxpid();
+ const unsigned long maxpid = api::get().get_maxpid();
for (size_t current_actor = 1; current_actor < maxpid; current_actor++) {
if (not incomplete_communications_pattern[current_actor].empty()) {
XBT_DEBUG("Some communications are not finished, cannot stop the exploration! State not visited.");
/* Restore the initial state */
api::get().restore_initial_state();
- unsigned long n = api::get().get_maxpid();
- assert(n == incomplete_communications_pattern.size());
- assert(n == initial_communications_pattern.size());
- for (unsigned long j = 0; j < n; j++) {
+ const unsigned long maxpid = api::get().get_maxpid();
+ assert(maxpid == incomplete_communications_pattern.size());
+ assert(maxpid == initial_communications_pattern.size());
+ for (unsigned long j = 0; j < maxpid; j++) {
incomplete_communications_pattern[j].clear();
initial_communications_pattern[j].index_comm = 0;
}
bool exploration_started = false;
explicit Pair(unsigned long expanded_pairs);
- ~Pair() = default;
Pair(Pair const&) = delete;
Pair& operator=(Pair const&) = delete;
VisitedPair(int pair_num, xbt_automaton_state_t automaton_state,
std::shared_ptr<const std::vector<int>> atomic_propositions, std::shared_ptr<State> graph_state);
- ~VisitedPair() = default;
};
class XBT_PRIVATE LivenessChecker : public Checker {
public:
explicit LivenessChecker();
- ~LivenessChecker() override = default;
void run() override;
RecordTrace get_record_trace() override;
std::vector<std::string> get_textual_trace() override;
if (reductionMode_ == ReductionMode::dpor) {
auto call = state->executed_req_.call_;
const kernel::actor::ActorImpl* issuer = api::get().simcall_get_issuer(&state->executed_req_);
- if (call == simix::Simcall::MUTEX_LOCK || call == simix::Simcall::MUTEX_TRYLOCK)
+ if (call == simix::Simcall::MUTEX_LOCK)
xbt_die("Mutex is currently not supported with DPOR, use --cfg=model-check/reduction:none");
for (auto i = stack_.rbegin(); i != stack_.rend(); ++i) {
public:
explicit SafetyChecker();
- ~SafetyChecker() override = default;
void run() override;
RecordTrace get_record_trace() override;
std::vector<std::string> get_textual_trace() override;
#include "src/mc/checker/SimcallObserver.hpp"
#include "simgrid/s4u/Host.hpp"
+#include "src/kernel/activity/MutexImpl.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_observer, mc, "Logging specific to MC simcall observation");
return SimcallObserver::dot_label() + "Mutex UNLOCK";
}
+std::string MutexTrylockSimcall::to_string(int time_considered) const
+{
+ std::string res = SimcallObserver::to_string(time_considered) + "Mutex TRYLOCK";
+ res += "(locked = " + std::to_string(mutex_->is_locked());
+ res += ", owner = " + std::to_string(mutex_->get_owner() ? mutex_->get_owner()->get_pid() : -1);
+ res += ", sleeping = n/a)";
+ return res;
+}
+
+std::string MutexTrylockSimcall::dot_label() const
+{
+ return SimcallObserver::dot_label() + "Mutex TRYLOCK";
+}
+
} // namespace mc
} // namespace simgrid
std::string to_string(int times_considered) const override;
std::string dot_label() const override;
};
+
+class MutexTrylockSimcall : public SimcallObserver {
+ kernel::activity::MutexImpl* mutex_;
+
+public:
+ MutexTrylockSimcall(smx_actor_t actor, kernel::activity::MutexImpl* mutex) : SimcallObserver(actor), mutex_(mutex) {}
+ std::string to_string(int times_considered) const override;
+ std::string dot_label() const override;
+ kernel::activity::MutexImpl* get_mutex() const { return mutex_; }
+};
} // namespace mc
} // namespace simgrid
class XBT_PRIVATE UdporChecker : public Checker {
public:
explicit UdporChecker();
- ~UdporChecker() override = default;
void run() override;
RecordTrace get_record_trace() override;
std::vector<std::string> get_textual_trace() override;
using simix::Simcall;
return req->call_ == Simcall::COMM_ISEND || req->call_ == Simcall::COMM_IRECV || req->call_ == Simcall::COMM_WAIT ||
req->call_ == Simcall::COMM_WAITANY || req->call_ == Simcall::COMM_TEST ||
- req->call_ == Simcall::COMM_TESTANY || req->call_ == Simcall::MUTEX_LOCK ||
- req->call_ == Simcall::MUTEX_TRYLOCK;
+ req->call_ == Simcall::COMM_TESTANY || req->call_ == Simcall::MUTEX_LOCK;
}
}
State::State(unsigned long state_number) : num_(state_number)
{
- auto maxpid = api::get().get_maxpid();
+ const unsigned long maxpid = api::get().get_maxpid();
actor_states_.resize(maxpid);
/* Stateful model checking */
if ((_sg_mc_checkpoint > 0 && (state_number % _sg_mc_checkpoint == 0)) || _sg_mc_termination) {
void State::copy_incomplete_comm_pattern()
{
incomplete_comm_pattern_.clear();
- for (unsigned long i = 0; i < api::get().get_maxpid(); i++) {
+ const unsigned long maxpid = api::get().get_maxpid();
+ for (unsigned long i = 0; i < maxpid; i++) {
std::vector<simgrid::mc::PatternCommunication> res;
for (auto const& comm : incomplete_communications_pattern[i])
res.push_back(comm->dup());
RemotePtr<kernel::actor::ActorImpl> address{nullptr};
Remote<kernel::actor::ActorImpl> copy;
- /** Hostname (owned by `mc_modelchecker->hostnames`) */
+ /** Hostname (owned by `mc_model_checker->hostnames_`) */
const xbt::string* hostname = nullptr;
std::string name;
public:
Region(RegionType type, void* start_addr, size_t size);
- ~Region() = default;
Region(Region const&) = delete;
Region& operator=(Region const&) = delete;
Region(Region&& that) = delete;
public:
/* Initialization */
Snapshot(int num_state, RemoteSimulation* get_remote_simulation = &mc_model_checker->get_remote_simulation());
- ~Snapshot() override = default;
/* Regular use */
bool on_heap(const void* address) const
Configuration(const Configuration&) = default;
Configuration& operator=(Configuration const&) = default;
Configuration(Configuration&&) = default;
- ~Configuration() = default;
};
class UnfoldingEvent {
UnfoldingEvent(const UnfoldingEvent&) = default;
UnfoldingEvent& operator=(UnfoldingEvent const&) = default;
UnfoldingEvent(UnfoldingEvent&&) = default;
- ~UnfoldingEvent() = default;
EventSet getHistory() const;
Task(const Task&) = delete;
Task& operator=(const Task&) = delete;
- ~Task() = default;
bool is_used() const { return is_used_; }
bool is_parallel() const { return parallel_; }
double get_max_downtime() const { return max_downtime_; }
static simgrid::xbt::Extension<VirtualMachineImpl, DirtyPageTrackingExt> EXTENSION_ID;
- virtual ~DirtyPageTrackingExt() = default;
DirtyPageTrackingExt() = default;
};
, current_flops_(host_->get_load())
{
}
- ~HostLoad() = default;
HostLoad() = delete;
explicit HostLoad(simgrid::s4u::Host& ptr) = delete;
explicit HostLoad(simgrid::s4u::Host&& ptr) = delete;
static simgrid::xbt::Extension<simgrid::s4u::Link, LinkEnergy> EXTENSION_ID;
explicit LinkEnergy(simgrid::s4u::Link* ptr) : link_(ptr), last_updated_(surf_get_clock()) {}
- ~LinkEnergy() = default;
void init_watts_range_list();
double get_consumed_energy();
static simgrid::xbt::Extension<simgrid::s4u::Link, LinkEnergyWifi> EXTENSION_ID;
explicit LinkEnergyWifi(simgrid::s4u::Link* ptr) : link_(ptr) {}
-
- ~LinkEnergyWifi() = default;
LinkEnergyWifi() = delete;
/**
static simgrid::xbt::Extension<simgrid::s4u::Link, LinkLoad> EXTENSION_ID;
explicit LinkLoad(simgrid::s4u::Link* ptr);
- ~LinkLoad() = default;
void track();
void untrack();
class VmHostExt {
public:
static simgrid::xbt::Extension<simgrid::s4u::Host, VmHostExt> EXTENSION_ID;
- virtual ~VmHostExt() = default;
sg_size_t ramsize = 0; /* available ramsize (0= not taken into account) */
bool overcommit = true; /* Whether the host allows overcommiting more VM than the avail ramsize allows */
s4u::ActorPtr tx_ = nullptr;
s4u::ActorPtr rx_ = nullptr;
static simgrid::xbt::Extension<simgrid::s4u::Host, VmMigrationExt> EXTENSION_ID;
- virtual ~VmMigrationExt() = default;
explicit VmMigrationExt(s4u::ActorPtr issuer, s4u::ActorPtr rx, s4u::ActorPtr tx) : issuer_(issuer), tx_(tx), rx_(rx)
{
}
for (int i = 0; i < physical_host->get_pstate_count(); i++)
speeds.push_back(physical_host->get_pstate_speed(i));
- surf_cpu_model_vm->create_cpu(this, speeds, core_amount);
+ surf_cpu_model_vm->create_cpu(this, speeds)->set_core_count(core_amount)->seal();
if (physical_host->get_pstate() != 0)
set_pstate(physical_host->get_pstate());
/** @brief Acquire the mutex if it's free, and return false (without blocking) if not */
bool Mutex::try_lock()
{
- return simcall_mutex_trylock(pimpl_);
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
+ mc::MutexTrylockSimcall observer{issuer, pimpl_};
+ return kernel::actor::simcall([&observer] { return observer.get_mutex()->try_lock(observer.get_issuer()); },
+ &observer);
}
/** @brief Create a new mutex
* @ingroup simix_synchro_management
*
*/
-int simcall_mutex_trylock(smx_mutex_t mutex)
+int simcall_mutex_trylock(smx_mutex_t mutex) // XBT_ATTRIB_DEPRECATD_v331
{
- return simcall_BODY_mutex_trylock(mutex);
+ return mutex->mutex().try_lock();
}
/**
simgrid::simix::marshal<smx_mutex_t>(simcall->args_[0], arg);
}
-static inline smx_mutex_t simcall_mutex_trylock__get__mutex(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<smx_mutex_t>(simcall->args_[0]);
-}
-static inline smx_mutex_t simcall_mutex_trylock__getraw__mutex(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<smx_mutex_t>(simcall->args_[0]);
-}
-static inline void simcall_mutex_trylock__set__mutex(smx_simcall_t simcall, smx_mutex_t arg)
-{
- simgrid::simix::marshal<smx_mutex_t>(simcall->args_[0], arg);
-}
-static inline int simcall_mutex_trylock__get__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<int>(simcall->result_);
-}
-static inline int simcall_mutex_trylock__getraw__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<int>(simcall->result_);
-}
-static inline void simcall_mutex_trylock__set__result(smx_simcall_t simcall, int result)
-{
- simgrid::simix::marshal<int>(simcall->result_, result);
-}
-
static inline smx_cond_t simcall_cond_wait__get__cond(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<smx_cond_t>(simcall->args_[0]);
XBT_PRIVATE void simcall_HANDLER_comm_test(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm);
XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms, size_t count);
XBT_PRIVATE void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex);
-XBT_PRIVATE int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex);
XBT_PRIVATE void simcall_HANDLER_cond_wait(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex);
XBT_PRIVATE void simcall_HANDLER_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex, double timeout);
XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem);
return simcall<void, smx_mutex_t>(Simcall::MUTEX_LOCK, mutex);
}
-inline static int simcall_BODY_mutex_trylock(smx_mutex_t mutex)
-{
- if (false) /* Go to that function to follow the code flow through the simcall barrier */
- simcall_HANDLER_mutex_trylock(&SIMIX_process_self()->simcall_, mutex);
- return simcall<int, smx_mutex_t>(Simcall::MUTEX_TRYLOCK, mutex);
-}
-
inline static void simcall_BODY_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
{
if (false) /* Go to that function to follow the code flow through the simcall barrier */
COMM_TEST,
COMM_TESTANY,
MUTEX_LOCK,
- MUTEX_TRYLOCK,
COND_WAIT,
COND_WAIT_TIMEOUT,
SEM_ACQUIRE,
RUN_BLOCKING,
};
-constexpr int NUM_SIMCALLS = 18;
+constexpr int NUM_SIMCALLS = 17;
} // namespace simix
} // namespace simgrid
"Simcall::COMM_TEST",
"Simcall::COMM_TESTANY",
"Simcall::MUTEX_LOCK",
- "Simcall::MUTEX_TRYLOCK",
"Simcall::COND_WAIT",
"Simcall::COND_WAIT_TIMEOUT",
"Simcall::SEM_ACQUIRE",
simcall_HANDLER_mutex_lock(&simcall_, simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[0]));
break;
- case Simcall::MUTEX_TRYLOCK:
- simgrid::simix::marshal<int>(simcall_.result_, simcall_HANDLER_mutex_trylock(&simcall_, simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[0])));
- simcall_answer();
- break;
-
case Simcall::COND_WAIT:
simcall_HANDLER_cond_wait(&simcall_, simgrid::simix::unmarshal<smx_cond_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[1]));
break;
int comm_testany(simgrid::kernel::activity::CommImpl** comms, size_t count) [[block]];
void mutex_lock(smx_mutex_t mutex) [[block]];
-int mutex_trylock(smx_mutex_t mutex);
void cond_wait(smx_cond_t cond, smx_mutex_t mutex) [[block]];
int cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout) [[block]];
int PMPI_Type_get_extent_x(MPI_Datatype datatype, MPI_Count * lb, MPI_Count * extent)
{
- MPI_Aint tmplb, tmpext;
+ MPI_Aint tmplb;
+ MPI_Aint tmpext;
int ret = PMPI_Type_get_extent(datatype, &tmplb, &tmpext);
if(ret == MPI_SUCCESS){
*lb = static_cast<MPI_Count>(tmplb);
static xbt::Extension<s4u::Host, smpi::Host> EXTENSION_ID;
explicit Host(s4u::Host* ptr);
- ~Host() = default;
double orecv(size_t size);
double osend(size_t size);
public:
explicit Info() {this->add_f();}
explicit Info(const Info* orig) : map_(orig->map_) {this->add_f();}
- ~Info() override = default;
void ref();
static void unref(MPI_Info info);
void set(const char* key, const char* value) { map_[key] = value; }
surf_cpu_model_pm = nullptr;
}
-Cpu* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
+Cpu* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
{
- return new CpuCas01(this, host, speed_per_pstate, core);
+ return (new CpuCas01(host, speed_per_pstate))->set_model(this);
}
/************
* Resource *
************/
-CpuCas01::CpuCas01(CpuCas01Model* model, s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
- : Cpu(host, speed_per_pstate)
-{
- this->set_core_count(core)->set_model(model)->set_constraint(
- model->get_maxmin_system()->constraint_new(this, core * speed_per_pstate.front()));
-}
-
-CpuCas01::~CpuCas01() = default;
-
bool CpuCas01::is_used() const
{
return get_model()->get_maxmin_system()->constraint_used(get_constraint());
CpuCas01Model& operator=(const CpuCas01Model&) = delete;
~CpuCas01Model() override;
- Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core) override;
+ Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
};
/************
class CpuCas01 : public Cpu {
public:
- CpuCas01(CpuCas01Model* model, s4u::Host* host, const std::vector<double>& speed_per_pstate, int core);
+ CpuCas01(s4u::Host* host, const std::vector<double>& speed_per_pstate) : Cpu(host, speed_per_pstate) {}
CpuCas01(const CpuCas01&) = delete;
CpuCas01& operator=(const CpuCas01&) = delete;
- ~CpuCas01() override;
void apply_event(profile::Event* event, double value) override;
CpuAction* execution_start(double size) override;
CpuAction* execution_start(double size, int requested_cores) override;
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "cpu_interface.hpp"
+#include "cpu_ti.hpp"
#include "src/kernel/resource/profile/Profile.hpp"
#include "src/surf/surf_interface.hpp"
#include "surf/surf.hpp"
{
xbt_assert(not is_sealed(), "Core count cannot be changed once CPU has been sealed");
xbt_assert(core_count > 0, "Host %s must have at least one core, not 0.", piface_->get_cname());
+ if (dynamic_cast<CpuTiModel*>(get_model()) != nullptr)
+ xbt_assert(core_count == 1, "Multi-core not handled by this model yet");
+
core_count_ = core_count;
return this;
}
void Cpu::seal()
{
+ lmm::System* lmm = get_model()->get_maxmin_system();
+ if (dynamic_cast<CpuTiModel*>(get_model()) == nullptr)
+ this->set_constraint(lmm->constraint_new(this, core_count_ * speed_per_pstate_.front()));
Resource::seal();
}
* This ignores any potential external load coming from a trace.
* @param core The number of core of this Cpu
*/
- virtual Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core) = 0;
+ virtual Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) = 0;
void update_actions_state_lazy(double now, double delta) override;
void update_actions_state_full(double now, double delta) override;
surf_cpu_model_pm = nullptr;
}
-Cpu* CpuTiModel::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
+Cpu* CpuTiModel::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
{
- return new CpuTi(this, host, speed_per_pstate, core);
+ return (new CpuTi(host, speed_per_pstate))->set_model(this);
}
double CpuTiModel::next_occurring_event(double now)
/************
* Resource *
************/
-CpuTi::CpuTi(CpuTiModel* model, s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
- : Cpu(host, speed_per_pstate)
+CpuTi::CpuTi(s4u::Host* host, const std::vector<double>& speed_per_pstate) : Cpu(host, speed_per_pstate)
{
- xbt_assert(core == 1, "Multi-core not handled by this model yet");
- this->set_model(model);
-
speed_.peak = speed_per_pstate.front();
XBT_DEBUG("CPU create: peak=%f", speed_.peak);
************/
class CpuTi : public Cpu {
public:
- CpuTi(CpuTiModel* model, s4u::Host* host, const std::vector<double>& speed_per_pstate, int core);
+ CpuTi(s4u::Host* host, const std::vector<double>& speed_per_pstate);
CpuTi(const CpuTi&) = delete;
CpuTi& operator&(const CpuTi&) = delete;
~CpuTi() override;
CpuTiModel(const CpuTiModel&) = delete;
CpuTiModel& operator=(const CpuTiModel&) = delete;
~CpuTiModel() override;
- Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core) override;
+ Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
double next_occurring_event(double now) override;
void update_actions_state(double now, double delta) override;
class NetworkCm02Model : public NetworkModel {
public:
NetworkCm02Model();
- ~NetworkCm02Model() override = default;
LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths,
s4u::Link::SharingPolicy policy) override;
void update_actions_state_lazy(double now, double delta) override;
class NetworkCm02Link : public LinkImpl {
public:
NetworkCm02Link(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy, lmm::System* system);
- ~NetworkCm02Link() override = default;
void apply_event(kernel::profile::Event* event, double value) override;
void set_bandwidth(double value) override;
LinkImpl* set_latency(double value) override;
public:
using NetworkAction::NetworkAction;
- ~NetworkCm02Action() override = default;
void update_remains_lazy(double now) override;
};
}
// number of comms the node is receiving
int nbActiveCommsDown = 0;
explicit IBNode(int id) : id(id){};
- virtual ~IBNode() = default;
};
class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
s4u::Link piface_;
protected:
- LinkImpl(const std::string& name);
+ explicit LinkImpl(const std::string& name);
LinkImpl(const LinkImpl&) = delete;
LinkImpl& operator=(const LinkImpl&) = delete;
~LinkImpl() override = default; // Use destroy() instead of this destructor.
class NetworkNS3Model : public NetworkModel {
public:
NetworkNS3Model();
- ~NetworkNS3Model() override = default;
LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidth,
s4u::Link::SharingPolicy policy) override;
Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
class XBT_PRIVATE NetworkSmpiModel : public NetworkCm02Model {
public:
NetworkSmpiModel();
- ~NetworkSmpiModel() override = default;
double get_latency_factor(double size) override;
double get_bandwidth_factor(double size) override;
/* Expand it for the CPUs even if there is nothing to compute, to make sure that it gets expended even if there is no
* communication either */
- for (size_t i = 0; i < host_list.size(); i++)
+ double bound = std::numeric_limits<double>::max();
+ for (size_t i = 0; i < host_list.size(); i++) {
model->get_maxmin_system()->expand(host_list[i]->pimpl_cpu->get_constraint(), get_variable(),
(flops_amount == nullptr ? 0.0 : flops_amount[i]));
+ if (flops_amount && flops_amount[i] > 0)
+ bound = std::min(bound, host_list[i]->pimpl_cpu->get_speed(1.0) * host_list[i]->pimpl_cpu->get_speed_ratio() /
+ flops_amount[i]);
+ }
+ if (bound < std::numeric_limits<double>::max())
+ model->get_maxmin_system()->update_variable_bound(get_variable(), bound);
if (bytes_amount != nullptr) {
for (size_t k = 0; k < host_list.size() * host_list.size(); k++) {
return res;
}
-kernel::resource::Cpu* CpuL07Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
+kernel::resource::Cpu* CpuL07Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
{
- return new CpuL07(this, host, speed_per_pstate, core);
+ return (new CpuL07(host, speed_per_pstate))->set_model(this);
}
kernel::resource::LinkImpl* NetworkL07Model::create_link(const std::string& name, const std::vector<double>& bandwidths,
* Resource *
************/
-CpuL07::CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
- : Cpu(host, speed_per_pstate)
-{
- this->set_core_count(core)->set_model(model)->set_constraint(
- model->get_maxmin_system()->constraint_new(this, speed_per_pstate.front()));
-}
-
-CpuL07::~CpuL07()=default;
-
kernel::resource::CpuAction* CpuL07::execution_start(double size)
{
std::vector<s4u::Host*> host_list = {get_iface()};
CpuL07Model& operator=(const CpuL07Model&) = delete;
~CpuL07Model() override;
- kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core) override;
+ kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
HostL07Model *hostModel_;
};
class CpuL07 : public kernel::resource::Cpu {
public:
- CpuL07(CpuL07Model* model, s4u::Host* host, const std::vector<double>& speed_per_pstate, int core);
+ CpuL07(s4u::Host* host, const std::vector<double>& speed_per_pstate) : Cpu(host, speed_per_pstate){};
CpuL07(const CpuL07&) = delete;
CpuL07& operator=(const CpuL07&) = delete;
- ~CpuL07() override;
+
bool is_used() const override;
void apply_event(kernel::profile::Event* event, double value) override;
kernel::resource::CpuAction* execution_start(double size) override;
TypedConfigurationElement(const std::string& key, const std::string& desc, T value, std::function<void(T&)> callback)
: ConfigurationElement(key, desc), content(std::move(value)), callback(std::move(callback))
{}
- ~TypedConfigurationElement() override = default;
std::string get_string_value() override;
const char* get_type_name() override;
XBT_INFO("Behavior: segv");
behavior = Behavior::SEGV;
} else {
- xbt_die("Please use either 'abort', 'assert', 'printf', or 'segv' as first parameter, to specify what to do when "
- "the error "
- "is found.");
+ xbt_die("Please use either 'abort', 'assert', 'printf', or 'segv' as first parameter,"
+ " to specify what to do when the error is found.");
}
e.load_platform(argv[2]);