/** @brief When reaching EOF, check whether we are in an include tag, and behave accordingly if yes * * This function is called automatically by sedding the parser in tools/cmake/MaintainerMode.cmake * Every FAIL on "Premature EOF" is preceded by a call to this function, which role is to restore the * previous buffer if we reached the EOF /of an include file/. Its return code is used to avoid the * error message in that case. * * Yeah, that's terribly hackish, but it works. A better solution should be dealed with in flexml * directly: a command line flag could instruct it to do the correct thing when #include is encountered * on a line. One day maybe, if the maya allow it. */ int ETag_surfxml_include_state(void) { fflush(nullptr); XBT_DEBUG("ETag_surfxml_include_state '%s'",A_surfxml_include_file); if(xbt_dynar_is_empty(surf_input_buffer_stack)) // nope, that's a true premature EOF. Let the parser die verbosely. return 0; // Yeah, we were in an <include> Restore state and proceed. fclose(surf_file_to_parse); xbt_dynar_pop(surf_file_to_parse_stack, &surf_file_to_parse); surf_parse_pop_buffer_state(); xbt_dynar_pop(surf_input_buffer_stack,&surf_input_buffer); // Restore the filename for error messages free(surf_parsed_filename); xbt_dynar_pop(surf_parsed_filename_stack,&surf_parsed_filename); return 1; }
double NetworkModel::next_occuring_event_full(double now) { NetworkAction *action = NULL; ActionList *runningActions = surf_network_model->getRunningActionSet(); double minRes; minRes = shareResourcesMaxMin(runningActions, surf_network_model->maxminSystem_, surf_network_model->f_networkSolve); for(ActionList::iterator it(runningActions->begin()), itend(runningActions->end()) ; it != itend ; ++it) { action = static_cast<NetworkAction*>(&*it); if (action->latency_ > 0) { minRes = (minRes < 0) ? action->latency_ : std::min(minRes, action->latency_); } } XBT_DEBUG("Min of share resources %f", minRes); return minRes; }
void new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key, int size) { paje_event_t event = xbt_new0(s_paje_event_t, 1); event->event_type = PAJE_StartLink; event->timestamp = timestamp; event->print = active_writer.print_StartLink; event->free = &free_paje_event; event->data = xbt_new0(s_startLink_t, 1); (static_cast<startLink_t>(event->data))->type = type; (static_cast<startLink_t>(event->data))->container = container; (static_cast<startLink_t>(event->data))->sourceContainer = sourceContainer; (static_cast<startLink_t>(event->data))->value = xbt_strdup(value); (static_cast<startLink_t>(event->data))->key = xbt_strdup(key); (static_cast<startLink_t>(event->data))->size = size; XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); insert_into_buffer (event); }
static std::vector<double> surf_parse_get_all_speeds(char* speeds, const char* entity_kind, std::string id) { std::vector<double> speed_per_pstate; if (strchr(speeds, ',') == nullptr){ double speed = surf_parse_get_speed(speeds, entity_kind, id); speed_per_pstate.push_back(speed); } else { std::vector<std::string> pstate_list; boost::split(pstate_list, speeds, boost::is_any_of(",")); for (auto speed_str : pstate_list) { boost::trim(speed_str); double speed = surf_parse_get_speed(speed_str.c_str(), entity_kind, id); speed_per_pstate.push_back(speed); XBT_DEBUG("Speed value: %f", speed); } } return speed_per_pstate; }
/** \ingroup msg_file_management * \brief Write into a file (local or remote) * * \param size of the file to write * \param fd is a the file descriptor * \return the number of bytes successfully write or -1 if an error occurred */ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size) { msg_file_priv_t file_priv = MSG_file_priv(fd); sg_size_t write_size, offset; /* Find the host where the file is physically located (remote or local)*/ msg_storage_t storage_src =(msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId); msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src); msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname); if(strcmp(storage_priv_src->hostname, MSG_host_get_name(MSG_host_self()))){ /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */ XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, size); msg_host_t *m_host_list = NULL; m_host_list = calloc(2, sizeof(msg_host_t)); m_host_list[0] = MSG_host_self(); m_host_list[1] = attached_host; double flops_amount[] = { 0, 0 }; double bytes_amount[] = { 0, (double)size, 0, 0 }; msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, NULL); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); if(transfer != MSG_OK){ if (transfer == MSG_HOST_FAILURE) XBT_WARN("Transfer error, %s remote host just turned off!", MSG_host_get_name(attached_host)); if (transfer == MSG_TASK_CANCELED) XBT_WARN("Transfer error, task has been canceled!"); return -1; } } /* Write file on local or remote host */ offset = simcall_file_tell(file_priv->simdata->smx_file); write_size = simcall_file_write(file_priv->simdata->smx_file, size, attached_host); file_priv->size = offset+write_size; return write_size; }
/** * @brief Creates a new Lua state and get its environment from the maestro * state. * * The state created is independent from maestro and has its own copies of * global and registry values. * However, the global and registry values are not copied right now from * the original state; they are copied only the first time they are accessed. * This behavior saves time and memory, and is okay for Simgrid's needs. * * TODO: if the simulation runs in parallel, copy everything right now? * * @return the state created */ lua_State* sglua_clone_maestro(void) { /* create the new state */ lua_State *L = luaL_newstate(); /* set its environment and its registry: * - create a table newenv * - create a metatable mt * - set mt.__index = a function that copies the global from the father state * - set mt as the metatable of the registry * - set mt as the metatable of newenv * - set newenv as the environment of the new state */ lua_pushthread(L); /* thread */ lua_newtable(L); /* thread newenv */ lua_newtable(L); /* thread newenv mt */ lua_pushvalue(L, LUA_REGISTRYINDEX); /* thread newenv mt reg */ lua_pushcfunction(L, l_get_from_maestro); /* thread newenv mt reg f */ lua_setfield(L, -3, "__index"); /* thread newenv mt reg */ lua_pushvalue(L, -2); /* thread newenv mt reg mt */ lua_setmetatable(L, -2); /* thread newenv mt reg */ lua_pop(L, 1); /* thread newenv mt */ lua_setmetatable(L, -2); /* thread newenv */ lua_setfenv(L, -2); /* thread */ lua_pop(L, 1); /* -- */ /* create the table of known tables from maestro */ lua_pushstring(L, "simgrid.maestro_tables"); /* "simgrid.maestro_tables" */ lua_newtable(L); /* "simgrid.maestro_tables" maestrotbs */ lua_rawset(L, LUA_REGISTRYINDEX); /* -- */ /* opening the standard libs is not necessary as they are * inherited like any global values */ /* luaL_openlibs(L); */ XBT_DEBUG("New state created"); return L; }
double HostCLM03Model::shareResources(double now){ adjustWeightOfDummyCpuActions(); double min_by_cpu = surf_cpu_model_pm->shareResources(now); double min_by_net = surf_network_model->shareResourcesIsIdempotent() ? surf_network_model->shareResources(now) : -1; double min_by_sto = surf_storage_model->shareResources(now); XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f", this, typeid(surf_cpu_model_pm).name(), min_by_cpu, typeid(surf_network_model).name(), min_by_net, typeid(surf_storage_model).name(), min_by_sto); double res = max(max(min_by_cpu, min_by_net), min_by_sto); if (min_by_cpu >= 0.0 && min_by_cpu < res) res = min_by_cpu; if (min_by_net >= 0.0 && min_by_net < res) res = min_by_net; if (min_by_sto >= 0.0 && min_by_sto < res) res = min_by_sto; return res; }
static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout, smx_actor_t issuer, smx_simcall_t simcall) { XBT_IN("(%p, %p, %f, %p,%p)",cond,mutex,timeout,issuer,simcall); smx_activity_t synchro = nullptr; XBT_DEBUG("Wait condition %p", cond); /* If there is a mutex unlock it */ /* FIXME: what happens if the issuer is not the owner of the mutex? */ if (mutex != nullptr) { cond->mutex = mutex; mutex->unlock(issuer); } synchro = SIMIX_synchro_wait(issuer->host, timeout); synchro->simcalls.push_front(simcall); issuer->waiting_synchro = synchro; xbt_swag_insert(simcall->issuer, cond->sleeping); XBT_OUT(); }
void smpi_sample_3(int global, const char *file, int line) { char *loc = sample_location(global, file, line); local_data_t *data; double sample, n; xbt_assert(samples, "You did something very inconsistent, didn't you?"); data = xbt_dict_get_or_null(samples, loc); smpi_bench_end(); if(data && data->started && data->count < data->iters) { sample = smpi_process_simulated_elapsed(); data->sum += sample; data->sum_pow2 += sample * sample; n = (double)data->count; data->mean = data->sum / n; data->relstderr = sqrt((data->sum_pow2 / n - data->mean * data->mean) / n) / data->mean; XBT_DEBUG("Average mean after %d steps is %f, relative standard error is %f (sample was %f)", data->count, data->mean, data->relstderr, sample); } free(loc); }
static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout, smx_process_t issuer, smx_simcall_t simcall) { XBT_IN("(%p, %p, %f, %p,%p)",cond,mutex,timeout,issuer,simcall); smx_action_t sync_act = NULL; XBT_DEBUG("Wait condition %p", cond); /* If there is a mutex unlock it */ /* FIXME: what happens if the issuer is not the owner of the mutex? */ if (mutex != NULL) { cond->mutex = mutex; SIMIX_mutex_unlock(mutex, issuer); } sync_act = SIMIX_synchro_wait(issuer->smx_host, timeout); xbt_fifo_unshift(sync_act->simcalls, simcall); issuer->waiting_action = sync_act; xbt_swag_insert(simcall->issuer, cond->sleeping); XBT_OUT(); }
void ETag_surfxml_config() { // Sort config elements before applying. // That's a little waste of time, but not doing so would break the tests std::vector<std::string> keys; for (auto const& kv : *current_property_set) { keys.push_back(kv.first); } std::sort(keys.begin(), keys.end()); for (std::string key : keys) { if (simgrid::config::is_default(key.c_str())) { std::string cfg = key + ":" + current_property_set->at(key); simgrid::config::set_parse(std::move(cfg)); } else XBT_INFO("The custom configuration '%s' is already defined by user!", key.c_str()); } XBT_DEBUG("End configuration name = %s",A_surfxml_config_id); delete current_property_set; current_property_set = nullptr; }
/* MSG_task_put related functions */ int TRACE_msg_task_put_start(msg_task_t task) { XBT_DEBUG("PUT,in %p, %lld, %s", task, task->counter, task->category); if (TRACE_msg_process_is_enabled()){ int len = INSTR_DEFAULT_STR_SIZE; char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); val_t value = PJ_value_get ("send", type); new_pajePushState (MSG_get_clock(), process_container, type, value); char key[INSTR_DEFAULT_STR_SIZE]; snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter); type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root()); new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key); } return 1; }
static void IB_action_init_callback(NetworkActionPtr action,RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate){ if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL) xbt_die("IB comm added, without any node connected !"); IBNode* act_src= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, src->getName()); if(act_src==NULL) xbt_die("could not find src node active comms !"); //act_src->rate=rate; IBNode* act_dst= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, dst->getName()); if(act_dst==NULL) xbt_die("could not find dst node active comms !"); // act_dst->rate=rate; ((NetworkIBModel*)surf_network_model)->active_comms[action]=make_pair<IBNode*,IBNode*>(act_src, act_dst); //post the action in the second dist, to retrieve in the other callback XBT_DEBUG("IB callback - action %p init", action); ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, act_src, act_dst, 0); }
/** @brief retrieve the arguments of accept syscall */ void get_args_accept(process_descriptor_t * proc, reg_s * reg, syscall_arg_u * sysarg) { accept_arg_t arg = &(sysarg->accept); arg->ret = reg->ret; arg->sockfd = (int) reg->arg1; XBT_DEBUG("Socket for accepting %lu", reg->arg1); int domain = get_domain_socket(proc, arg->sockfd); pid_t child = proc->pid; if (domain == 2) // PF_INET ptrace_cpy(child, &arg->sai, (void *) reg->arg2, sizeof(struct sockaddr_in), "accept"); if (domain == 1) // PF_UINX ptrace_cpy(child, &arg->sau, (void *) reg->arg2, sizeof(struct sockaddr_in), "accept"); if (domain == 16) // PF_NETLINK ptrace_cpy(child, &arg->snl, (void *) reg->arg2, sizeof(struct sockaddr_in), "accept"); ptrace_cpy(child, &arg->addrlen, (void *) reg->arg3, sizeof(socklen_t), "accept"); arg->addr_dest = (void *) reg->arg2; arg->len_dest = (void *) reg->arg3; }
ExecImpl* ExecImpl::start() { state_ = SIMIX_RUNNING; if (not MC_is_active() && not MC_record_replay_is_active()) { if (hosts_.size() == 1) { surf_action_ = hosts_.front()->pimpl_cpu->execution_start(flops_amounts_.front()); surf_action_->set_priority(priority_); surf_action_->set_category(get_tracing_category()); if (bound_ > 0) surf_action_->set_bound(bound_); } else { surf_action_ = surf_host_model->execute_parallel(hosts_, flops_amounts_.data(), bytes_amounts_.data(), -1); } surf_action_->set_activity(this); } XBT_DEBUG("Create execute synchro %p: %s", this, get_cname()); ExecImpl::on_creation(*this); return this; }
int Coll_scatter_ompi::scatter(const void *sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount, MPI_Datatype rdtype, int root, MPI_Comm comm ) { const size_t small_block_size = 300; const int small_comm_size = 10; int communicator_size, rank; size_t dsize, block_size; XBT_DEBUG("Coll_scatter_ompi::scatter"); communicator_size = comm->size(); rank = comm->rank(); // Determine block size if (root == rank) { dsize=sdtype->size(); block_size = dsize * scount; } else { dsize=rdtype->size(); block_size = dsize * rcount; } if ((communicator_size > small_comm_size) && (block_size < small_block_size)) { std::unique_ptr<unsigned char[]> tmp_buf; if (rank != root) { tmp_buf.reset(new unsigned char[rcount * rdtype->get_extent()]); sbuf = tmp_buf.get(); scount = rcount; sdtype = rdtype; } return Coll_scatter_ompi_binomial::scatter(sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm); } return Coll_scatter_ompi_basic_linear::scatter (sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm); }
int smpi_coll_tuned_reduce_ompi_binomial( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) { uint32_t segsize=0; int segcount = count; size_t typelng; const double a1 = 0.6016 / 1024.0; /* [1/B] */ const double b1 = 1.3496; // COLL_TUNED_UPDATE_IN_ORDER_BMTREE( comm, tuned_module, root ); /** * Determine number of segments and number of elements * sent per operation */ typelng= smpi_datatype_size( datatype); int communicator_size = smpi_comm_size(comm); size_t message_size = typelng * count; if (((communicator_size < 8) && (message_size < 20480)) || (message_size < 2048) || (count <= 1)) { /* Binomial_0K */ segsize = 0; } else if (communicator_size > (a1 * message_size + b1)) { // Binomial_1K segsize = 1024; } XBT_DEBUG("coll:tuned:reduce_intra_binomial rank %d ss %5d", smpi_comm_rank(comm), segsize); COLL_TUNED_COMPUTED_SEGCOUNT( segsize, typelng, segcount ); return smpi_coll_tuned_ompi_reduce_generic( sendbuf, recvbuf, count, datatype, op, root, comm, ompi_coll_tuned_topo_build_in_order_bmtree(comm, root), segcount, 0); }
static void action_Irecv(const char *const *action) { char mailbox[250]; double clock = MSG_get_clock(); process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self()); XBT_DEBUG("Irecv on %s", MSG_process_get_name(MSG_process_self())); sprintf(mailbox, "%s_%s", action[2], MSG_process_get_name(MSG_process_self())); msg_task_t t = NULL; xbt_dynar_push(globals->tasks, &t); msg_comm_t c = MSG_task_irecv(xbt_dynar_get_ptr (globals->tasks, xbt_dynar_length(globals->tasks) - 1), mailbox); xbt_dynar_push(globals->irecvs, &c); log_action(action, MSG_get_clock() - clock); asynchronous_cleanup(); }
/** * @brief Get current data, or free the cursor if there is no data left * * @returns true if it's ok, false if there is no more data */ XBT_INLINE int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t * cursor, char **key, void **data) { xbt_dictelm_t current; XBT_DEBUG("xbt_dict_get_or_free"); if (!cursor || !(*cursor)) return FALSE; current = (*cursor)->current; if (current == NULL) { /* no data left */ xbt_dict_cursor_free(cursor); return FALSE; } *key = current->key; *data = current->content; return TRUE; }
void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat) { XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]", src->name(), src->id(), dst->name(), dst->id()); /* set utils vars */ size_t table_size = vertices_.size(); sg_platf_route_cbarg_t e_route = nullptr; e_route = TO_ROUTE_FULL(src->id(), dst->id()); if (e_route) { res->gw_src = e_route->gw_src; res->gw_dst = e_route->gw_dst; for (auto link : *e_route->link_list) { res->link_list->push_back(link); if (lat) *lat += static_cast<Link*>(link)->getLatency(); } } }
static void route_new_dijkstra(as_dijkstra_t as, int src_id, int dst_id, sg_platf_route_cbarg_t e_route) { XBT_DEBUG("Load Route from \"%d\" to \"%d\"", src_id, dst_id); xbt_node_t src = NULL; xbt_node_t dst = NULL; graph_node_map_element_t src_elm = (graph_node_map_element_t) xbt_dict_get_or_null_ext(as->graph_node_map, (char *) (&src_id), sizeof(int)); graph_node_map_element_t dst_elm = (graph_node_map_element_t) xbt_dict_get_or_null_ext(as->graph_node_map, (char *) (&dst_id), sizeof(int)); if (src_elm) src = src_elm->node; if (dst_elm) dst = dst_elm->node; /* add nodes if they don't exist in the graph */ if (src_id == dst_id && src == NULL && dst == NULL) { src = route_graph_new_node(as, src_id, -1); dst = src; } else { if (src == NULL) { src = route_graph_new_node(as, src_id, -1); } if (dst == NULL) { dst = route_graph_new_node(as, dst_id, -1); } } /* add link as edge to graph */ xbt_graph_new_edge(as->route_graph, src, dst, e_route); }
void TRACE_header(int basic, int size) { XBT_DEBUG ("Define paje header"); TRACE_header_PajeDefineContainerType (basic); TRACE_header_PajeDefineVariableType (basic); TRACE_header_PajeDefineStateType (basic); TRACE_header_PajeDefineEventType (basic); TRACE_header_PajeDefineLinkType (basic); TRACE_header_PajeDefineEntityValue (basic); TRACE_header_PajeCreateContainer (); TRACE_header_PajeDestroyContainer (); TRACE_header_PajeSetVariable (); TRACE_header_PajeAddVariable (); TRACE_header_PajeSubVariable (); TRACE_header_PajeSetState (); TRACE_header_PajePushState (size); TRACE_header_PajePopState (); TRACE_header_PajeResetState (basic); TRACE_header_PajeStartLink (basic, size); TRACE_header_PajeEndLink (basic); TRACE_header_PajeNewEvent (); }
/** @brief Unshift something to the message exchange queue, with a timeout. * * @see #xbt_queue_unshift */ void xbt_queue_unshift_timed(xbt_queue_t queue, const void *src, double delay) { double begin = xbt_time(); xbt_mutex_acquire(queue->mutex); if (delay == 0) { if (queue->capacity != 0 && queue->capacity == xbt_dynar_length(queue->data)) { xbt_mutex_release(queue->mutex); THROWF(timeout_error, 0, "Capacity of %p exceeded (=%d), and delay = 0", queue, queue->capacity); } } else { while (queue->capacity != 0 && queue->capacity == xbt_dynar_length(queue->data) && (delay < 0 || (xbt_time() - begin) <= delay)) { XBT_DEBUG("Capacity of %p exceeded (=%d). Waiting", queue, queue->capacity); TRY { xbt_cond_timedwait(queue->not_full, queue->mutex, delay < 0 ? -1 : delay - (xbt_time() - begin)); } CATCH_ANONYMOUS { xbt_mutex_release(queue->mutex); RETHROW; } } } xbt_dynar_unshift(queue->data, src); xbt_cond_signal(queue->not_empty); xbt_mutex_release(queue->mutex); }
/** @brief Get all logging settings from the command line * * xbt_log_control_set() is called on each string we got from cmd line */ void xbt_log_init(int *argc, char **argv) { unsigned help_requested = 0; /* 1: logs; 2: categories */ int i, j; char *opt; // _XBT_LOGV(log).threshold = xbt_log_priority_debug; /* uncomment to set the LOG category to debug directly */ xbt_log_connect_categories(); /* Set logs and init log submodule */ for (j = i = 1; i < *argc; i++) { if (!strncmp(argv[i], "--log=", strlen("--log="))) { opt = strchr(argv[i], '='); opt++; xbt_log_control_set(opt); XBT_DEBUG("Did apply '%s' as log setting", opt); } else if (!strcmp(argv[i], "--help-logs")) { help_requested |= 1; } else if (!strcmp(argv[i], "--help-log-categories")) { help_requested |= 2; } else { argv[j++] = argv[i]; } } if (j < *argc) { argv[j] = NULL; *argc = j; } if (help_requested) { if (help_requested & 1) xbt_log_help(); if (help_requested & 2) xbt_log_help_categories(); exit(0); } }
double HostCLM03Model::shareResources(double now){ adjustWeightOfDummyCpuActions(); double min_by_cpu = p_cpuModel->shareResources(now); double min_by_net = (strcmp(surf_network_model->getName(), "network NS3")) ? surf_network_model->shareResources(now) : -1; double min_by_sto = -1; if (p_cpuModel == surf_cpu_model_pm) min_by_sto = surf_storage_model->shareResources(now); XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f", this, surf_cpu_model_pm->getName(), min_by_cpu, surf_network_model->getName(), min_by_net, surf_storage_model->getName(), min_by_sto); double res = max(max(min_by_cpu, min_by_net), min_by_sto); if (min_by_cpu >= 0.0 && min_by_cpu < res) res = min_by_cpu; if (min_by_net >= 0.0 && min_by_net < res) res = min_by_net; if (min_by_sto >= 0.0 && min_by_sto < res) res = min_by_sto; return res; }
void SIMIX_simcall_pre(smx_simcall_t simcall, int value) { XBT_DEBUG("Handling simcall %p: %s", simcall, SIMIX_simcall_name(simcall->call)); simcall->mc_value = value; switch (simcall->call) { SIMCALL_LIST(SIMCALL_CASE, SIMCALL_SEP_NOTHING) case NUM_SIMCALLS:; break; case SIMCALL_NONE:; THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s", SIMIX_process_get_name(simcall->issuer), SIMIX_host_get_name(SIMIX_process_get_host(simcall->issuer)) ); break; /* ****************************************************************************************** */ /* TUTORIAL: New API */ /* ****************************************************************************************** */ case SIMCALL_NEW_API_INIT: SIMIX_pre_new_api_fct(simcall); break; } }
static void send_one(int from, int to) { //XBT_DEBUG("send_one(%d, %d)",from,to); if (count %100000 == 0) XBT_INFO("Sending task #%d",count); count++; bcast_task_t bt; if (!xbt_dynar_is_empty(reclaimed)) { bt = xbt_dynar_pop_as(reclaimed,bcast_task_t); } else { bt = xbt_new(s_bcast_task_t,1); } bt->i=from; bt->j=(from+to)/2; bt->k=to; SD_task_t task = SD_task_create_comm_e2e(NULL,bt,424242); XBT_DEBUG("Schedule task between %d and %d",bt->i,bt->j); SD_task_schedulel(task,2,ws_list[bt->i],ws_list[bt->j]); SD_task_watch(task,SD_DONE); }
double surf_solve(double max_date) { surf_min = -1.0; /* duration */ double next_event_date = -1.0; double model_next_action_end = -1.0; double value = -1.0; ResourcePtr resource = NULL; ModelPtr model = NULL; tmgr_trace_event_t event = NULL; unsigned int iter; if(!host_that_restart) host_that_restart = xbt_dynar_new(sizeof(char*), NULL); if (max_date != -1.0 && max_date != NOW) { surf_min = max_date - NOW; } XBT_DEBUG("Looking for next action end for all models except NS3"); if (surf_mins == NULL) { surf_mins = xbt_new(double, xbt_dynar_length(model_list_invoke)); }
lmm_system_t lmm_system_new(int selective_update) { lmm_system_t l = NULL; s_lmm_variable_t var; s_lmm_constraint_t cnst; l = xbt_new0(s_lmm_system_t, 1); l->modified = 0; l->selective_update_active = selective_update; l->visited_counter = 1; XBT_DEBUG("Setting selective_update_active flag to %d\n", l->selective_update_active); xbt_swag_init(&(l->variable_set), xbt_swag_offset(var, variable_set_hookup)); xbt_swag_init(&(l->constraint_set), xbt_swag_offset(cnst, constraint_set_hookup)); xbt_swag_init(&(l->active_constraint_set), xbt_swag_offset(cnst, active_constraint_set_hookup)); xbt_swag_init(&(l->modified_constraint_set), xbt_swag_offset(cnst, modified_constraint_set_hookup)); xbt_swag_init(&(l->saturated_variable_set), xbt_swag_offset(var, saturated_variable_set_hookup)); xbt_swag_init(&(l->saturated_constraint_set), xbt_swag_offset(cnst, saturated_constraint_set_hookup)); l->variable_mallocator = xbt_mallocator_new(65536, lmm_variable_mallocator_new_f, lmm_variable_mallocator_free_f, lmm_variable_mallocator_reset_f); return l; }
/** @brief Shift something from the message exchange queue, with a timeout. * * @see #xbt_queue_shift * */ void xbt_queue_shift_timed(xbt_queue_t queue, void *const dst, double delay) { double begin = xbt_time(); xbt_mutex_acquire(queue->mutex); if (delay == 0) { if (xbt_dynar_is_empty(queue->data)) { xbt_mutex_release(queue->mutex); THROWF(timeout_error, 0, "Delay = 0, and queue is empty"); } } else { while ((xbt_dynar_is_empty(queue->data)) && (delay < 0 || (xbt_time() - begin) <= delay)) { XBT_DEBUG("Queue %p empty. Waiting", queue); TRY { xbt_cond_timedwait(queue->not_empty, queue->mutex, delay < 0 ? -1 : delay - (xbt_time() - begin)); } CATCH_ANONYMOUS { xbt_mutex_release(queue->mutex); RETHROW; } } } if (xbt_dynar_is_empty(queue->data)) { xbt_mutex_release(queue->mutex); THROWF(timeout_error, 0, "Timeout (%f) elapsed, but queue still empty", delay); } xbt_dynar_shift(queue->data, dst); xbt_cond_signal(queue->not_full); xbt_mutex_release(queue->mutex); }