int TRACE_start() { TRACE_getopts(); // tracing system must be: // - enabled (with --cfg=tracing:1) // - already configured (TRACE_global_init already called) if (!(TRACE_is_enabled() && TRACE_is_configured())){ return 0; } XBT_DEBUG("Tracing starts"); /* open the trace file */ TRACE_paje_start(); /* activate trace */ if (trace_active == 1){ THROWF (tracing_error, 0, "Tracing is already active"); } trace_active = 1; XBT_DEBUG ("Tracing is on"); /* other trace initialization */ created_categories = xbt_dict_new_homogeneous(xbt_free); declared_marks = xbt_dict_new_homogeneous (xbt_free); user_host_variables = xbt_dict_new_homogeneous (xbt_free); user_link_variables = xbt_dict_new_homogeneous (xbt_free); TRACE_surf_alloc(); TRACE_smpi_alloc(); return 0; }
/** @brief Initializes the replay mechanism, and returns true if (and only if) it was necessary * * It returns false if it was already done by another process. */ int _xbt_replay_action_init(void) { if (xbt_action_funs) return 0; is_replay_active = 1; xbt_action_funs = xbt_dict_new_homogeneous(NULL); xbt_action_queues = xbt_dict_new_homogeneous(NULL); return 1; }
int TRACE_start() { if (TRACE_is_configured()) TRACE_getopts(); // tracing system must be: // - enabled (with --cfg=tracing:yes) // - already configured (TRACE_global_init already called) if (TRACE_is_enabled()) { XBT_DEBUG("Tracing starts"); /* init the tracing module to generate the right output */ /* open internal buffer */ TRACE_init(); /* open the trace file(s) */ const char* format = sg_cfg_get_string(OPT_TRACING_FORMAT); XBT_DEBUG("Tracing format %s\n", format); if(!strcmp(format, "Paje")){ TRACE_paje_init(); TRACE_paje_start(); }else if (!strcmp(format, "TI")){ TRACE_TI_init(); TRACE_TI_start(); }else{ xbt_die("Unknown trace format :%s ", format); } /* activate trace */ if (trace_active == 1) { THROWF(tracing_error, 0, "Tracing is already active"); } trace_active = 1; XBT_DEBUG("Tracing is on"); /* other trace initialization */ created_categories = xbt_dict_new_homogeneous(xbt_free_f); declared_marks = xbt_dict_new_homogeneous(xbt_free_f); user_host_variables = xbt_dict_new_homogeneous(xbt_free_f); user_vm_variables = xbt_dict_new_homogeneous(xbt_free_f); user_link_variables = xbt_dict_new_homogeneous(xbt_free_f); if (TRACE_start_functions != NULL) { void (*func) (); unsigned int iter = xbt_dynar_length(TRACE_start_functions); xbt_dynar_foreach(TRACE_start_functions, iter, func) { func(); } } }
void NetworkSmpiModel::gapAppend(double size, Link* link, NetworkAction *act) { const char *src = link->getName(); xbt_fifo_t fifo; NetworkCm02Action *action= static_cast<NetworkCm02Action*>(act); if (sg_sender_gap > 0.0) { if (!gap_lookup) { gap_lookup = xbt_dict_new_homogeneous(nullptr); } fifo = (xbt_fifo_t) xbt_dict_get_or_null(gap_lookup, src); action->senderGap_ = 0.0; if (fifo && xbt_fifo_size(fifo) > 0) { /* Compute gap from last send */ /*last_action = (surf_action_network_CM02_t) xbt_fifo_get_item_content(xbt_fifo_get_last_item(fifo));*/ // bw = net_get_link_bandwidth(link); action->senderGap_ = sg_sender_gap; /* max(sg_sender_gap,last_action->sender.size / bw);*/ action->latency_ += action->senderGap_; } /* Append action as last send */ /*action->sender.link_name = link->lmm_resource.generic_resource.name; fifo = (xbt_fifo_t) xbt_dict_get_or_null(gap_lookup, action->sender.link_name); if (!fifo) { fifo = xbt_fifo_new(); xbt_dict_set(gap_lookup, action->sender.link_name, fifo, nullptr); } action->sender.fifo_item = xbt_fifo_push(fifo, action);*/ action->senderSize_ = size; } }
/********************************* 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); }
int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; MSG_init(&argc, argv); /* Explicit initialization of the action module is required now*/ MSG_action_init(); xbt_assert(argc > 3,"Usage: %s platform_file deployment_file [action_files]\n" "\texample: %s platform.xml deployment.xml actions # if all actions are in the same file\n" "\texample: %s platform.xml deployment.xml # if actions are in separate files, specified in deployment\n", argv[0], argv[0], argv[0]); MSG_create_environment(argv[1]); MSG_launch_application(argv[2]); /* Action registration */ xbt_replay_action_register("open", action_open); xbt_replay_action_register("read", action_read); xbt_replay_action_register("close", action_close); if (!opened_files) opened_files = xbt_dict_new_homogeneous(NULL); /* Actually do the simulation using MSG_action_trace_run */ res = MSG_action_trace_run(argv[3]); // it's ok to pass a NULL argument here XBT_INFO("Simulation time %g", MSG_get_clock()); if (opened_files) xbt_dict_free(&opened_files); /* Explicit finalization of the action module is required now*/ MSG_action_exit(); return res!=MSG_OK; }
/** \ingroup m_task_management * \brief Creates a new #msg_task_t. * * A constructor for #msg_task_t taking four arguments and returning the corresponding object. * \param name a name for the object. It is for user-level information and can be NULL. * \param flop_amount a value of the processing amount (in flop) needed to process this new task. If 0, then it cannot be executed with MSG_task_execute(). This value has to be >=0. * \param message_size a value of the amount of data (in bytes) needed to transfer this new task. If 0, then it cannot be transfered with MSG_task_send() and MSG_task_recv(). This value has to be >=0. * \param data a pointer to any data may want to attach to the new object. It is for user-level information and can be NULL. It can be retrieved with the function \ref MSG_task_get_data. * \see msg_task_t * \return The new corresponding object. */ msg_task_t MSG_task_create(const char *name, double flop_amount, double message_size, void *data) { msg_task_t task = xbt_new(s_msg_task_t, 1); simdata_task_t simdata = xbt_new(s_simdata_task_t, 1); task->simdata = simdata; /* Task structure */ task->name = xbt_strdup(name); task->data = data; /* Simulator Data */ simdata->compute = NULL; simdata->comm = NULL; simdata->bytes_amount = message_size; simdata->flops_amount = flop_amount; simdata->sender = NULL; simdata->receiver = NULL; simdata->source = NULL; simdata->priority = 1.0; simdata->bound = 0; simdata->affinity_mask_db = xbt_dict_new_homogeneous(NULL); simdata->rate = -1.0; simdata->isused = 0; simdata->host_nb = 0; simdata->host_list = NULL; simdata->flops_parallel_amount = NULL; simdata->bytes_parallel_amount = NULL; TRACE_msg_task_create(task); return task; }
/** \ingroup m_task_management * \brief Creates a new #msg_task_t. * * A constructor for #msg_task_t taking four arguments and returning the corresponding object. * \param name a name for the object. It is for user-level information and can be NULL. * \param compute_duration a value of the processing amount (in flop) needed to process this new task. If 0, then it cannot be executed with MSG_task_execute(). This value has to be >=0. * \param message_size a value of the amount of data (in bytes) needed to transfer this new task. If 0, then it cannot be transfered with MSG_task_send() and MSG_task_recv(). This value has to be >=0. * \param data a pointer to any data may want to attach to the new object. It is for user-level information and can be NULL. It can be retrieved with the function \ref MSG_task_get_data. * \see msg_task_t * \return The new corresponding object. */ msg_task_t MSG_task_create(const char *name, double compute_duration, double message_size, void *data) { msg_task_t task = xbt_new(s_msg_task_t, 1); simdata_task_t simdata = xbt_new(s_simdata_task_t, 1); task->simdata = simdata; /* Task structure */ task->name = xbt_strdup(name); task->data = data; /* Simulator Data */ simdata->compute = NULL; simdata->comm = NULL; simdata->message_size = message_size; simdata->computation_amount = compute_duration; simdata->sender = NULL; simdata->receiver = NULL; simdata->source = NULL; simdata->priority = 1.0; simdata->bound = 0; simdata->affinity_mask_db = xbt_dict_new_homogeneous(NULL); simdata->rate = -1.0; simdata->isused = 0; simdata->host_nb = 0; simdata->host_list = NULL; simdata->comp_amount = NULL; simdata->comm_amount = NULL; #ifdef HAVE_TRACING TRACE_msg_task_create(task); #endif return task; }
void print_TICreateContainer(paje_event_t event) { //if we are in the mode with only one file static FILE *temp = nullptr; if (tracing_files == nullptr) { tracing_files = xbt_dict_new_homogeneous(nullptr); //generate unique run id with time prefix = xbt_os_time(); } if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || temp == nullptr) { char *folder_name = bprintf("%s_files", TRACE_get_filename()); char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, ((createContainer_t) event->data)->container->name); #ifdef WIN32 _mkdir(folder_name); #else mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO); #endif temp = fopen(filename, "w"); xbt_assert(temp, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno)); fprintf(tracing_file, "%s\n", filename); xbt_free(folder_name); xbt_free(filename); } xbt_dict_set(tracing_files, ((createContainer_t) event->data)->container->name, (void *) temp, nullptr); }
/** * \brief Constructor * \return pointer to the destination * \see xbt_dict_free() * * Creates and initialize a new dictionary with a default hashtable size. * The dictionary is heterogeneous: each element can have a different free * function. */ xbt_dict_t xbt_dict_new(void) { xbt_dict_t dict = xbt_dict_new_homogeneous(NULL); dict->homogeneous = 0; return dict; }
/********************************* 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; }
/** @brief loads a DOT file describing a DAG * * See http://www.graphviz.org/doc/info/lang.html * for more details. * To obtain information about transfers and tasks, two attributes are * required : size on task (execution time in Flop) and size on edge * (the amount of data transfer in bit). * if they aren't here, there choose to be equal to zero. */ xbt_dynar_t SD_dotload(const char *filename) { computers = xbt_dict_new_homogeneous(NULL); schedule = false; SD_dotload_generic(filename, sequential); xbt_dynar_t computer = NULL; xbt_dict_cursor_t dict_cursor; char *computer_name; xbt_dict_foreach(computers,dict_cursor,computer_name,computer){ xbt_dynar_free(&computer); }
void* smpi_shared_set_call(const char* func, const char* input, void* data) { char* loc = bprintf("%s:%s", func, input); if(!calls) { calls = xbt_dict_new_homogeneous(NULL); } xbt_dict_set(calls, loc, data, NULL); free(loc); return data; }
void STag_surfxml_prop(void) { if(AS_TAG){ 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 %p for AS '%s'",as_dict_tab[as_prop_nb],as_name_tab[as_prop_nb]); as_prop_nb++; } xbt_dict_set(as_current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), NULL); } else{ if (!current_property_set) current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), NULL); } }
xbt_dict_t Storage::getContent() { /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */ xbt_dict_t content_dict = xbt_dict_new_homogeneous(NULL); xbt_dict_cursor_t cursor = NULL; char *file; sg_size_t *psize; xbt_dict_foreach(p_content, cursor, file, psize){ xbt_dict_set(content_dict,file,psize,NULL); }
int main(int argc, char *argv[]) { /* Check the given arguments */ MSG_init(&argc, argv); /* Explicit initialization of the action module is required now*/ MSG_action_init(); // MSG_config("surf/precision","1e-9"); MSG_create_environment(argv[1]); /* Simulation setting */ msg_error_t res = MSG_OK; /* No need to register functions as in classical MSG programs: the actions get started anyway */ MSG_launch_application(argv[2]); char *wh=argv[4]; XBT_INFO("Your choose is %s",wh); xbt_replay_action_register("unlink", simsleep);//register the action xbt_replay_action_register("compute", simsleep);//register the action xbt_replay_action_register("access", simsleep); xbt_replay_action_register("stat", simsleep); xbt_replay_action_register("flush", simsleep); xbt_replay_action_register("readdir", simsleep); xbt_replay_action_register("getxattr", simsleep); xbt_replay_action_register("mkdir", simsleep); xbt_replay_action_register("symlink", simsleep); xbt_replay_action_register("readlink", simsleep); if(strcmp(wh,"action")==0) //decide which mode to run /* Action registration */ { xbt_replay_action_register("open", simopen); xbt_replay_action_register("release", simrelease); xbt_replay_action_register("read", simread); xbt_replay_action_register("creat", simcreat); xbt_replay_action_register("write", simwrite); } else if(strcmp(wh,"sleep")==0){ xbt_replay_action_register("open", simsleep); xbt_replay_action_register("release", simsleep); xbt_replay_action_register("read", simsleep); xbt_replay_action_register("creat", simsleep); xbt_replay_action_register("write", simsleep); } if(!opened_files) {opened_files = xbt_dict_new_homogeneous(NULL);} res = MSG_action_trace_run(argv[3]); // it's ok to pass a NULL argument here XBT_INFO("Simulation time %g", MSG_get_clock()); if(opened_files) {xbt_dict_free(&opened_files);} MSG_action_exit(); return !!MSG_OK; }
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); }
/** \ingroup m_host_management * \brief Return the content of mounted storages on an host. * \param host a host * \return a dict containing content (as a dict) of all storages mounted on the host */ xbt_dict_t MSG_host_get_storage_content(msg_host_t host) { xbt_assert((host != NULL), "Invalid parameters"); xbt_dict_t contents = xbt_dict_new_homogeneous(NULL); msg_storage_t storage; char* storage_name; char* mount_name; xbt_dict_cursor_t cursor = NULL; xbt_dict_t storage_list = simcall_host_get_mounted_storage_list(host); xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){ storage = (msg_storage_t)xbt_lib_get_elm_or_null(storage_lib,storage_name); xbt_dict_t content = simcall_storage_get_content(storage); xbt_dict_set(contents,mount_name, content,NULL); }
void *smpi_shared_malloc(size_t size, const char *file, int line) { char *loc = bprintf("%zu_%s_%d", (size_t)getpid(), file, line); size_t len = strlen(loc); size_t i; int fd; void* mem; shared_data_t *data; for(i = 0; i < len; i++) { /* Make the 'loc' ID be a flat filename */ if(loc[i] == '/') { loc[i] = '_'; } } if (!allocs) { allocs = xbt_dict_new_homogeneous(free); } data = xbt_dict_get_or_null(allocs, loc); if(!data) { fd = shm_open(loc, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if(fd < 0) { switch(errno) { case EEXIST: xbt_die("Please cleanup /dev/shm/%s", loc); default: xbt_die("An unhandled error occured while opening %s: %s", loc, strerror(errno)); } } data = xbt_new(shared_data_t, 1); data->fd = fd; data->count = 1; data->loc = loc; mem = shm_map(fd, size, data); if(shm_unlink(loc) < 0) { XBT_WARN("Could not early unlink %s: %s", loc, strerror(errno)); } xbt_dict_set(allocs, loc, data, NULL); XBT_DEBUG("Mapping %s at %p through %d", loc, mem, fd); } else { mem = shm_map(data->fd, size, data); data->count++; } XBT_DEBUG("Malloc %zu in %p (metadata at %p)", size, mem, data); return mem; }
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_homogeneous(free); 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), NULL); xbt_dynar_free(&keyvals); }
/********************************* 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; }
ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb, void **workstation_list, double *computation_amount, double *communication_amount, double rate) { WorkstationL07ActionPtr action; int i, j; unsigned int cpt; int nb_link = 0; int nb_host = 0; double latency = 0.0; if (ptask_parallel_task_link_set == NULL) ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL); xbt_dict_reset(ptask_parallel_task_link_set); /* Compute the number of affected resources... */ for (i = 0; i < workstation_nb; i++) { for (j = 0; j < workstation_nb; j++) { xbt_dynar_t route=NULL; if (communication_amount[i * workstation_nb + j] > 0) { double lat=0.0; unsigned int cpt; void *_link; LinkL07Ptr link; routing_platf->getRouteAndLatency(static_cast<WorkstationL07Ptr>(workstation_list[i])->p_netElm, static_cast<WorkstationL07Ptr>(workstation_list[j])->p_netElm, &route, &lat); latency = MAX(latency, lat); xbt_dynar_foreach(route, cpt, _link) { link = static_cast<LinkL07Ptr>(_link); xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL); } } }
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); } }
/** \ingroup smpi_simulation * \brief Registers a running instance of a MPI program. * * FIXME : remove MSG from the loop at some point. * \param name the reference name of the function. * \param code the main mpi function (must have a int ..(int argc, char *argv[])) prototype * \param num_processes the size of the instance we want to deploy */ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_processes) { SIMIX_function_register(name, code); s_smpi_mpi_instance_t* instance = (s_smpi_mpi_instance_t*)xbt_malloc(sizeof(s_smpi_mpi_instance_t)); instance->name = name; instance->size = num_processes; instance->present_processes = 0; instance->index = process_count; instance->comm_world = MPI_COMM_NULL; instance->finalization_barrier=xbt_barrier_init(num_processes); process_count+=num_processes; if(smpi_instances==nullptr){ smpi_instances = xbt_dict_new_homogeneous(xbt_free_f); } xbt_dict_set(smpi_instances, name, (void*)instance, nullptr); return; }
int smpi_shared_known_call(const char* func, const char* input) { char* loc = bprintf("%s:%s", func, input); xbt_ex_t ex; int known; if(!calls) { calls = xbt_dict_new_homogeneous(NULL); } TRY { xbt_dict_get(calls, loc); /* Succeed or throw */ known = 1; } CATCH(ex) { if(ex.category == not_found_error) { known = 0; xbt_ex_free(ex); } else { RETHROW; } } free(loc); return known; }
void 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, unrelated computation into account */ if (!samples) samples = xbt_dict_new_homogeneous(free); data = xbt_dict_get_or_null(samples, loc); if (!data) { xbt_assert(threshold>0 || iters>0, "You should provide either a positive amount of iterations to bench, or a positive maximal stderr (or both)"); 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->benching = 1; // If we have no data, we need at least one data->mean = 0; xbt_dict_set(samples, loc, data, NULL); XBT_DEBUG("XXXXX First time ever on benched nest %s.",loc); } else { if (data->iters != iters || data->threshold != threshold) { XBT_ERROR("Asked to bench block %s with different settings %d, %f is not %d, %f. How did you manage to give two numbers at the same line??", loc, data->iters, data->threshold, iters,threshold); THROW_IMPOSSIBLE; } // if we already have some data, check whether sample_2 should get one more bench or whether it should emulate the computation instead data->benching = !sample_enough_benchs(data); XBT_DEBUG("XXXX Re-entering the benched nest %s. %s",loc, (data->benching?"more benching needed":"we have enough data, skip computes")); } free(loc); }
xbt_dict_t Storage::parseContent(char *filename) { m_usedSize = 0; if ((!filename) || (strcmp(filename, "") == 0)) return NULL; xbt_dict_t parse_content = xbt_dict_new_homogeneous(xbt_free_f); FILE *file = NULL; file = surf_fopen(filename, "r"); if (file == NULL) xbt_die("Cannot open file '%s' (path=%s)", filename, xbt_str_join(surf_path, ":")); char *line = NULL; size_t len = 0; ssize_t read; char path[1024]; sg_size_t size; while ((read = xbt_getline(&line, &len, file)) != -1) { if (read){ if(sscanf(line,"%s %llu", path, &size) == 2) { m_usedSize += size; sg_size_t *psize = xbt_new(sg_size_t, 1); *psize = size; xbt_dict_set(parse_content,path,psize,NULL); } else { xbt_die("Be sure of passing a good format for content file.\n"); } } } free(line); fclose(file); return parse_content; }
void TRACE_smpi_alloc() { keys = xbt_dict_new_homogeneous(xbt_dynar_free_voidp); process_category = xbt_dict_new_homogeneous(xbt_free); }
/* This function acts as a main in the parsing area. */ void parse_platform_file(const char *file) { #if HAVE_LUA int is_lua = (file != NULL && strlen(file) > 3 && file[strlen(file)-3] == 'l' && file[strlen(file)-2] == 'u' && file[strlen(file)-1] == 'a'); #endif sg_platf_init(); #if HAVE_LUA /* Check if file extension is "lua". If so, we will use * the lua bindings to parse the platform file (since it is * written in lua). If not, we will use the (old?) XML parser */ if (is_lua) { lua_State* L = luaL_newstate(); luaL_openlibs(L); luaL_loadfile(L, file); // This loads the file without executing it. /* Run the script */ if (lua_pcall(L, 0, 0, 0)) { XBT_ERROR("FATAL ERROR:\n %s: %s\n\n", "Lua call failed. Errormessage:", lua_tostring(L, -1)); xbt_die("Lua call failed. See Log"); } } else #endif { // Use XML parser int parse_status; /* init the flex parser */ surfxml_buffer_stack_stack_ptr = 1; surfxml_buffer_stack_stack[0] = 0; after_config_done = 0; surf_parse_open(file); traces_set_list = xbt_dict_new_homogeneous(NULL); trace_connect_list_host_avail = xbt_dict_new_homogeneous(free); trace_connect_list_host_speed = xbt_dict_new_homogeneous(free); trace_connect_list_link_avail = xbt_dict_new_homogeneous(free); trace_connect_list_link_bw = xbt_dict_new_homogeneous(free); trace_connect_list_link_lat = xbt_dict_new_homogeneous(free); /* Init my data */ if (!surfxml_bufferstack_stack) surfxml_bufferstack_stack = xbt_dynar_new(sizeof(char *), NULL); /* Do the actual parsing */ parse_status = surf_parse(); /* connect all traces relative to hosts */ xbt_dict_cursor_t cursor = NULL; char *trace_name, *elm; xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); xbt_assert(trace, "Trace %s undefined", trace_name); simgrid::s4u::Host *host = sg_host_by_name(elm); xbt_assert(host, "Host %s undefined", elm); simgrid::surf::Cpu *cpu = host->pimpl_cpu; cpu->setStateTrace(trace); } xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); xbt_assert(trace, "Trace %s undefined", trace_name); simgrid::s4u::Host *host = sg_host_by_name(elm); xbt_assert(host, "Host %s undefined", elm); simgrid::surf::Cpu *cpu = host->pimpl_cpu; cpu->setSpeedTrace(trace); }
void TRACE_surf_resource_utilization_alloc() { platform_variables = xbt_dict_new_homogeneous(NULL); }