A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Plug memleak.
[simgrid.git]
/
src
/
s4u
/
s4u_Host.cpp
diff --git
a/src/s4u/s4u_Host.cpp
b/src/s4u/s4u_Host.cpp
index b52da40fc2e2a2777c74a49856cdc581166b4380..846790fadf2138dc2f73e61210c3f16a59f95737 100644
(file)
--- a/
src/s4u/s4u_Host.cpp
+++ b/
src/s4u/s4u_Host.cpp
@@
-152,7
+152,7
@@
void Host::route_to(const Host* dest, std::vector<Link*>& links, double* latency
{
std::vector<kernel::resource::LinkImpl*> linkImpls;
this->route_to(dest, linkImpls, latency);
- for (
kernel::resource::LinkImpl* const&
l : linkImpls)
+ for (
auto*
l : linkImpls)
links.push_back(l->get_iface());
}
@@
-163,8
+163,8
@@
void Host::route_to(const Host* dest, std::vector<kernel::resource::LinkImpl*>&
if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", get_cname(), dest->get_cname(),
(latency == nullptr ? -1 : *latency));
- for (auto const
&
link : links)
- XBT_CDEBUG(surf_route, "
Link %s
", link->get_cname());
+ for (auto const
*
link : links)
+ XBT_CDEBUG(surf_route, "
Link '%s'
", link->get_cname());
}
}
@@
-174,12
+174,17
@@
NetZone* Host::get_englobing_zone()
return pimpl_netpoint_->get_englobing_zone()->get_iface();
}
-void Host::send_to(Host* dest, double byte_amount)
+void Host::sendto(Host* dest, double byte_amount)
+{
+ sendto_async(dest, byte_amount)->wait();
+}
+
+ActivityPtr Host::sendto_async(Host* dest, double byte_amount)
{
std::vector<Host*> m_host_list = {this, dest};
std::vector<double> flops_amount = {0, 0};
std::vector<double> bytes_amount = {0, byte_amount, 0, 0};
-
this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount
);
+
return this_actor::exec_init(m_host_list, flops_amount, bytes_amount)->start(
);
}
/** Get the properties assigned to a host */
@@
-199,7
+204,7
@@
void Host::set_property(const std::string& key, const std::string& value)
kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
}
-void Host::set_properties(const std::map<std::string, std::string>& properties)
+void Host::set_properties(const std::
unordered_
map<std::string, std::string>& properties)
{
kernel::actor::simcall([this, &properties] { this->pimpl_->set_properties(properties); });
}
@@
-282,23
+287,24
@@
std::vector<const char*> Host::get_attached_storages() const
std::unordered_map<std::string, Storage*> const& Host::get_mounted_storages()
{
- if (mounts_ == nullptr)
- mounts_ = pimpl_->get_mounted_storages();
-
+ kernel::actor::simcall([this] {
+ if (mounts_ == nullptr)
+ mounts_ = pimpl_->get_mounted_storages();
+ });
return *mounts_;
}
-ExecPtr Host::exec_async(double flops)
+ExecPtr Host::exec_async(double flops)
const
{
return this_actor::exec_init(flops);
}
-void Host::execute(double flops)
+void Host::execute(double flops)
const
{
execute(flops, 1.0 /* priority */);
}
-void Host::execute(double flops, double priority)
+void Host::execute(double flops, double priority)
const
{
this_actor::exec_init(flops)->set_priority(1 / priority)->start()->wait();
}
@@
-313,17
+319,11
@@
size_t sg_host_count()
}
sg_host_t* sg_host_list()
{
- simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
+
const
simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
size_t host_count = e->get_host_count();
xbt_assert(host_count > 0, "There is no host!");
std::vector<simgrid::s4u::Host*> hosts = e->get_all_hosts();
- auto last = std::remove_if(begin(hosts), end(hosts), [](const simgrid::s4u::Host* host) {
- return not host || not host->get_netpoint() || not host->get_netpoint()->is_host();
- });
- std::sort(begin(hosts), last,
- [](const simgrid::s4u::Host* a, const simgrid::s4u::Host* b) { return a->get_name() < b->get_name(); });
-
sg_host_t* res = xbt_new(sg_host_t, hosts.size());
memcpy(res, hosts.data(), sizeof(sg_host_t) * hosts.size());
@@
-350,7
+350,7
@@
sg_host_t sg_host_by_name(const char* name)
return simgrid::s4u::Host::by_name_or_null(name);
}
-xbt_dynar_t sg_hosts_as_dynar()
+xbt_dynar_t sg_hosts_as_dynar()
// XBT_ATTRIB_DEPRECATED_v330
{
std::vector<simgrid::s4u::Host*> list = simgrid::s4u::Engine::get_instance()->get_all_hosts();
@@
-390,7
+390,7
@@
void sg_host_user_destroy(sg_host_t host) // deprecated
}
// ========= storage related functions ============
-void sg_host_disks(sg_host_t host, unsigned int* disk_count, sg_disk_t** disks)
+void sg_host_disks(
const_
sg_host_t host, unsigned int* disk_count, sg_disk_t** disks)
{
std::vector<sg_disk_t> list = host->get_disks();
*disk_count = list.size();
@@
-597,9
+597,9
@@
double sg_host_route_bandwidth(const_sg_host_t from, const_sg_host_t to)
return min_bandwidth;
}
-void sg_host_send
_
to(sg_host_t from, sg_host_t to, double byte_amount)
+void sg_host_sendto(sg_host_t from, sg_host_t to, double byte_amount)
{
- from->send
_
to(to, byte_amount);
+ from->sendto(to, byte_amount);
}
/** @brief Displays debugging information about a host */