void gras_process_init() { char **env_iter; _gras_procdata = xbt_new0(gras_procdata_t, 1); gras_procdata_init(); /* initialize the host & process properties */ _host_properties = xbt_dict_new(); _process_properties = xbt_dict_new(); env_iter = environ; while (*env_iter) { char *equal, *buf = xbt_strdup(*env_iter); equal = strchr(buf, '='); if (!equal) { XBT_WARN ("The environment contains an entry without '=' char: %s (ignore it)", *env_iter); continue; } *equal = '\0'; xbt_dict_set(_process_properties, buf, xbt_strdup(equal + 1), xbt_free_f); free(buf); env_iter++; } }
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); } } */ }
/********************************* 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; }
/********************************* 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); }
static void* shm_map(int fd, size_t size, shared_data_t* data) { void* mem; char loc[PTR_STRLEN]; shared_metadata_t* meta; if(size > shm_size(fd)) { if(ftruncate(fd, (off_t)size) < 0) { xbt_die("Could not truncate fd %d to %zu: %s", fd, size, strerror(errno)); } } mem = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if(mem == MAP_FAILED) { xbt_die("Could not map fd %d: %s", fd, strerror(errno)); } if(!allocs_metadata) { allocs_metadata = xbt_dict_new(); } snprintf(loc, PTR_STRLEN, "%p", mem); meta = xbt_new(shared_metadata_t, 1); meta->size = size; meta->data = data; xbt_dict_set(allocs_metadata, loc, meta, &free); XBT_DEBUG("MMAP %zu to %p", size, mem); return mem; }
void gras_emul_init(void) { if (!benchmark_set) { benchmark_set = xbt_dict_new(); timer = xbt_os_timer_new(); } }
static void IB_create_host_callback(sg_platf_host_cbarg_t t){ static int id=0; // pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL) ((NetworkIBModel*)surf_network_model)->active_nodes=xbt_dict_new(); IBNode* act = new IBNode(id); id++; xbt_dict_set(((NetworkIBModel*)surf_network_model)->active_nodes, t->id, act, NULL); }
/********************************* 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); 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); priv->file_descriptor_table = xbt_dynar_new(sizeof(int), NULL); for (int i=1023; i>=0;i--) xbt_dynar_push_as(priv->file_descriptor_table, int, i); sg_host_msg_set(host,priv); return host; }
static void mytest(const char *input, const char *patterns, const char *expected) { xbt_dynar_t dyn_patterns; /* splited string */ xbt_dict_t p; /* patterns */ unsigned int cpt; char *str; /*foreach */ xbt_strbuff_t sb; /* what we test */ p = xbt_dict_new(); dyn_patterns = xbt_str_split(patterns, " "); xbt_dynar_foreach(dyn_patterns, cpt, str) { xbt_dynar_t keyvals = xbt_str_split(str, "="); char *key = xbt_dynar_get_as(keyvals, 0, char *); char *val = xbt_dynar_get_as(keyvals, 1, char *); xbt_str_subst(key, '_', ' ', 0); // to put space in names without breaking the enclosing dynar_foreach xbt_dict_set(p, key, xbt_strdup(val), free); xbt_dynar_free(&keyvals); }
void xbt_multidict_set_ext(xbt_dict_t mdict, xbt_dynar_t keys, xbt_dynar_t lens, void *data, void_f_pvoid_t free_ctn) { xbt_dict_t thislevel, nextlevel = NULL; int i; unsigned long int thislen; char *thiskey; int keys_len = xbt_dynar_length(keys); xbt_assert(xbt_dynar_length(keys) == xbt_dynar_length(lens)); xbt_assert(keys_len, "Can't set a zero-long key set in a multidict"); XBT_DEBUG("xbt_multidict_set(%p,%d)", mdict, keys_len); for (i = 0, thislevel = mdict; i < keys_len - 1; i++, thislevel = nextlevel) { xbt_dynar_get_cpy(keys, i, &thiskey); xbt_dynar_get_cpy(lens, i, &thislen); XBT_DEBUG("multi_set: at level %d, len=%ld, key=%p |%*s|", i, thislen, thiskey, (int) thislen, thiskey); /* search the dict of next level */ nextlevel = xbt_dict_get_or_null_ext(thislevel, thiskey, thislen); if (nextlevel == NULL) { /* make sure the dict of next level exists */ nextlevel = xbt_dict_new(); XBT_VERB("Create a dict (%p)", nextlevel); xbt_dict_set_ext(thislevel, thiskey, thislen, nextlevel, &_free_dict); } } xbt_dynar_get_cpy(keys, i, &thiskey); xbt_dynar_get_cpy(lens, i, &thislen); xbt_dict_set_ext(thislevel, thiskey, thislen, data, free_ctn); }
void *smpi_shared_malloc(size_t size, const char *file, int line) { char *loc = bprintf("%s:%d:%zu", file, line, size); shared_data_t *data; if (!allocs) { allocs = xbt_dict_new(); } data = xbt_dict_get_or_null(allocs, loc); if (!data) { data = (shared_data_t *) xbt_malloc0(sizeof(int) + size); data->count = 1; xbt_dict_set(allocs, loc, data, &free); } else { data->count++; } free(loc); return data->data; }
void STag_surfxml_prop(void) { if(AS_TAG){ // We need a stack here to retrieve the most recently opened AS if (!as_current_property_set){ xbt_assert(as_prop_nb < 1024, "Number of AS property reach the limit!!!"); as_current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error as_name_tab[as_prop_nb] = xbt_strdup(A_surfxml_AS_id); as_dict_tab[as_prop_nb] = as_current_property_set; XBT_DEBUG("PUSH prop set %p for AS '%s'",as_dict_tab[as_prop_nb],as_name_tab[as_prop_nb]); as_prop_nb++; } XBT_DEBUG("add prop %s=%s into current AS property set", A_surfxml_prop_id, A_surfxml_prop_value); xbt_dict_set(as_current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), nullptr); } else{ if (!current_property_set) current_property_set = xbt_dict_new(); // Maybe, it should raise an error xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), xbt_free_f); XBT_DEBUG("add prop %s=%s into current property set", A_surfxml_prop_id, A_surfxml_prop_value); } }
int smpi_sample_1(int global, const char *file, int line, int iters, double threshold) { char *loc = sample_location(global, file, line); local_data_t *data; smpi_bench_end(); /* Take time from previous MPI call into account */ if (!samples) { samples = xbt_dict_new(); } data = xbt_dict_get_or_null(samples, loc); if (!data) { data = (local_data_t *) xbt_new(local_data_t, 1); data->count = 0; data->sum = 0.0; data->sum_pow2 = 0.0; data->iters = iters; data->threshold = threshold; data->started = 0; xbt_dict_set(samples, loc, data, &free); return 0; } free(loc); return 1; }
void simbatch_init(int *argc, char **argv) { const char *config_file; const char *deployment_file; const char *request = "/config/global/file[@type=\"deployment\"]/text()"; //const char *req = "/platform_description/process[@function=\"SB_batch\"]"; if (parseCmdLine(*argc, argv)) { xbt_die("Error parsing command line"); } config_file = getParam(argv, "-f"); #ifdef VERBOSE { int i = 0; fprintf(stderr, "*** Global init ***\n"); fprintf(stderr, "DIET MODE %s\n", (DIET_MODE)? "enabled": "disable"); fprintf(stderr, "DIET FILE %s\n", (DIET_FILE)? DIET_FILE: "disable"); for (i=0; i<4; ++i) fprintf(stderr, "DIET_PARAM[%d] = %lu\n", i, DIET_PARAM[i]); fprintf(stderr, "Loading config file %s... ", config_file); } #endif config = config_load(config_file); if (!config) { #ifdef VERBOSE fprintf(stderr, "failed\n"); fprintf(stderr, "Usage : %s -f simbatch_config.xml\n", argv[0]); #endif free(config); xbt_die("Cant'load config file"); } #ifdef VERBOSE fprintf(stderr, "ok\n"); fprintf(stderr, "Check batch deployed and batch defined... "); #endif nbBatch = config_get_nb_nodes("/config/batch"); deployment_file = config_get_value(request); /* * A bit dirty - I need just one value in the deployment file * So i do a context switch instead of changing my functions *//* { config_t * config_backup = config; config = config_load(deployment_file); if (!config) { #ifdef VERBOSE fprintf(stderr, "failed\n"); #endif free(config_backup); xbt_die("Cant'load deployment file"); } nbBatchDeployed = config_get_nb_nodes(req); free(config); config = config_backup; } if (nbBatchDeployed != nbBatch) { #ifdef VERBOSE fprintf(stderr, "failed\n"); #endif free(config); xbt_die("Batch deployed are not equal to batch defined"); } #ifdef VERBOSE fprintf(stderr, "ok\n"); if (nbBatch <= 0) fprintf(stderr, "Warning no batch used\n"); fprintf(stderr, "Number of batch defined : %d\n", nbBatch); #endif */ book_of_plugin = xbt_dict_new(); #ifdef LOG book_of_log = xbt_dict_new(); config_init_log_file(); #endif }