static void action_init(const char *const *action) { int i; XBT_DEBUG("Initialize the counters"); smpi_replay_globals_t globals = xbt_new(s_smpi_replay_globals_t, 1); globals->irecvs = xbt_dynar_new(sizeof(MPI_Request),NULL); if(action[2]) MPI_DEFAULT_TYPE= MPI_DOUBLE; // default MPE dataype else MPI_DEFAULT_TYPE= MPI_BYTE; // default TAU datatype smpi_process_set_user_data((void*) globals); /* start a simulated timer */ smpi_process_simulated_start(); /*initialize the number of active processes */ active_processes = smpi_process_count(); if (!reqq) { reqq=xbt_new0(xbt_dynar_t,active_processes); for(i=0;i<active_processes;i++){ reqq[i]=xbt_dynar_new(sizeof(MPI_Request),NULL); } } }
/* Business methods */ xbt_dynar_t AsFloyd::getOneLinkRoutes() { xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); int src,dst; sg_routing_edge_t src_elm, dst_elm; int table_size = xbt_dynar_length(p_indexNetworkElm); for(src=0; src < table_size; src++) { for(dst=0; dst< table_size; dst++) { xbt_dynar_reset(route->link_list); src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdgePtr); dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdgePtr); this->getRouteAndLatency(src_elm, dst_elm, route, NULL); if (xbt_dynar_length(route->link_list) == 1) { void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0); OnelinkPtr onelink; if (p_hierarchy == SURF_ROUTING_BASE) onelink = new Onelink(link, src_elm, dst_elm); else if (p_hierarchy == SURF_ROUTING_RECURSIVE) onelink = new Onelink(link, route->gw_src, route->gw_dst); else onelink = new Onelink(link, NULL, NULL); xbt_dynar_push(ret, &onelink); } } } return ret; }
/** @brief shows some debugging info about the bucklet repartition */ void xbt_dict_dump_sizes(xbt_dict_t dict) { int i; unsigned int count; unsigned int size; xbt_dictelm_t element; xbt_dynar_t sizes = xbt_dynar_new(sizeof(int), NULL); printf("Dict %p: %d bucklets, %d used cells (of %d) ", dict, dict->count, dict->fill, dict->table_size); if (dict != NULL) { for (i = 0; i < dict->table_size; i++) { element = dict->table[i]; size = 0; if (element) { while (element != NULL) { size++; element = element->next; } } if (xbt_dynar_length(sizes) <= size) { int prevsize = 1; xbt_dynar_set(sizes, size, &prevsize); } else { int prevsize; xbt_dynar_get_cpy(sizes, size, &prevsize); prevsize++; xbt_dynar_set(sizes, size, &prevsize); } } if (!all_sizes) all_sizes = xbt_dynar_new(sizeof(int), NULL); xbt_dynar_foreach(sizes, count, size) { /* Copy values of this one into all_sizes */ int prevcount; if (xbt_dynar_length(all_sizes) <= count) { prevcount = size; xbt_dynar_set(all_sizes, count, &prevcount); } else { xbt_dynar_get_cpy(all_sizes, count, &prevcount); prevcount += size; xbt_dynar_set(all_sizes, count, &prevcount); } /* Report current sizes */ if (count == 0) continue; if (size == 0) continue; printf("%uelm x %u cells; ", count, size); } }
static void action_init(const char *const *action) { XBT_DEBUG("Initialize the counters"); process_globals_t globals = (process_globals_t) calloc(1, sizeof(s_process_globals_t)); globals->isends = xbt_dynar_new(sizeof(msg_comm_t), NULL); globals->irecvs = xbt_dynar_new(sizeof(msg_comm_t), NULL); globals->tasks = xbt_dynar_new(sizeof(msg_task_t), NULL); MSG_process_set_data(MSG_process_self(), globals); }
static void action_init(const char *const *action) { XBT_DEBUG("Initialize the counters"); smpi_replay_globals_t globals = xbt_new(s_smpi_replay_globals_t, 1); globals->isends = xbt_dynar_new(sizeof(MPI_Request),NULL); globals->irecvs = xbt_dynar_new(sizeof(MPI_Request),NULL); smpi_process_set_user_data((void*) globals); /* start a simulated timer */ smpi_process_simulated_start(); /*initialize the number of active processes */ active_processes = smpi_process_count(); }
void mpi_init_(int* ierr) { if(!comm_lookup){ comm_lookup = xbt_dynar_new(sizeof(MPI_Comm), NULL); new_comm(MPI_COMM_WORLD); group_lookup = xbt_dynar_new(sizeof(MPI_Group), NULL); request_lookup = xbt_dict_new_homogeneous(NULL); datatype_lookup = xbt_dynar_new(sizeof(MPI_Datatype), NULL); new_datatype(MPI_BYTE); new_datatype(MPI_CHAR); new_datatype(MPI_INT); new_datatype(MPI_INT); new_datatype(MPI_INT8_T); new_datatype(MPI_INT16_T); new_datatype(MPI_INT32_T); new_datatype(MPI_INT64_T); new_datatype(MPI_FLOAT); new_datatype(MPI_FLOAT); new_datatype(MPI_DOUBLE); new_datatype(MPI_DOUBLE); new_datatype(MPI_C_FLOAT_COMPLEX); new_datatype(MPI_C_DOUBLE_COMPLEX); new_datatype(MPI_2INT); new_datatype(MPI_UINT8_T); new_datatype(MPI_UINT16_T); new_datatype(MPI_UINT32_T); new_datatype(MPI_UINT64_T); new_datatype(MPI_2FLOAT); new_datatype(MPI_2DOUBLE); op_lookup = xbt_dynar_new(sizeof(MPI_Op), NULL); new_op(MPI_MAX); new_op(MPI_MIN); new_op(MPI_MAXLOC); new_op(MPI_MINLOC); new_op(MPI_SUM); new_op(MPI_PROD); new_op(MPI_LAND); new_op(MPI_LOR); new_op(MPI_LXOR); new_op(MPI_BAND); new_op(MPI_BOR); new_op(MPI_BXOR); } /* smpif2c is responsible for generating a call with the final arguments */ *ierr = MPI_Init(NULL, NULL); }
static xbt_dynar_t parse_factor(const char *smpi_coef_string) { char *value = NULL; unsigned int iter = 0; s_smpi_factor_t fact; xbt_dynar_t smpi_factor, radical_elements, radical_elements2 = NULL; smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_t), NULL); radical_elements = xbt_str_split(smpi_coef_string, ";"); xbt_dynar_foreach(radical_elements, iter, value) { radical_elements2 = xbt_str_split(value, ":"); surf_parse_assert(xbt_dynar_length(radical_elements2) == 2, "Malformed radical '%s' for smpi factor. I was expecting something like 'a:b'", value); char *errmsg = bprintf("Invalid factor in chunk #%d: %%s", iter+1); fact.factor = xbt_str_parse_int(xbt_dynar_get_as(radical_elements2, 0, char *), errmsg); xbt_free(errmsg); fact.value = xbt_str_parse_double(xbt_dynar_get_as(radical_elements2, 1, char *), errmsg); errmsg = bprintf("Invalid factor value in chunk #%d: %%s", iter+1); xbt_free(errmsg); xbt_dynar_push_as(smpi_factor, s_smpi_factor_t, fact); XBT_DEBUG("smpi_factor:\t%ld : %f", fact.factor, fact.value); xbt_dynar_free(&radical_elements2); }
static void create_hierarchy(AS_t current_comp, jed_simgrid_container_t current_container) { xbt_dict_cursor_t cursor = NULL; char *key; AS_t elem; xbt_dict_t routing_sons = surf_AS_get_routing_sons(current_comp); if (xbt_dict_is_empty(routing_sons)) { // I am no AS // add hosts to jedule platform xbt_dynar_t table = surf_AS_get_hosts(current_comp); xbt_dynar_t hosts; unsigned int dynar_cursor; sg_host_t host_elem; hosts = xbt_dynar_new(sizeof(char*), NULL); xbt_dynar_foreach(table, dynar_cursor, host_elem) { xbt_dynar_push_as(hosts, char*, sg_host_name(host_elem)); } jed_simgrid_add_resources(current_container, hosts); xbt_dynar_free(&hosts); xbt_dynar_free(&table); } else {
void jedule_log_sd_event(SD_task_t task) { xbt_dynar_t host_list; jed_event_t event; int i; xbt_assert(task != NULL); host_list = xbt_dynar_new(sizeof(char*), NULL); for(i=0; i<task->workstation_nb; i++) { char *hostname = sg_host_name(task->workstation_list[i]); xbt_dynar_push(host_list, &hostname); } create_jed_event(&event, (char*)SD_task_get_name(task), task->start_time, task->finish_time, "SD"); jed_event_add_resources(event, host_list); jedule_store_event(event); xbt_dynar_free(&host_list); }
Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, xbt_dynar_t speedPeakList, int core, double speedPeak) : Resource(model, host->name().c_str(), constraint) , m_core(core) , m_host(host) { p_speed.peak = speedPeak; p_speed.scale = 1; host->pimpl_cpu = this; xbt_assert(p_speed.scale > 0, "Available speed has to be >0"); // Copy the power peak array: p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr); unsigned long n = xbt_dynar_length(speedPeakList); for (unsigned long i = 0; i != n; ++i) { double value = xbt_dynar_get_as(speedPeakList, i, double); xbt_dynar_push(p_speedPeakList, &value); } /* Currently, we assume that a VM does not have a multicore CPU. */ if (core > 1) xbt_assert(model == surf_cpu_model_pm); if (model->getUpdateMechanism() != UM_UNDEFINED) { p_constraintCore = xbt_new(lmm_constraint_t, core); p_constraintCoreId = xbt_new(void*, core); int i; for (i = 0; i < core; i++) { /* just for a unique id, never used as a string. */ p_constraintCoreId[i] = bprintf("%s:%i", host->name().c_str(), i); p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], p_speed.scale * p_speed.peak); } }
/** * \brief Add a "host_link" to the network element list */ static void parse_S_host_link(sg_platf_host_link_cbarg_t host) { sg_routing_edge_t info = NULL; info = xbt_lib_get_or_null(host_lib, host->id, ROUTING_HOST_LEVEL); xbt_assert(info, "Host '%s' not found!",host->id); xbt_assert(current_routing->model_desc == &routing_models[SURF_MODEL_CLUSTER] || current_routing->model_desc == &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 = xbt_lib_get_or_null(link_lib, host->link_up, SURF_LINK_LEVEL); link_up_down.link_down = xbt_lib_get_or_null(link_lib, host->link_down, SURF_LINK_LEVEL); link_up_down.limiter_link = NULL; link_up_down.loopback_link = NULL; 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->link_up_down_list) current_routing->link_up_down_list = 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(xbt_dynar_length(current_routing->link_up_down_list) > info->id && xbt_dynar_get_as(current_routing->link_up_down_list,info->id,void*)) xbt_die("Host_link for '%s' is already defined!",host->id); XBT_DEBUG("Push Host_link for host '%s' to position %d",info->name,info->id); xbt_dynar_set_as(current_routing->link_up_down_list,info->id,s_surf_parsing_link_up_down_t,link_up_down); }
/* Build the set of hosts/VMs that have to be terminated. This function selects how_many VMs from the source set of * candidates. * Remark: In the paper by Malawski et al., no details are provided about how the VMs are selected in the source set. * Moreover, there is no check w.r.t. the size of the source set. * Assumptions: * 1) If the source set is too small, display a warning and return a smaller set than expected. * 2) Straightforward selection of the VMs in the set. Just pick the how_many first ones without any consideration of * the time remaining until the next hourly billing cycle. Just check if the VM is not currently executing a task */ xbt_dynar_t find_active_VMs_to_stop(int how_many, xbt_dynar_t source){ int i, found; long unsigned int source_size = xbt_dynar_length(source); xbt_dynar_t to_stop = xbt_dynar_new(sizeof(sg_host_t), NULL); sg_host_t v; if (how_many > source_size){ XBT_WARN("Trying to terminate more VMs than what is available (%d > %lu)." " Change the number of VMs to terminate to %lu", how_many, source_size, source_size); how_many = source_size; } i = 0; found = 0; while(found < how_many && i < xbt_dynar_length(source)){ /* No advanced selection process. Just pick the how_many first idle VMs in the source set. */ xbt_dynar_get_cpy(source, i, &v); HostAttribute attr = sg_host_user(v); if (!attr->idle_busy){ xbt_dynar_push(to_stop, &v); found++; } i++; } if (found < how_many) XBT_WARN("Trying to terminate too many VMs, some are busy... Change the number of VMs to terminate to %d", found); return to_stop; }
static void action_init(const char *const *action) { XBT_DEBUG("Initialize the counters"); CHECK_ACTION_PARAMS(action, 0, 1); if(action[2]) MPI_DEFAULT_TYPE= MPI_DOUBLE; // default MPE dataype else MPI_DEFAULT_TYPE= MPI_BYTE; // default TAU datatype /* start a simulated timer */ smpi_process_simulated_start(); /*initialize the number of active processes */ active_processes = smpi_process_count(); if (!reqq) { reqq = xbt_dict_new(); } set_reqq_self(xbt_dynar_new(sizeof(MPI_Request),&xbt_free_ref)); /* reqq=xbt_new0(xbt_dynar_t,active_processes); for(i=0;i<active_processes;i++){ reqq[i]=xbt_dynar_new(sizeof(MPI_Request),&xbt_free_ref); } } */ }
/** * \brief Add a "host" to the network element list */ static void parse_S_host(sg_platf_host_cbarg_t host) { if (current_routing->p_hierarchy == SURF_ROUTING_NULL) current_routing->p_hierarchy = SURF_ROUTING_BASE; xbt_assert(!sg_host_by_name(host->id), "Reading a host, processing unit \"%s\" already exists", host->id); RoutingEdge *info = new RoutingEdgeImpl(xbt_strdup(host->id), -1, SURF_NETWORK_ELEMENT_HOST, current_routing); info->setId(current_routing->parsePU(info)); sg_host_edge_set(sg_host_by_name_or_create(host->id), info); XBT_DEBUG("Having set name '%s' id '%d'", host->id, info->getId()); if(mount_list){ xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list); mount_list = NULL; } if (host->coord && strcmp(host->coord, "")) { unsigned int cursor; char*str; if (!COORD_HOST_LEVEL) xbt_die ("To use host coordinates, please add --cfg=network/coordinates:yes to your command line"); /* Pre-parse the host coordinates -- FIXME factorize with routers by overloading the routing->parse_PU function*/ xbt_dynar_t ctn_str = xbt_str_split_str(host->coord, " "); xbt_dynar_t ctn = xbt_dynar_new(sizeof(double),NULL); xbt_dynar_foreach(ctn_str,cursor, str) { double val = atof(str); xbt_dynar_push(ctn,&val); }
ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate) { unsigned int i; void *_link; NetworkCm02LinkPtr link; int failed = 0; NetworkCm02ActionPtr action = NULL; double bandwidth_bound; double latency = 0.0; xbt_dynar_t back_route = NULL; int constraints_per_variable = 0; xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL); XBT_IN("(%s,%s,%g,%g)", src->getName(), dst->getName(), size, rate); routing_platf->getRouteAndLatency(src, dst, &route, &latency); xbt_assert(!xbt_dynar_is_empty(route) || latency, "You're trying to send data from %s to %s but there is no connection at all between these two hosts.", src->getName(), dst->getName()); xbt_dynar_foreach(route, i, _link) { link = static_cast<NetworkCm02LinkPtr>(_link); if (link->getState() == SURF_RESOURCE_OFF) { failed = 1; break; } }
static int master(int argc, char *argv[]) { msg_task_t task = NULL; // I am the master of emigrant process, // I tell it where it must emigrate to. xbt_dynar_t destinations = xbt_dynar_new (sizeof(char*), &xbt_free_ref); xbt_dynar_push_as (destinations, char*, xbt_strdup ("Tremblay")); xbt_dynar_push_as (destinations, char*, xbt_strdup ("Jupiter")); xbt_dynar_push_as (destinations, char*, xbt_strdup ("Fafard")); xbt_dynar_push_as (destinations, char*, xbt_strdup ("Ginette")); xbt_dynar_push_as (destinations, char*, xbt_strdup ("Bourassa")); xbt_dynar_push_as (destinations, char*, xbt_strdup ("Fafard")); xbt_dynar_push_as (destinations, char*, xbt_strdup ("Tremblay")); xbt_dynar_push_as (destinations, char*, xbt_strdup ("Ginette")); xbt_dynar_push_as (destinations, char*, NULL); char *destination; unsigned int i; xbt_dynar_foreach(destinations, i, destination){ task = MSG_task_create("task", 0, 0, NULL); if (destination){ MSG_task_set_data(task, xbt_strdup (destination)); } MSG_task_set_category(task, "migration_order"); MSG_task_send (task, "master_mailbox"); task = NULL; }
static void parse_ns3_add_link(sg_platf_link_cbarg_t link) { XBT_DEBUG("NS3_ADD_LINK '%s'",link->id); if(!IPV4addr) IPV4addr = xbt_dynar_new(sizeof(char*),free); tmgr_trace_t bw_trace; tmgr_trace_t state_trace; tmgr_trace_t lat_trace; bw_trace = link->bandwidth_trace; lat_trace = link->latency_trace; state_trace = link->state_trace; if (bw_trace) XBT_INFO("The NS3 network model doesn't support bandwidth state traces"); if (lat_trace) XBT_INFO("The NS3 network model doesn't support latency state traces"); if (state_trace) XBT_INFO("The NS3 network model doesn't support link state traces"); ns3_link_t link_ns3 = xbt_new0(s_ns3_link_t,1);; link_ns3->id = xbt_strdup((char*)(link->id)); link_ns3->bdw = bprintf("%f",link->bandwidth); link_ns3->lat = bprintf("%f",link->latency); surf_ns3_link_t l = xbt_new0(s_surf_ns3_link_t,1); l->generic_resource.name = xbt_strdup(link->id); l->generic_resource.properties = current_property_set; l->data = link_ns3; l->created = 1; xbt_lib_set(link_lib,link->id,NS3_LINK_LEVEL,link_ns3); xbt_lib_set(link_lib,link->id,SURF_LINK_LEVEL,l); }
void peer_init(peer_t p, int argc, char *argv[]) { p->init = 0; p->prev = NULL; p->next = NULL; p->pieces = 0; p->bytes = 0; p->pending_recvs = xbt_dynar_new(sizeof(msg_comm_t), NULL); p->pending_sends = xbt_dynar_new(sizeof(msg_comm_t), NULL); /* Set mailbox name: use host number from argv or hostname if no argument given */ if (argc > 1) { p->me = bprintf("host%s", argv[1]); } else { p->me = xbt_strdup(MSG_host_get_name(MSG_host_self())); } }
/** * \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); }
/** @brief Add an "host" to the current AS */ void sg_platf_new_host(sg_platf_host_cbarg_t host) { xbt_assert(! sg_host_by_name(host->id), "Refusing to create a second host named '%s'.", host->id); simgrid::surf::AsImpl* current_routing = routing_get_current(); if (current_routing->hierarchy_ == simgrid::surf::AsImpl::RoutingMode::unset) current_routing->hierarchy_ = simgrid::surf::AsImpl::RoutingMode::base; simgrid::surf::NetCard *netcard = new simgrid::surf::NetCardImpl(host->id, SURF_NETWORK_ELEMENT_HOST, current_routing); netcard->setId(current_routing->addComponent(netcard)); sg_host_t h = simgrid::s4u::Host::by_name_or_create(host->id); h->pimpl_netcard = netcard; simgrid::surf::netcardCreatedCallbacks(netcard); if(mount_list){ xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list); mount_list = NULL; } if (host->coord && strcmp(host->coord, "")) { unsigned int cursor; char*str; if (!COORD_HOST_LEVEL) xbt_die ("To use host coordinates, please add --cfg=network/coordinates:yes to your command line"); /* Pre-parse the host coordinates -- FIXME factorize with routers by overloading the routing->parse_PU function*/ xbt_dynar_t ctn_str = xbt_str_split_str(host->coord, " "); xbt_dynar_t ctn = xbt_dynar_new(sizeof(double),NULL); xbt_dynar_foreach(ctn_str,cursor, str) { double val = xbt_str_parse_double(str, "Invalid coordinate: %s"); xbt_dynar_push(ctn,&val); }
static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster) { const char *cluster_prefix = cluster->prefix; const char *cluster_suffix = cluster->suffix; const char *cluster_radical = cluster->radical; const char *cluster_bb_bw = bprintf("%f",cluster->bb_bw); const char *cluster_bb_lat = bprintf("%f",cluster->bb_lat); const char *cluster_bw = bprintf("%f",cluster->bw); const char *cluster_lat = bprintf("%f",cluster->lat); const char *groups = NULL; int start, end, i; unsigned int iter; xbt_dynar_t radical_elements; xbt_dynar_t radical_ends; xbt_dynar_t tab_elements_num = xbt_dynar_new(sizeof(int), NULL); char *router_id,*host_id; radical_elements = xbt_str_split(cluster_radical, ","); xbt_dynar_foreach(radical_elements, iter, groups) { radical_ends = xbt_str_split(groups, "-"); switch (xbt_dynar_length(radical_ends)) { case 1: start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *)); xbt_dynar_push_as(tab_elements_num, int, start); router_id = bprintf("ns3_%s%d%s", cluster_prefix, start, cluster_suffix); xbt_lib_set(host_lib, router_id, NS3_HOST_LEVEL, ns3_add_host_cluster(router_id) ); XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id); free(router_id); break; case 2: start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *)); end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *)); for (i = start; i <= end; i++){ xbt_dynar_push_as(tab_elements_num, int, i); router_id = bprintf("ns3_%s%d%s", cluster_prefix, i, cluster_suffix); xbt_lib_set(host_lib, router_id, NS3_HOST_LEVEL, ns3_add_host_cluster(router_id) ); XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id); free(router_id); } break; default: XBT_DEBUG("Malformed radical"); } }
static xbt_dynar_t rulebased_get_onelink_routes(AS_t rc) { xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free); //We have already bypass cluster routes with network NS3 if(!strcmp(surf_network_model->name,"network NS3")) return ret; char *k1; //find router sg_routing_edge_t router = NULL; xbt_lib_cursor_t cursor; xbt_lib_foreach(as_router_lib, cursor, k1, router) { if (router->rc_type == SURF_NETWORK_ELEMENT_ROUTER) break; } if (!router) xbt_die ("rulebased_get_onelink_routes works only if the AS is a cluster, sorry."); sg_routing_edge_t host = NULL; xbt_lib_foreach(as_router_lib, cursor, k1, host){ void *link_ptr; sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1); route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); rulebased_get_route_and_latency (rc, router, host, route,NULL); switch (xbt_dynar_length(route->link_list)) { case 1: //loopback break; case 2: xbt_dynar_get_cpy (route->link_list, 1, &link_ptr); onelink_t onelink = xbt_new0 (s_onelink_t, 1); onelink->src = host; onelink->dst = router; onelink->link_ptr = link_ptr; xbt_dynar_push (ret, &onelink); break; default: xbt_die("rulebased_get_onelink_routes works only if the AS is a cluster, sorry."); break; } }
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; }
int master_fun(int argc, char *argv[]) { msg_vm_t vm; unsigned int i; xbt_dynar_t worker_pms = MSG_process_get_data(MSG_process_self()); int nb_workers = xbt_dynar_length(worker_pms); xbt_dynar_t vms = xbt_dynar_new(sizeof(msg_vm_t), NULL); /* Launch VMs and worker processes. One VM per PM, and one worker process per VM. */ XBT_INFO("# Launch %d VMs", nb_workers); for (i = 0; i< nb_workers; i++) { char *vm_name = bprintf("VM%02d", i); char *pr_name = bprintf("WRK%02d", i); msg_host_t pm = xbt_dynar_get_as(worker_pms, i, msg_host_t); XBT_INFO("create %s on PM(%s)", vm_name, MSG_host_get_name(pm)); msg_vm_t vm = MSG_vm_create_core(pm, vm_name); s_vm_params_t params; memset(¶ms, 0, sizeof(params)); params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes MSG_host_set_params(vm, ¶ms); MSG_vm_start(vm); xbt_dynar_push(vms, &vm); XBT_INFO("put a process (%s) on %s", pr_name, vm_name); MSG_process_create(pr_name, worker_fun, NULL, vm); xbt_free(vm_name); xbt_free(pr_name); } /* Send a bunch of work to every one */ XBT_INFO("# Send a task to %d worker process", nb_workers); send_tasks(nb_workers); XBT_INFO("# Suspend all VMs"); xbt_dynar_foreach(vms, i, vm) { const char *vm_name = MSG_host_get_name(vm); XBT_INFO("suspend %s", vm_name); MSG_vm_suspend(vm); } XBT_INFO("# Wait a while"); MSG_process_sleep(2); XBT_INFO("# Resume all VMs"); xbt_dynar_foreach(vms, i, vm) { MSG_vm_resume(vm); }
/** Sender function */ int sender(int argc, char *argv[]) { long number_of_tasks = atol(argv[1]); double task_comp_size = atof(argv[2]); double task_comm_size = atof(argv[3]); long receivers_count = atol(argv[4]); int diff_com = atol(argv[5]); double coef = 0; xbt_dynar_t d = xbt_dynar_new(sizeof(msg_comm_t), NULL); int i; msg_task_t task; char mailbox[256]; char sprintf_buffer[256]; msg_comm_t comm; for (i = 0; i < number_of_tasks; i++) { if (diff_com == 0) coef = 1; else coef = (i + 1); sprintf(mailbox, "receiver-%ld", (i % receivers_count)); sprintf(sprintf_buffer, "Task_%d", i); task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size / coef, NULL); comm = MSG_task_isend(task, mailbox); xbt_dynar_push_as(d, msg_comm_t, comm); XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, sprintf_buffer, task_comm_size / coef); } /* Here we are waiting for the completion of all communications */ while (!xbt_dynar_is_empty(d)) { xbt_dynar_remove_at(d, MSG_comm_waitany(d), &comm); MSG_comm_destroy(comm); } xbt_dynar_free(&d); /* Here we are waiting for the completion of all tasks */ sprintf(mailbox, "finalize"); msg_comm_t res_irecv; _XBT_GNUC_UNUSED msg_error_t res_wait; for (i = 0; i < receivers_count; i++) { task = NULL; res_irecv = MSG_task_irecv(&(task), mailbox); res_wait = MSG_comm_wait(res_irecv, -1); xbt_assert(res_wait == MSG_OK, "MSG_comm_wait failed"); MSG_comm_destroy(res_irecv); MSG_task_destroy(task); } XBT_INFO("Goodbye now!"); return 0; } /* end_of_sender */
static void action_waitall(const char *const *action){ double clock = smpi_process_simulated_elapsed(); int count_requests=0; unsigned int i=0; count_requests=xbt_dynar_length(reqq[smpi_comm_rank(MPI_COMM_WORLD)]); if (count_requests>0) { MPI_Request requests[count_requests]; MPI_Status status[count_requests]; /* The reqq is an array of dynars. Its index corresponds to the rank. Thus each rank saves its own requests to the array request. */ xbt_dynar_foreach(reqq[smpi_comm_rank(MPI_COMM_WORLD)],i,requests[i]); #ifdef HAVE_TRACING //save information from requests xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), NULL); xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), NULL); xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), NULL); for (i = 0; i < count_requests; i++) { if(requests[i]){ int *asrc = xbt_new(int, 1); int *adst = xbt_new(int, 1); int *arecv = xbt_new(int, 1); *asrc = requests[i]->src; *adst = requests[i]->dst; *arecv = requests[i]->recv; xbt_dynar_insert_at(srcs, i, asrc); xbt_dynar_insert_at(dsts, i, adst); xbt_dynar_insert_at(recvs, i, arecv); xbt_free(asrc); xbt_free(adst); xbt_free(arecv); }else { int *t = xbt_new(int, 1); xbt_dynar_insert_at(srcs, i, t); xbt_dynar_insert_at(dsts, i, t); xbt_dynar_insert_at(recvs, i, t); xbt_free(t); } }
static void array_new(unsigned **a, xbt_dynar_t *data) { int i; *a = xbt_malloc(ARRAY_SIZE * sizeof **a); *data = xbt_dynar_new(sizeof *a, NULL); xbt_dynar_shrink(*data, ARRAY_SIZE); for (i = 0 ; i < ARRAY_SIZE ; i++) { (*a)[i] = i; xbt_dynar_push_as(*data, void*, &(*a)[i]); } }
/** @brief Returns the dynar of the parents of a task * * \param task a task * \return a newly allocated dynar comprising the parents of this task */ xbt_dynar_t SD_task_get_children(SD_task_t task) { xbt_dynar_t children = xbt_dynar_new(sizeof(SD_task_t), nullptr); for (std::set<SD_task_t>::iterator it=task->successors->begin(); it!=task->successors->end(); ++it) xbt_dynar_push(children, &(*it)); for (std::set<SD_task_t>::iterator it=task->outputs->begin(); it!=task->outputs->end(); ++it) xbt_dynar_push(children, &(*it)); return children; }
static xbt_dynar_t instr_dict_to_dynar (xbt_dict_t filter) { if (!TRACE_is_enabled()) return NULL; if (!TRACE_needs_platform()) return NULL; xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref); xbt_dict_cursor_t cursor = NULL; char *name, *value; xbt_dict_foreach(filter, cursor, name, value) { xbt_dynar_push_as (ret, char*, xbt_strdup(name)); }
void jed_event_add_resources(jed_event_t event, xbt_dynar_t host_selection) { xbt_dynar_t resource_subset_list; jed_res_subset_t res_set; unsigned int i; resource_subset_list = xbt_dynar_new(sizeof(jed_res_subset_t), NULL); jed_simgrid_get_resource_selection_by_hosts(resource_subset_list, host_selection); xbt_dynar_foreach(resource_subset_list, i, res_set) { xbt_dynar_push(event->resource_subsets, &res_set); }