static msg_file_t get_file_descriptor(const char *file_name){
char full_name[1024];
- msg_file_t file = NULL;
snprintf(full_name,1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
- file = (msg_file_t) xbt_dict_get_or_null(opened_files, full_name);
+ msg_file_t file = (msg_file_t)xbt_dict_get_or_null(opened_files, full_name);
return file;
}
static int relay_runner(int argc, char *argv[])
{
xbt_assert(argc==0, "The relay_runner function does not accept any parameter from the XML deployment file");
- unsigned int task_comm_size = 1000000; /* The token is 1MB long*/
int rank = xbt_str_parse_int(MSG_process_get_name(MSG_process_self()), "Any process of this example must have a numerical name, not %s");
char mailbox[256];
if (rank == 0) {
/* The root process (rank 0) first sends the token then waits to receive it back */
snprintf(mailbox,255, "%d", rank+1);
+ unsigned int task_comm_size = 1000000; /* The token is 1MB long*/
msg_task_t task = MSG_task_create("Token", 0, task_comm_size, NULL);
XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, task->name,mailbox);
MSG_task_send(task, mailbox);
int remote_find_successor(node_t node, int ask_to, int id)
{
int successor = -1;
- int stop = 0;
char mailbox[MAILBOX_NAME_SIZE];
get_mailbox(ask_to, mailbox);
task_data_t req_data = xbt_new0(s_task_data_t, 1);
XBT_DEBUG("Failed to send the 'Find Successor' request (task %p) to %d for id %d", task_sent, ask_to, id);
task_free(task_sent);
} else {
+ int stop = 0;
// receive the answer
XBT_DEBUG("Sent a 'Find Successor' request (task %p) to %d for key %d, waiting for the answer",
task_sent, ask_to, id);
/* - Finally dump disks contents */
XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self()));
- xbt_dict_t contents = NULL;
- contents = MSG_host_get_storage_content(MSG_host_self()); // contents is a dict of dicts
+ xbt_dict_t contents = MSG_host_get_storage_content(MSG_host_self()); // contents is a dict of dicts
xbt_dict_cursor_t curs;
xbt_dict_cursor_t curs2 = NULL;
char* mountname;
int answer_id = -1; // answer (used by some types of messages)
simgrid::s4u::MailboxPtr answer_to; // mailbox to send an answer to (if any)
- explicit ChordMessage(e_message_type_t type) : type(type)
+ explicit ChordMessage(e_message_type_t type) : type(type), issuer_host_name(simgrid::s4u::this_actor::host()->name())
{
- issuer_host_name = simgrid::s4u::this_actor::host()->name();
}
~ChordMessage() = default;
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
{
- int index;
int argc = 0;
- jstring jval;
- const char *tmp;
XBT_LOG_CONNECT(java);
XBT_LOG_CONNECT(jtrace);
char** argv = new char*[argc + 1];
argv[0] = xbt_strdup("java");
- for (index = 0; index < argc - 1; index++) {
- jval = (jstring) env->GetObjectArrayElement(jargs, index);
- tmp = env->GetStringUTFChars(jval, 0);
+ for (int index = 0; index < argc - 1; index++) {
+ jstring jval = (jstring)env->GetObjectArrayElement(jargs, index);
+ const char* tmp = env->GetStringUTFChars(jval, 0);
argv[index + 1] = xbt_strdup(tmp);
env->ReleaseStringUTFChars(jval, tmp);
}
JAVA_HOST_LEVEL = simgrid::s4u::Host::extension_create(__JAVA_host_priv_free);
- for (index = 0; index < argc - 1; index++) {
+ for (int index = 0; index < argc - 1; index++) {
env->SetObjectArrayElement(jargs, index, (jstring)env->NewStringUTF(argv[index + 1]));
free(argv[index]);
}
void TorusZone::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position)
{
- /*
- * Create all links that exist in the torus.
- * Each rank creates @a dimensions-1 links
- */
- int neighbor_rank_id = 0; // The other node the link connects
- int current_dimension = 0; // which dimension are we currently in?
- // we need to iterate over all dimensions
- // and create all links there
+ /* Create all links that exist in the torus. Each rank creates @a dimensions-1 links */
int dim_product = 1; // Needed to calculate the next neighbor_id
- for (unsigned int j = 0; j < dimensions_.size(); j++) {
+ for (unsigned int j = 0; j < dimensions_.size(); j++) {
LinkCreationArgs link;
- current_dimension = dimensions_.at(j);
- neighbor_rank_id = ((static_cast<int>(rank) / dim_product) % current_dimension == current_dimension - 1)
- ? rank - (current_dimension - 1) * dim_product
- : rank + dim_product;
+ int current_dimension = dimensions_.at(j); // which dimension are we currently in?
+ // we need to iterate over all dimensions and create all links there
+ // The other node the link connects
+ int neighbor_rank_id = ((static_cast<int>(rank) / dim_product) % current_dimension == current_dimension - 1)
+ ? rank - (current_dimension - 1) * dim_product
+ : rank + dim_product;
// name of neighbor is not right for non contiguous cluster radicals (as id != rank in this case)
char* link_id = bprintf("%s_link_from_%i_to_%i", cluster->id, id, neighbor_rank_id);
link.id = link_id;
XBT_DEBUG("mig: rx_start");
// The structure has been created in the do_migration function and should only be freed in the same place ;)
- struct migration_session *ms = (migration_session *) MSG_process_get_data(MSG_process_self());
+ struct migration_session* ms = static_cast<migration_session*>(MSG_process_get_data(MSG_process_self()));
bool received_finalize = false;
/* Copyright (c) 2014-2015. The SimGrid Team.
- * All rights reserved. */
+*All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
}
void NetworkIBModel::computeIBfactors(IBNode *root) {
- double penalized_bw=0.0;
double num_comm_out = (double) root->ActiveCommsUp.size();
double max_penalty_out=0.0;
//first, compute all outbound penalties to get their max
if((*it)->init_rate==-1)
(*it)->init_rate= rate_before_update;
- penalized_bw = num_comm_out ? (*it)->init_rate / penalty : (*it)->init_rate;
+ double penalized_bw = num_comm_out ? (*it)->init_rate / penalty : (*it)->init_rate;
if (not double_equals(penalized_bw, rate_before_update, sg_surf_precision)) {
XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->action->getBound(), (*it)->init_rate );
* into the heap info table as necessary. */
static void *register_morecore(struct mdesc *mdp, size_t size)
{
- int i;
- void *result;
- malloc_info *newinfo, *oldinfo;
- size_t newsize;
-
- result = align(mdp, size); // Never returns NULL
+ void* result = align(mdp, size); // Never returns NULL
/* Check if we need to grow the info table (in a multiplicative manner) */
if ((size_t) BLOCK((char *) result + size) > mdp->heapsize) {
int it;
- newsize = mdp->heapsize;
+ size_t newsize = mdp->heapsize;
while ((size_t) BLOCK((char *) result + size) > newsize)
newsize *= 2;
/* Copy old info into new location */
- oldinfo = mdp->heapinfo;
- newinfo = (malloc_info *) align(mdp, newsize * sizeof(malloc_info));
+ malloc_info* oldinfo = mdp->heapinfo;
+ malloc_info* newinfo = (malloc_info*)align(mdp, newsize * sizeof(malloc_info));
memcpy(newinfo, oldinfo, mdp->heapsize * sizeof(malloc_info));
/* Initialise the new blockinfo : */
/* Update the swag of busy blocks containing free fragments by applying the offset to all swag_hooks. Yeah. My hand is right in the fan and I still type */
size_t offset=((char*)newinfo)-((char*)oldinfo);
- for (i=1/*first element of heapinfo describes the mdesc area*/;
- i<mdp->heaplimit;
- i++) {
+ for (int i = 1 /*first element of heapinfo describes the mdesc area*/; i < mdp->heaplimit; i++) {
update_hook(newinfo[i].freehook.next,offset);
update_hook(newinfo[i].freehook.prev,offset);
}
// also update the starting points of the swag
- for (i=0;i<BLOCKLOG;i++) {
+ for (int i = 0; i < BLOCKLOG; i++) {
update_hook(mdp->fraghead[i].head,offset);
update_hook(mdp->fraghead[i].tail,offset);
}
void *mmalloc_no_memset(xbt_mheap_t mdp, size_t size)
{
void *result;
- size_t block, blocks, lastblocks, start;
+ size_t block;
+ size_t blocks;
+ size_t lastblocks size_t start;
size_t i;
size_t log;
int it;