本文整理汇总了C++中xbt_new0函数的典型用法代码示例。如果您正苦于以下问题:C++ xbt_new0函数的具体用法?C++ xbt_new0怎么用?C++ xbt_new0使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xbt_new0函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __MSG_host_create
/********************************* Host **************************************/
msg_host_t __MSG_host_create(smx_host_t workstation)
{
const char *name = SIMIX_host_get_name(workstation);
msg_host_priv_t host = xbt_new0(s_msg_host_priv_t, 1);
s_msg_vm_t vm; // simply to compute the offset
host->vms = xbt_swag_new(xbt_swag_offset(vm,host_vms_hookup));
#ifdef MSG_USE_DEPRECATED
int i;
char alias[MAX_ALIAS_NAME + 1] = { 0 }; /* buffer used to build the key of the mailbox */
if (msg_global->max_channel > 0)
host->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);
for (i = 0; i < msg_global->max_channel; i++) {
sprintf(alias, "%s:%d", name, i);
/* the key of the mailbox (in this case) is build from the name of the host and the channel number */
host->mailboxes[i] = MSG_mailbox_new(alias);
memset(alias, 0, MAX_ALIAS_NAME + 1);
}
#endif
xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);
return xbt_lib_get_elm_or_null(host_lib, name);
}
示例2: parse_ns3_add_link
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);
}
示例3: __MSG_host_create
/********************************* Host **************************************/
msg_host_t __MSG_host_create(sg_host_t host) // FIXME: don't return our parameter
{
msg_host_priv_t priv = xbt_new0(s_msg_host_priv_t, 1);
#ifdef MSG_USE_DEPRECATED
int i;
char alias[MAX_ALIAS_NAME + 1] = { 0 }; /* buffer used to build the key of the mailbox */
priv->mailboxes = (msg_global->max_channel > 0) ?
xbt_new0(msg_mailbox_t, msg_global->max_channel) : NULL;
for (i = 0; i < msg_global->max_channel; i++) {
sprintf(alias, "%s:%d", name, i);
/* the key of the mailbox (in this case) is build from the name of the host and the channel number */
priv->mailboxes[i] = MSG_mailbox_new(alias);
memset(alias, 0, MAX_ALIAS_NAME + 1);
}
#endif
priv->dp_objs = xbt_dict_new();
priv->dp_enabled = 0;
priv->dp_updated_by_deleted_tasks = 0;
priv->is_migrating = 0;
priv->affinity_mask_db = xbt_dict_new_homogeneous(NULL);
sg_host_msg_set(host,priv);
return host;
}
示例4: xbt_new0
void AsFull::seal() {
int i;
sg_platf_route_cbarg_t e_route;
/* set utils vars */
int table_size = static_cast<int>(vertices_.size());
/* Create table if necessary */
if (!routingTable_)
routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
/* Add the loopback if needed */
if (routing_platf->loopback_ && hierarchy_ == RoutingMode::base) {
for (i = 0; i < table_size; i++) {
e_route = TO_ROUTE_FULL(i, i);
if (!e_route) {
e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->gw_src = nullptr;
e_route->gw_dst = nullptr;
e_route->link_list = new std::vector<Link*>();
e_route->link_list->push_back(routing_platf->loopback_);
TO_ROUTE_FULL(i, i) = e_route;
}
}
}
}
示例5: __MSG_host_create
/********************************* Host **************************************/
m_host_t __MSG_host_create(smx_host_t workstation, void *data)
{
const char *name;
simdata_host_t simdata = xbt_new0(s_simdata_host_t, 1);
m_host_t host = xbt_new0(s_m_host_t, 1);
int i;
char alias[MAX_ALIAS_NAME + 1] = { 0 }; /* buffer used to build the key of the mailbox */
name = SIMIX_host_get_name(workstation);
/* Host structure */
host->name = xbt_strdup(name);
host->simdata = simdata;
host->data = data;
simdata->smx_host = workstation;
if (msg_global->max_channel > 0)
simdata->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);
for (i = 0; i < msg_global->max_channel; i++) {
sprintf(alias, "%s:%d", name, i);
/* the key of the mailbox (in this case) is build from the name of the host and the channel number */
simdata->mailboxes[i] = MSG_mailbox_new(alias);
memset(alias, 0, MAX_ALIAS_NAME + 1);
}
SIMIX_req_host_set_data(workstation, host);
xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);
return host;
}
示例6: surf_model_init
/** @brief initialize common datastructures to all models */
surf_model_t surf_model_init(void)
{
s_surf_action_t action;
surf_model_t model = xbt_new0(s_surf_model_t, 1);
model->model_private = xbt_new0(s_surf_model_private_t, 1);
model->states.ready_action_set =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
model->states.running_action_set =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
model->states.failed_action_set =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
model->states.done_action_set =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
model->action_unref = int_die_impossible_paction;
model->action_cancel = void_die_impossible_paction;
model->action_recycle = void_die_impossible_paction;
model->action_state_get = surf_action_state_get;
model->action_state_set = surf_action_state_set;
model->action_get_start_time = surf_action_get_start_time;
model->action_get_finish_time = surf_action_get_finish_time;
model->action_data_set = surf_action_data_set;
model->model_private->modified_set = NULL;
model->model_private->action_heap = NULL;
model->model_private->update_mechanism = UM_UNDEFINED;
model->model_private->selective_update = 0;
return model;
}
示例7: __MSG_host_create
/********************************* Host **************************************/
msg_host_t __MSG_host_create(smx_host_t workstation)
{
const char *name = SIMIX_host_get_name(workstation);
msg_host_priv_t priv = xbt_new0(s_msg_host_priv_t, 1);
#ifdef MSG_USE_DEPRECATED
int i;
char alias[MAX_ALIAS_NAME + 1] = { 0 }; /* buffer used to build the key of the mailbox */
priv->mailboxes = (msg_global->max_channel > 0) ?
xbt_new0(msg_mailbox_t, msg_global->max_channel) : NULL;
for (i = 0; i < msg_global->max_channel; i++) {
sprintf(alias, "%s:%d", name, i);
/* the key of the mailbox (in this case) is build from the name of the host and the channel number */
priv->mailboxes[i] = MSG_mailbox_new(alias);
memset(alias, 0, MAX_ALIAS_NAME + 1);
}
#endif
priv->dp_objs = xbt_dict_new();
priv->dp_enabled = 0;
priv->dp_updated_by_deleted_tasks = 0;
priv->is_migrating = 0;
priv->affinity_mask_db = xbt_dict_new_homogeneous(NULL);
xbt_lib_set(host_lib, name, MSG_HOST_LEVEL, priv);
return xbt_lib_get_elm_or_null(host_lib, name);
}
示例8: action_reduce
static void action_reduce(const char *const *action)
{
int i;
char *reduce_identifier;
char mailbox[80];
double comm_size = parse_double(action[2]);
double comp_size = parse_double(action[3]);
msg_task_t comp_task = NULL;
const char *process_name;
double clock = MSG_get_clock();
process_globals_t counters =
(process_globals_t) MSG_process_get_data(MSG_process_self());
xbt_assert(communicator_size, "Size of Communicator is not defined, "
"can't use collective operations");
process_name = MSG_process_get_name(MSG_process_self());
reduce_identifier = bprintf("reduce_%d", counters->reduce_counter++);
if (!strcmp(process_name, "p0")) {
XBT_DEBUG("%s: %s is the Root", reduce_identifier, process_name);
msg_comm_t *comms = xbt_new0(msg_comm_t, communicator_size - 1);
msg_task_t *tasks = xbt_new0(msg_task_t, communicator_size - 1);
for (i = 1; i < communicator_size; i++) {
sprintf(mailbox, "%s_p%d_p0", reduce_identifier, i);
comms[i - 1] = MSG_task_irecv(&(tasks[i - 1]), mailbox);
}
MSG_comm_waitall(comms, communicator_size - 1, -1);
for (i = 1; i < communicator_size; i++) {
MSG_comm_destroy(comms[i - 1]);
MSG_task_destroy(tasks[i - 1]);
}
xbt_free(comms);
xbt_free(tasks);
comp_task = MSG_task_create("reduce_comp", comp_size, 0, NULL);
XBT_DEBUG("%s: computing 'reduce_comp'", reduce_identifier);
MSG_task_execute(comp_task);
MSG_task_destroy(comp_task);
XBT_DEBUG("%s: computed", reduce_identifier);
} else {
XBT_DEBUG("%s: %s sends", reduce_identifier, process_name);
sprintf(mailbox, "%s_%s_p0", reduce_identifier, process_name);
XBT_DEBUG("put on %s", mailbox);
MSG_task_send(MSG_task_create(reduce_identifier, 0, comm_size, NULL),
mailbox);
}
log_action(action, MSG_get_clock() - clock);
xbt_free(reduce_identifier);
}
示例9: parse_S_host
/**
* \brief Add a "host" to the network element list
*/
static void parse_S_host(sg_platf_host_cbarg_t host)
{
sg_routing_edge_t info = NULL;
if (current_routing->hierarchy == SURF_ROUTING_NULL)
current_routing->hierarchy = SURF_ROUTING_BASE;
xbt_assert(!xbt_lib_get_or_null(host_lib, host->id, ROUTING_HOST_LEVEL),
"Reading a host, processing unit \"%s\" already exists", host->id);
info = xbt_new0(s_routing_edge_t, 1);
info->rc_component = current_routing;
info->rc_type = SURF_NETWORK_ELEMENT_HOST;
info->name = xbt_strdup(host->id);
info->id = current_routing->parse_PU(current_routing, (void *) info);
xbt_lib_set(host_lib, host->id, ROUTING_HOST_LEVEL, (void *) info);
XBT_DEBUG("Having set name '%s' id '%d'",host->id,info->id);
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);
}
示例10: new_pajeDefineEventType
void new_pajeDefineEventType(type_t type)
{
paje_event_t event = xbt_new0(s_paje_event_t, 1);
event->event_type = PAJE_DefineEventType;
event->timestamp = 0;
event->print = active_writer.print_DefineEventType;
event->free = free_paje_event;
event->data = xbt_new0(s_defineEventType_t, 1);
((defineEventType_t)(event->data))->type = type;
XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
//print it
event->print (event);
event->free (event);
}
示例11: action_test
static void action_test(const char *const *action){
CHECK_ACTION_PARAMS(action, 0, 0);
double clock = smpi_process_simulated_elapsed();
MPI_Request request;
MPI_Status status;
int flag = TRUE;
request = xbt_dynar_pop_as(get_reqq_self(),MPI_Request);
//if request is null here, this may mean that a previous test has succeeded
//Different times in traced application and replayed version may lead to this
//In this case, ignore the extra calls.
if(request){
int rank = smpi_process_index();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type=TRACING_TEST;
TRACE_smpi_testing_in(rank, extra);
flag = smpi_mpi_test(&request, &status);
XBT_DEBUG("MPI_Test result: %d", flag);
/* push back request in dynar to be caught by a subsequent wait. if the test
* did succeed, the request is now NULL.
*/
xbt_dynar_push_as(get_reqq_self(),MPI_Request, request);
TRACE_smpi_testing_out(rank);
}
log_timed_action (action, clock);
}
示例12: new_pajeNewEvent
void new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value)
{
paje_event_t event = xbt_new0(s_paje_event_t, 1);
event->event_type = PAJE_NewEvent;
event->timestamp = timestamp;
event->print = active_writer.print_NewEvent;
event->free = free_paje_event;
event->data = xbt_new0(s_newEvent_t, 1);
((newEvent_t)(event->data))->type = type;
((newEvent_t)(event->data))->container = container;
((newEvent_t)(event->data))->value = value;
XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
insert_into_buffer (event);
}
示例13: model_rulebased_parse_route
static void model_rulebased_parse_route(AS_t rc, sg_platf_route_cbarg_t route)
{
char *src = (char*)(route->src);
char *dst = (char*)(route->dst);
AS_rulebased_t routing = (AS_rulebased_t) rc;
rule_route_t ruleroute = xbt_new0(s_rule_route_t, 1);
const char *error;
int erroffset;
if(!strcmp(rc->model_desc->name,"Vivaldi")){
if(!xbt_dynar_is_empty(route->link_list))
xbt_die("You can't have link_ctn with Model Vivaldi.");
}
ruleroute->re_src = pcre_compile(src, 0, &error, &erroffset, NULL);
xbt_assert(ruleroute->re_src,
"PCRE compilation failed at offset %d (\"%s\"): %s\n",
erroffset, src, error);
ruleroute->re_dst = pcre_compile(dst, 0, &error, &erroffset, NULL);
xbt_assert(ruleroute->re_src,
"PCRE compilation failed at offset %d (\"%s\"): %s\n",
erroffset, dst, error);
ruleroute->re_str_link = route->link_list;
route->link_list = NULL; // Don't free it twice in each container
xbt_dynar_push(routing->list_route, &ruleroute);
}
示例14: 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;
}
示例15: action_Isend
static void action_Isend(const char *const *action)
{
CHECK_ACTION_PARAMS(action, 2, 1);
int to = atoi(action[2]);
double size=parse_double(action[3]);
double clock = smpi_process_simulated_elapsed();
MPI_Request request;
if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]);
else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
int rank = smpi_process_index();
int dst_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), to);
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_ISEND;
extra->send_size = size;
extra->src = rank;
extra->dst = dst_traced;
extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL);
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
if (!TRACE_smpi_view_internals()) {
TRACE_smpi_send(rank, rank, dst_traced, size*smpi_datatype_size(MPI_CURRENT_TYPE));
}
request = smpi_mpi_isend(NULL, size, MPI_CURRENT_TYPE, to, 0,MPI_COMM_WORLD);
TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
request->send = 1;
xbt_dynar_push(get_reqq_self(),&request);
log_timed_action (action, clock);
}