*/
XBT_PUBLIC(int) surf_model_running_action_set_size(surf_model_t model);
-/** @brief Create a communication between two hosts
- *
- * @param model The model which handle the communication
- * @param src The source host
- * @param dst The destination host
- * @param size The amount of data (in bytes) needed to transfer
- * @param rate [description]
- * @return The action corresponding to the communication
- */
-XBT_PUBLIC(surf_action_t) surf_network_model_communicate(surf_network_model_t model, sg_host_t src, sg_host_t dst, double size, double rate);
-
/** @brief Create a sleep action on the given host */
XBT_PUBLIC(surf_action_t) surf_host_sleep(sg_host_t host, double duration);
#include "simgrid/s4u/Mailbox.hpp"
#include "src/kernel/activity/SynchroComm.hpp"
+#include "src/surf/network_interface.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related synchronization");
XBT_DEBUG("Starting communication %p from '%s' to '%s'", synchro, sg_host_get_name(sender), sg_host_get_name(receiver));
- comm->surf_comm = surf_network_model_communicate(surf_network_model, sender, receiver, comm->task_size, comm->rate);
+ comm->surf_comm = surf_network_model->communicate(sender, receiver, comm->task_size, comm->rate);
comm->surf_comm->setData(synchro);
comm->state = SIMIX_RUNNING;
action = host_list[0]->pimpl_cpu->execution_start(flops_amount[0]);
} else if ((host_nb == 1)
&& (cost_or_zero(flops_amount, 0) == 0.0)) {
- action = surf_network_model->communicate(host_list[0]->pimpl_netcard,
- host_list[0]->pimpl_netcard,
- bytes_amount[0], rate);
+ action = surf_network_model->communicate(host_list[0], host_list[0], bytes_amount[0], rate);
} else if ((host_nb == 2)
&& (cost_or_zero(flops_amount, 0) == 0.0)
&& (cost_or_zero(flops_amount, 1) == 0.0)) {
}
}
if (nb == 1) {
- action = surf_network_model->communicate(host_list[0]->pimpl_netcard, host_list[1]->pimpl_netcard, value, rate);
+ action = surf_network_model->communicate(host_list[0], host_list[1], value, rate);
} else if (nb == 0) {
xbt_die("Cannot have a communication with no flop to exchange in this model. You should consider using the ptask model");
} else {
#include <algorithm>
-#include "network_cm02.hpp"
#include "maxmin_private.hpp"
+#include "network_cm02.hpp"
+#include "simgrid/s4u/host.hpp"
#include "simgrid/sg_config.h"
#include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
}
}
-Action *NetworkCm02Model::communicate(kernel::routing::NetCard *src, kernel::routing::NetCard *dst,
- double size, double rate)
+Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
{
int failed = 0;
double bandwidth_bound;
std::vector<Link*> *route = new std::vector<Link*>();
- XBT_IN("(%s,%s,%g,%g)", src->name(), dst->name(), size, rate);
+ XBT_IN("(%s,%s,%g,%g)", src->name().c_str(), dst->name().c_str(), size, rate);
- routing_platf->getRouteAndLatency(src, dst, route, &latency);
- xbt_assert(! route->empty() || latency,
+ routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, &latency);
+ xbt_assert(!route->empty() || latency,
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
- src->name(), dst->name());
+ src->name().c_str(), dst->name().c_str());
for (auto link: *route)
if (link->isOff())
if (sg_network_crosstraffic == 1) {
back_route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency(dst, src, back_route, nullptr);
+ routing_platf->getRouteAndLatency(dst->pimpl_netcard, src->pimpl_netcard, back_route, nullptr);
for (auto link: *back_route)
if (link->isOff())
failed = 1;
"Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!");
gapAppend(size, route->at(0), action);
- XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)", action, src->name(), dst->name(), action->senderGap_, action->latency_);
+ XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)", action, src->name().c_str(), dst->name().c_str(), action->senderGap_,
+ action->latency_);
}
constraints_per_variable = route->size();
xbt_dict_t properties) override;
void updateActionsStateLazy(double now, double delta) override;
void updateActionsStateFull(double now, double delta) override;
- Action *communicate(kernel::routing::NetCard *src, kernel::routing::NetCard *dst, double size, double rate) override;
+ Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
virtual void gapAppend(double size, const Link* link, NetworkAction* action);
protected:
bool haveGap_ = false;
* Action *
**********/
class NetworkCm02Action : public NetworkAction {
- friend Action *NetworkCm02Model::communicate(kernel::routing::NetCard *src, kernel::routing::NetCard *dst, double size, double rate);
+ friend Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
friend NetworkSmpiModel;
public:
NetworkCm02Action(Model *model, double cost, bool failed)
}
}
- Action *NetworkConstantModel::communicate(kernel::routing::NetCard *src, kernel::routing::NetCard *dst, double size, double rate)
+ Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
{
NetworkConstantAction *action = new NetworkConstantAction(this, size, sg_latency_factor);
NetworkConstantModel() : NetworkModel() { };
~NetworkConstantModel() override;
- Action *communicate(kernel::routing::NetCard *src, kernel::routing::NetCard *dst, double size, double rate) override;
+ Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size, double rate) override;
double nextOccuringEvent(double now) override;
void updateActionsState(double now, double delta) override;
}
-
-static void IB_action_init_callback(
- simgrid::surf::NetworkAction *action, simgrid::kernel::routing::NetCard *src, simgrid::kernel::routing::NetCard *dst)
+static void IB_action_init_callback(simgrid::surf::NetworkAction* action, simgrid::s4u::Host* src,
+ simgrid::s4u::Host* dst)
{
simgrid::surf::NetworkIBModel* ibModel = (simgrid::surf::NetworkIBModel*)surf_network_model;
- simgrid::surf::IBNode* act_src= (simgrid::surf::IBNode*) xbt_dict_get_or_null(ibModel->active_nodes, src->name());
+ simgrid::surf::IBNode* act_src =
+ (simgrid::surf::IBNode*)xbt_dict_get_or_null(ibModel->active_nodes, src->name().c_str());
xbt_assert(act_src, "could not find src node active comms !");
- simgrid::surf::IBNode* act_dst= (simgrid::surf::IBNode*) xbt_dict_get_or_null(ibModel->active_nodes, dst->name());
+ simgrid::surf::IBNode* act_dst =
+ (simgrid::surf::IBNode*)xbt_dict_get_or_null(ibModel->active_nodes, dst->name().c_str());
xbt_assert(act_dst, "could not find dst node active comms !");
ibModel->active_comms[action]=std::make_pair(act_src, act_dst);
simgrid::xbt::signal<void(Link*)> Link::onStateChange;
simgrid::xbt::signal<void(NetworkAction*, Action::State, Action::State)> networkActionStateChangedCallbacks;
- simgrid::xbt::signal<void(NetworkAction*, kernel::routing::NetCard *src, kernel::routing::NetCard *dst)> Link::onCommunicate;
-
+ simgrid::xbt::signal<void(NetworkAction*, s4u::Host* src, s4u::Host* dst)> Link::onCommunicate;
}
}
* unlimited.
* @return The action representing the communication
*/
- virtual Action *communicate(kernel::routing::NetCard *src, kernel::routing::NetCard *dst, double size, double rate)=0;
+ virtual Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size, double rate) = 0;
/** @brief Function pointer to the function to use to solve the lmm_system_t
*
static simgrid::xbt::signal<void(surf::Link*)> onStateChange;
/** @brief Callback signal fired when a communication starts
- * Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst)` */
- static simgrid::xbt::signal<void(surf::NetworkAction*, kernel::routing::NetCard *src, kernel::routing::NetCard *dst)> onCommunicate;
-
-
+ * Signature: `void(NetworkAction *action, host *src, host *dst)` */
+ static simgrid::xbt::signal<void(surf::NetworkAction*, s4u::Host* src, s4u::Host* dst)> onCommunicate;
/** @brief Get the bandwidth in bytes per second of current Link */
virtual double getBandwidth();
xbt_free(host_list);
}
-Action *NetworkL07Model::communicate(kernel::routing::NetCard *src, kernel::routing::NetCard *dst, double size, double rate)
+Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
{
sg_host_t*host_list = xbt_new0(sg_host_t, 2);
double *flops_amount = xbt_new0(double, 2);
double *bytes_amount = xbt_new0(double, 4);
- host_list[0] = sg_host_by_name(src->name());
- host_list[1] = sg_host_by_name(dst->name());
+ host_list[0] = src;
+ host_list[1] = dst;
bytes_amount[1] = size;
return hostModel_->executeParallelTask(2, host_list, flops_amount, bytes_amount, rate);
e_surf_link_sharing_policy_t policy,
xbt_dict_t properties) override;
- Action *communicate(kernel::routing::NetCard *src, kernel::routing::NetCard *dst, double size, double rate) override;
+ Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
HostL07Model *hostModel_;
};
return model->getRunningActionSet()->size();
}
-surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_host_t src, sg_host_t dst, double size, double rate){
- return model->communicate(src->pimpl_netcard, dst->pimpl_netcard, size, rate);
-}
-
surf_action_t surf_host_sleep(sg_host_t host, double duration){
return host->pimpl_cpu->sleep(duration);
}
/* A few basic tests for the surf library */
-/* Copyright (c) 2004-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2004-2015. 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 <stdio.h>
-#include "simgrid/sg_config.h"
-#include "simgrid/host.h"
#include "surf/surf.h"
-#include "src/surf/surf_interface.hpp"
+#include "simgrid/s4u/host.hpp"
+#include "simgrid/sg_config.h"
#include "src/surf/cpu_interface.hpp"
#include "src/surf/network_interface.hpp"
+#include "src/surf/surf_interface.hpp"
+#include <stdio.h>
#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
/* Let's do something on it */
- surf_network_model_communicate(surf_network_model, hostA, hostB, 150.0, -1.0);
+ surf_network_model->communicate(hostA, hostB, 150.0, -1.0);
surf_solve(-1.0);
do {
/* A few basic tests for the surf library */
-/* Copyright (c) 2004-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2004-2015. 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/sg_config.h"
-#include "simgrid/host.h"
#include "surf/surf.h"
-#include "src/surf/surf_interface.hpp"
+#include "simgrid/s4u/host.hpp"
+#include "simgrid/sg_config.h"
#include "src/surf/cpu_interface.hpp"
+#include "src/surf/network_interface.hpp"
+#include "src/surf/surf_interface.hpp"
#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
int main(int argc, char **argv)
{
- sg_host_t hostA = nullptr;
- sg_host_t hostB = nullptr;
double now = -1.0;
int running;
parse_platform_file(argv[1]);
/*********************** HOST ***********************************/
- hostA = sg_host_by_name("Cpu A");
- hostB = sg_host_by_name("Cpu B");
+ sg_host_t hostA = sg_host_by_name("Cpu A");
+ sg_host_t hostB = sg_host_by_name("Cpu B");
/* Let's check that those two processors exist */
XBT_DEBUG("%s : %p", sg_host_get_name(hostA), hostA);
hostB->pimpl_cpu->execution_start(1000.0);
surf_host_sleep(hostB, 7.32);
- surf_network_model_communicate(surf_network_model, hostA, hostB, 150.0, -1.0);
+ surf_network_model->communicate(hostA, hostB, 150.0, -1.0);
surf_solve(-1.0); /* Takes traces into account. Returns 0.0 */
do {