本文整理汇总了C++中xbt_dynar_new函数的典型用法代码示例。如果您正苦于以下问题:C++ xbt_dynar_new函数的具体用法?C++ xbt_dynar_new怎么用?C++ xbt_dynar_new使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xbt_dynar_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: action_init
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);
}
}
}
示例2: xbt_dynar_new
/* 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;
}
示例3: xbt_dict_dump_sizes
/** @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);
}
}
示例4: action_init
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);
}
示例5: action_init
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();
}
示例6: mpi_init_
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);
}
示例7: parse_factor
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);
}
示例8: create_hierarchy
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 {
示例9: jedule_log_sd_event
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);
}
示例10: Resource
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);
}
}
示例11: parse_S_host_link
/**
* \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);
}
示例12: find_active_VMs_to_stop
/* 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;
}
示例13: action_init
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);
}
}
*/
}
示例14: parse_S_host
/**
* \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);
}
示例15: xbt_dynar_new
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;
}
}