{
sg_host_t host = sg_host_self();
- int nb = sg_host_get_nb_pstates(host);
- XBT_INFO("Count of Processor states=%d", nb);
+ unsigned long nb = sg_host_get_nb_pstates(host);
+ XBT_INFO("Count of Processor states=%lu", nb);
double current_peak = sg_host_get_speed(host);
XBT_INFO("Current power peak=%f", current_peak);
XBT_INFO("Task1 simulation time: %e", task_time);
// Change power peak
- int new_pstate = 2;
- xbt_assert(new_pstate < nb, "Cannot set the host %s at pstate %d because it only provides %d pstates.",
+ unsigned long new_pstate = 2;
+ xbt_assert(new_pstate < nb, "Cannot set the host %s at pstate %lu because it only provides %lu pstates.",
sg_host_get_name(host), new_pstate, nb);
double peak_at = sg_host_get_pstate_speed(host, new_pstate);
- XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_pstate);
+ XBT_INFO("Changing power peak value to %f (at index %lu)", peak_at, new_pstate);
sg_host_set_pstate(host, new_pstate);
// Verify the default pstate is set to 0
host = sg_host_by_name("MyHost2");
- int nb2 = sg_host_get_nb_pstates(host);
- XBT_INFO("Count of Processor states=%d", nb2);
+ unsigned long nb2 = sg_host_get_nb_pstates(host);
+ XBT_INFO("Count of Processor states=%lu", nb2);
double current_peak2 = sg_host_get_speed(host);
XBT_INFO("Current power peak=%f", current_peak2);
XBT_INFO("Computation1 duration: %.2f", exec_time);
// Change power peak
- int new_pstate = 2;
+ unsigned long new_pstate = 2;
- XBT_INFO("Changing power peak value to %f (at index %d)", host->get_pstate_speed(new_pstate), new_pstate);
+ XBT_INFO("Changing power peak value to %f (at index %lu)", host->get_pstate_speed(new_pstate), new_pstate);
host->set_pstate(new_pstate);
int main(int argc, char *argv[])
{
int rank;
- int i;
+ unsigned long i;
char buf[1024];
int err = MPI_Init(&argc, &argv);
exit(EXIT_FAILURE);
}
- int pstates = sg_host_get_nb_pstates(sg_host_self());
+ unsigned long pstates = sg_host_get_nb_pstates(sg_host_self());
char *s = buf;
size_t sz = sizeof buf;
- size_t x = snprintf(s, sz,
- "[%.6f] [rank %d] Pstates: %d; Powers: %.0f",
- MPI_Wtime(), rank, pstates, sg_host_get_pstate_speed(sg_host_self(), 0));
+ size_t x = snprintf(s, sz, "[%.6f] [rank %d] Pstates: %lu; Powers: %.0f", MPI_Wtime(), rank, pstates,
+ sg_host_get_pstate_speed(sg_host_self(), 0));
if (x < sz) {
s += x;
sz -= x;
for (i = 0; i < pstates; i++) {
sg_host_set_pstate(sg_host_self(), i);
- fprintf(stderr, "[%.6f] [rank %d] Current pstate: %d; Current power: %.0f\n", MPI_Wtime(), rank, i,
+ fprintf(stderr, "[%.6f] [rank %d] Current pstate: %lu; Current power: %.0f\n", MPI_Wtime(), rank, i,
sg_host_get_speed(sg_host_self()));
SMPI_SAMPLE_FLOPS(1e9) {
*/
XBT_PUBLIC unsigned long sg_host_get_nb_pstates(const_sg_host_t host);
-XBT_PUBLIC int sg_host_get_pstate(const_sg_host_t host);
-XBT_PUBLIC void sg_host_set_pstate(sg_host_t host, int pstate);
+XBT_PUBLIC unsigned long sg_host_get_pstate(const_sg_host_t host);
+XBT_PUBLIC void sg_host_set_pstate(sg_host_t host, unsigned long pstate);
XBT_PUBLIC void sg_host_turn_on(sg_host_t host);
XBT_PUBLIC void sg_host_turn_off(sg_host_t host);
protected:
using ClusterZone::ClusterZone;
void set_num_links_per_node(unsigned long num) { num_links_per_node_ = num; }
- resource::LinkImpl* get_uplink_from(unsigned int position) const { return private_links_.at(position).first; }
- resource::LinkImpl* get_downlink_to(unsigned int position) const { return private_links_.at(position).second; }
+ resource::LinkImpl* get_uplink_from(unsigned long position) const { return private_links_.at(position).first; }
+ resource::LinkImpl* get_downlink_to(unsigned long position) const { return private_links_.at(position).second; }
double get_link_latency() const { return link_lat_; }
double get_link_bandwidth() const { return link_bw_; }
NetPoint(const std::string& name, NetPoint::Type component_type);
// Our rank in the vertices_ array of the netzone that contains us.
- unsigned int id() const { return id_; }
+ unsigned long id() const { return id_; }
const std::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
/** @brief the NetZone in which this NetPoint is included */
bool operator<(const NetPoint& rhs) const { return name_ < rhs.name_; }
private:
- unsigned int id_ = -1;
+ unsigned long id_ = -1;
std::string name_;
NetPoint::Type component_type_;
NetZoneImpl* englobing_zone_ = nullptr;
unsigned long get_pstate_count() const;
int get_pstate() const;
- double get_pstate_speed(int pstate_index) const;
- Host* set_pstate(int pstate_index);
+ double get_pstate_speed(unsigned long pstate_index) const;
+ Host* set_pstate(unsigned long pstate_index);
Host* set_coordinates(const std::string& coords);
std::vector<Disk*> get_disks() const;
std::map<std::string, xbt_edge_t, std::less<>>* edges);
/* Add content to the netzone, at parsing time. It should be sealed afterward. */
- int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
+ unsigned long add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
/**
* @brief Add a route between 2 netpoints
XBT_DEBUG(" linkContainers %s <-> %s", src->get_cname(), dst->get_cname());
}
-static void recursiveGraphExtraction(const simgrid::s4u::NetZone* netzone, simgrid::instr::Container* container,
+static void recursiveGraphExtraction(const simgrid::s4u::NetZone* netzone, const simgrid::instr::Container* container,
std::set<std::string, std::less<>>* filter)
{
if (not TRACE_platform_topology()) {
CommImplPtr find_matching_comm(CommImpl::Type type, bool (*match_fun)(void*, void*, CommImpl*), void* this_user_data,
const CommImplPtr& my_synchro, bool done, bool remove_matching);
bool is_permanent() const { return permanent_receiver_ != nullptr; }
- actor::ActorImplPtr get_permanent_receiver() { return permanent_receiver_; }
+ actor::ActorImplPtr get_permanent_receiver() const { return permanent_receiver_; }
bool empty() const { return comm_queue_.empty(); }
size_t size() const { return comm_queue_.size(); }
CommImplPtr front() const { return comm_queue_.front(); }
void DijkstraZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* lat)
{
get_route_check_params(src, dst);
- int src_id = src->id();
- int dst_id = dst->id();
+ unsigned long src_id = src->id();
+ unsigned long dst_id = dst->id();
const_xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_.get());
if (dst->is_router() || src->is_router())
return;
- XBT_VERB("dragonfly getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(),
+ XBT_VERB("dragonfly getLocalRoute from '%s'[%lu] to '%s'[%lu]", src->get_cname(), src->id(), dst->get_cname(),
dst->id());
if ((src->id() == dst->id()) && has_loopback()) {
/* Let's find the source and the destination in our internal structure */
auto searchedNode = this->compute_nodes_.find(src->id());
- xbt_assert(searchedNode != this->compute_nodes_.end(), "Could not find the source %s [%u] in the fat tree",
+ xbt_assert(searchedNode != this->compute_nodes_.end(), "Could not find the source %s [%lu] in the fat tree",
src->get_cname(), src->id());
const FatTreeNode* source = searchedNode->second.get();
searchedNode = this->compute_nodes_.find(dst->id());
- xbt_assert(searchedNode != this->compute_nodes_.end(), "Could not find the destination %s [%u] in the fat tree",
+ xbt_assert(searchedNode != this->compute_nodes_.end(), "Could not find the destination %s [%lu] in the fat tree",
dst->get_cname(), dst->id());
const FatTreeNode* destination = searchedNode->second.get();
- XBT_VERB("Get route and latency from '%s' [%u] to '%s' [%u] in a fat tree", src->get_cname(), src->id(),
+ XBT_VERB("Get route and latency from '%s' [%lu] to '%s' [%lu] in a fat tree", src->get_cname(), src->id(),
dst->get_cname(), dst->id());
/* In case destination is the source, and there is a loopback, let's use it instead of going up to a switch */
/* create a result route */
std::vector<Route*> route_stack;
- unsigned int cur = dst->id();
+ unsigned long cur = dst->id();
do {
int pred = predecessor_table_[src->id()][cur];
if (pred == -1)
void FullZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* res, double* lat)
{
- XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
+ XBT_DEBUG("full getLocalRoute from %s[%lu] to %s[%lu]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
const auto& e_route = routing_table_[src->id()][dst->id()];
xbt_assert(nullptr == s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()),
"Refusing to create a second NetZone called '%s'.", get_cname());
netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone);
- XBT_DEBUG("NetZone '%s' created with the id '%u'", get_cname(), netpoint_->id());
+ XBT_DEBUG("NetZone '%s' created with the id '%lu'", get_cname(), netpoint_->id());
_sg_cfg_init_status = 2; /* HACK: direct access to the global controlling the level of configuration to prevent
* any further config now that we created some real content */
simgrid::s4u::NetZone::on_creation(piface_); // notify the signal
void StarZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* latency)
{
- XBT_VERB("StarZone getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(),
+ XBT_VERB("StarZone getLocalRoute from '%s'[%lu] to '%s'[%lu]", src->get_cname(), src->id(), dst->get_cname(),
dst->id());
const auto& src_route = routes_.at(src->id());
void TorusZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* lat)
{
- XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
+ XBT_VERB("torus getLocalRoute from '%s'[%lu] to '%s'[%lu]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
if (dst->is_router() || src->is_router())
return;
void VivaldiZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* lat)
{
- XBT_DEBUG("vivaldi getLocalRoute from '%s'[%u] '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
+ XBT_DEBUG("vivaldi getLocalRoute from '%s'[%lu] '%s'[%lu]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
if (src->is_netzone()) {
std::string srcName = "router_" + src->get_name();
void WifiZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* res, double* lat)
{
- XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
+ XBT_DEBUG("full getLocalRoute from %s[%lu] to %s[%lu]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
if (wifi_link_ != nullptr) {
// If src and dst are nodes, not access_point, we need to traverse the link twice
virtual ~Governor() = default;
virtual std::string get_name() const = 0;
simgrid::s4u::Host* get_host() const { return host_; }
- int get_min_pstate() const { return min_pstate; }
- int get_max_pstate() const { return max_pstate; }
+ unsigned long get_min_pstate() const { return min_pstate; }
+ unsigned long get_max_pstate() const { return max_pstate; }
void init()
{
if (load > freq_up_threshold_) {
get_host()->set_pstate(get_min_pstate()); /* Run at max. performance! */
- XBT_INFO("Load: %f > threshold: %f --> changed to pstate %i", load, freq_up_threshold_, get_min_pstate());
+ XBT_INFO("Load: %f > threshold: %f --> changed to pstate %lu", load, freq_up_threshold_, get_min_pstate());
} else {
/* The actual implementation uses a formula here: (See Kernel file cpufreq_ondemand.c:158)
*
*/
// Load is now < freq_up_threshold; exclude pstate 0 (the fastest)
// because pstate 0 can only be selected if load > freq_up_threshold_
- int new_pstate = static_cast<int>(get_max_pstate() - load * (get_max_pstate() + 1));
+ unsigned long new_pstate = static_cast<int>(get_max_pstate() - load * (get_max_pstate() + 1));
if (new_pstate < get_min_pstate())
new_pstate = get_min_pstate();
get_host()->set_pstate(new_pstate);
- XBT_DEBUG("Load: %f < threshold: %f --> changed to pstate %i", load, freq_up_threshold_, new_pstate);
+ XBT_DEBUG("Load: %f < threshold: %f --> changed to pstate %lu", load, freq_up_threshold_, new_pstate);
}
}
};
void update() override
{
double load = get_host()->get_core_count() * sg_host_get_avg_load(get_host());
- int pstate = get_host()->get_pstate();
+ unsigned long pstate = get_host()->get_pstate();
sg_host_load_reset(get_host()); // Only consider the period between two calls to this method!
if (load > freq_up_threshold_) {
if (pstate != get_min_pstate()) {
get_host()->set_pstate(pstate - 1);
- XBT_INFO("Load: %f > threshold: %f -> increasing performance to pstate %d", load, freq_up_threshold_,
+ XBT_INFO("Load: %f > threshold: %f -> increasing performance to pstate %lu", load, freq_up_threshold_,
pstate - 1);
} else {
- XBT_DEBUG("Load: %f > threshold: %f -> but cannot speed up even more, already in highest pstate %d", load,
+ XBT_DEBUG("Load: %f > threshold: %f -> but cannot speed up even more, already in highest pstate %lu", load,
freq_up_threshold_, pstate);
}
} else if (load < freq_down_threshold_) {
if (pstate != get_max_pstate()) { // Are we in the slowest pstate already?
get_host()->set_pstate(pstate + 1);
- XBT_INFO("Load: %f < threshold: %f -> slowing down to pstate %d", load, freq_down_threshold_, pstate + 1);
+ XBT_INFO("Load: %f < threshold: %f -> slowing down to pstate %lu", load, freq_down_threshold_, pstate + 1);
} else {
- XBT_DEBUG("Load: %f < threshold: %f -> cannot slow down even more, already in slowest pstate %d", load,
+ XBT_DEBUG("Load: %f < threshold: %f -> cannot slow down even more, already in slowest pstate %lu", load,
freq_down_threshold_, pstate);
}
}
}
}
- for (int pstate = get_host()->get_pstate_count() - 1; pstate >= 0; pstate--) {
+ for (unsigned long pstate = get_host()->get_pstate_count() - 1; pstate != 0; pstate--) {
if (computed_flops / rates[task_id][pstate] <= target_time) {
// We just found the pstate we want to use!
best_pstate = pstate;
}
/** @brief Get the peak processor speed (in flops/s), at the specified pstate */
-double Host::get_pstate_speed(int pstate_index) const
+double Host::get_pstate_speed(unsigned long pstate_index) const
{
return this->pimpl_cpu_->get_pstate_peak_speed(pstate_index);
}
}
/** @brief Set the pstate at which the host should run */
-Host* Host::set_pstate(int pstate_index)
+Host* Host::set_pstate(unsigned long pstate_index)
{
kernel::actor::simcall([this, pstate_index] { this->pimpl_cpu_->set_pstate(pstate_index); });
return this;
*
* See also @ref plugin_host_energy.
*/
-int sg_host_get_pstate(const_sg_host_t host)
+unsigned long sg_host_get_pstate(const_sg_host_t host)
{
return host->get_pstate();
}
*
* See also @ref plugin_host_energy.
*/
-void sg_host_set_pstate(sg_host_t host, int pstate)
+void sg_host_set_pstate(sg_host_t host, unsigned long pstate)
{
host->set_pstate(pstate);
}
return pimpl_->get_host_count();
}
-int NetZone::add_component(kernel::routing::NetPoint* elm)
+unsigned long NetZone::add_component(kernel::routing::NetPoint* elm)
{
return pimpl_->add_component(elm);
}
simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, const std::string& coords)
{
auto* netpoint = current_routing->create_router(name)->set_coordinates(coords);
- XBT_DEBUG("Router '%s' has the id %u", netpoint->get_cname(), netpoint->id());
+ XBT_DEBUG("Router '%s' has the id %lu", netpoint->get_cname(), netpoint->id());
return netpoint;
}
const simgrid::s4u::Link* link_up, const simgrid::s4u::Link* link_down,
const simgrid::s4u::Link* backbone)
{
- XBT_DEBUG("Push Host_link for host '%s' to position %u", netpoint->get_cname(), netpoint->id());
+ XBT_DEBUG("Push Host_link for host '%s' to position %lu", netpoint->get_cname(), netpoint->id());
simgrid::s4u::LinkInRoute linkUp{link_up};
simgrid::s4u::LinkInRoute linkDown{link_down};
if (backbone) {