Пример #1
0
LinkDynar getRoute(char *srcName, char *dstName) {
  RoutingEdge *src = sg_host_edge(sg_host_by_name(srcName));
  RoutingEdge *dst = sg_host_edge(sg_host_by_name(dstName));
  xbt_assert(src,"Cannot get the route from a NULL source");
  xbt_assert(dst,"Cannot get the route to a NULL destination");
  xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdge*), NULL);
  routing_platf->getRouteAndLatency(src, dst, &route, NULL);
  return route;
}
Пример #2
0
/** @brief Retrieve a routing edge from its name
 *
 * Routing edges are either host and routers, whatever
 */
RoutingEdge *sg_routing_edge_by_name_or_null(const char *name) {
  sg_host_t h = sg_host_by_name(name);
  RoutingEdge *net_elm = h==NULL?NULL: sg_host_edge(h);
  if (!net_elm)
	net_elm = (RoutingEdge*) xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL);
  return net_elm;
}
Пример #3
0
/**
 * \brief Add a "host_link" to the network element list
 */
static void parse_S_host_link(sg_platf_host_link_cbarg_t host)
{
  RoutingEdge *info = sg_host_edge(sg_host_by_name(host->id));
  xbt_assert(info, "Host '%s' not found!", host->id);
  xbt_assert(current_routing->p_modelDesc == &routing_models[SURF_MODEL_CLUSTER] ||
      current_routing->p_modelDesc == &routing_models[SURF_MODEL_VIVALDI],
      "You have to be in model Cluster to use tag host_link!");

  s_surf_parsing_link_up_down_t link_up_down;
  link_up_down.link_up = Link::byName(host->link_up);
  link_up_down.link_down = Link::byName(host->link_down);

  xbt_assert(link_up_down.link_up, "Link '%s' not found!",host->link_up);
  xbt_assert(link_up_down.link_down, "Link '%s' not found!",host->link_down);

  if(!current_routing->p_linkUpDownList)
    current_routing->p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);

  // If dynar is is greater than edge id and if the host_link is already defined
  if((int)xbt_dynar_length(current_routing->p_linkUpDownList) > info->getId() &&
      xbt_dynar_get_as(current_routing->p_linkUpDownList, info->getId(), void*))
	surf_parse_error("Host_link for '%s' is already defined!",host->id);

  XBT_DEBUG("Push Host_link for host '%s' to position %d", info->getName(), info->getId());
  xbt_dynar_set_as(current_routing->p_linkUpDownList, info->getId(), s_surf_parsing_link_up_down_t, link_up_down);
}
Пример #4
0
Host *HostCLM03Model::createHost(const char *name){
  sg_host_t sg_host = sg_host_by_name(name);
  Host *host = new HostCLM03(surf_host_model, name, NULL,
		  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
		  sg_host_edge(sg_host),
		  sg_host_surfcpu(sg_host));
  XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
  xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);
  return host;
}
Пример #5
0
Action *HostCLM03Model::executeParallelTask(int host_nb,
                                        sg_host_t *host_list,
                                        double *flops_amount,
                                        double *bytes_amount,
                                        double rate){
#define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
  Action *action =NULL;
  if ((host_nb == 1)
      && (cost_or_zero(bytes_amount, 0) == 0.0)){
    action = surf_host_execute(host_list[0],flops_amount[0]);
  } else if ((host_nb == 1)
           && (cost_or_zero(flops_amount, 0) == 0.0)) {
    action = surf_network_model->communicate(sg_host_edge(host_list[0]),
    		                                 sg_host_edge(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)) {
    int i,nb = 0;
    double value = 0.0;

    for (i = 0; i < host_nb * host_nb; i++) {
      if (cost_or_zero(bytes_amount, i) > 0.0) {
        nb++;
        value = cost_or_zero(bytes_amount, i);
      }
    }
    if (nb == 1){
      action = surf_network_model->communicate(sg_host_edge(host_list[0]),
    		                                   sg_host_edge(host_list[1]),
											   value, rate);
    }
  } else
    THROW_UNIMPLEMENTED;      /* This model does not implement parallel tasks for more than 2 hosts */
#undef cost_or_zero
  xbt_free(host_list);
  return action;
}