- int i;
-
- /* Connect our log channels: that must be done manually under windows */
-#ifdef XBT_LOG_CONNECT
- XBT_LOG_CONNECT(smpi_base, smpi);
- XBT_LOG_CONNECT(smpi_bench, smpi);
- XBT_LOG_CONNECT(smpi_kernel, smpi);
- XBT_LOG_CONNECT(smpi_mpi, smpi);
- XBT_LOG_CONNECT(smpi_receiver, smpi);
- XBT_LOG_CONNECT(smpi_sender, smpi);
- XBT_LOG_CONNECT(smpi_util, smpi);
-#endif
-
- smpi_global = xbt_new(s_smpi_global_t, 1);
-
- // config vars
- smpi_global->reference_speed =
- xbt_cfg_get_double(_surf_cfg_set, "reference_speed");
-
- // mallocators
- smpi_global->request_mallocator =
- xbt_mallocator_new(SMPI_REQUEST_MALLOCATOR_SIZE, smpi_request_new,
- smpi_request_free, smpi_request_reset);
- smpi_global->message_mallocator =
- xbt_mallocator_new(SMPI_MESSAGE_MALLOCATOR_SIZE, smpi_message_new,
- smpi_message_free, smpi_message_reset);
-
- smpi_global->process_count = SIMIX_process_count();
- DEBUG1("There is %d processes", smpi_global->process_count);
-
- // sender/receiver processes
- smpi_global->main_processes =
- xbt_new(smx_process_t, smpi_global->process_count);
-
- // timers
- smpi_global->timer = xbt_os_timer_new();
- smpi_global->timer_cond = SIMIX_cond_init();
-
- smpi_global->do_once_duration_nodes = NULL;
- smpi_global->do_once_duration = NULL;
- smpi_global->do_once_mutex = SIMIX_mutex_init();
-
-
- smpi_mpi_global = xbt_new(s_smpi_mpi_global_t, 1);
-
- // global communicator
- smpi_mpi_global->mpi_comm_world = xbt_new(s_smpi_mpi_communicator_t, 1);
- smpi_mpi_global->mpi_comm_world->size = smpi_global->process_count;
- smpi_mpi_global->mpi_comm_world->barrier_count = 0;
- smpi_mpi_global->mpi_comm_world->barrier_mutex = SIMIX_mutex_init();
- smpi_mpi_global->mpi_comm_world->barrier_cond = SIMIX_cond_init();
- smpi_mpi_global->mpi_comm_world->rank_to_index_map =
- xbt_new(int, smpi_global->process_count);
- smpi_mpi_global->mpi_comm_world->index_to_rank_map =
- xbt_new(int, smpi_global->process_count);
- for (i = 0; i < smpi_global->process_count; i++) {
- smpi_mpi_global->mpi_comm_world->rank_to_index_map[i] = i;
- smpi_mpi_global->mpi_comm_world->index_to_rank_map[i] = i;
- }
-
- // mpi datatypes
- smpi_mpi_global->mpi_byte = xbt_new(s_smpi_mpi_datatype_t, 1); /* we can think of it as a placeholder for value*/
- smpi_mpi_global->mpi_byte->size = (size_t) 1;
- smpi_mpi_global->mpi_byte->lb = (ptrdiff_t) 0;
- smpi_mpi_global->mpi_byte->ub = smpi_mpi_global->mpi_byte->lb + smpi_mpi_global->mpi_byte->size;
- smpi_mpi_global->mpi_byte->flags = DT_FLAG_BASIC;
-
- smpi_mpi_global->mpi_char = xbt_new(s_smpi_mpi_datatype_t, 1);
- smpi_mpi_global->mpi_char->size = (size_t) 1;
- smpi_mpi_global->mpi_char->lb = (ptrdiff_t) 0; //&(smpi_mpi_global->mpi_char);
- smpi_mpi_global->mpi_char->ub = smpi_mpi_global->mpi_char->lb + smpi_mpi_global->mpi_char->size;
- smpi_mpi_global->mpi_char->flags = DT_FLAG_BASIC;
-
- smpi_mpi_global->mpi_int = xbt_new(s_smpi_mpi_datatype_t, 1);
- smpi_mpi_global->mpi_int->size = sizeof(int);
- smpi_mpi_global->mpi_int->lb = (ptrdiff_t) 0; // &(smpi_mpi_global->mpi_int);
- smpi_mpi_global->mpi_int->ub = smpi_mpi_global->mpi_int->lb + smpi_mpi_global->mpi_int->size;
- smpi_mpi_global->mpi_int->flags = DT_FLAG_BASIC;
-
- smpi_mpi_global->mpi_float = xbt_new(s_smpi_mpi_datatype_t, 1);
- smpi_mpi_global->mpi_float->size = sizeof(float);
- smpi_mpi_global->mpi_float->lb = (ptrdiff_t) 0; // &(smpi_mpi_global->mpi_float);
- smpi_mpi_global->mpi_float->ub = smpi_mpi_global->mpi_float->lb + smpi_mpi_global->mpi_float->size;
- smpi_mpi_global->mpi_float->flags = DT_FLAG_BASIC;
-
- smpi_mpi_global->mpi_double = xbt_new(s_smpi_mpi_datatype_t, 1);
- smpi_mpi_global->mpi_double->size = sizeof(double);
- smpi_mpi_global->mpi_double->lb = (ptrdiff_t) 0; //&(smpi_mpi_global->mpi_float);
- smpi_mpi_global->mpi_double->ub = smpi_mpi_global->mpi_double->lb + smpi_mpi_global->mpi_double->size;
- smpi_mpi_global->mpi_double->flags = DT_FLAG_BASIC;
-
- // mpi operations
- smpi_mpi_global->mpi_land = xbt_new(s_smpi_mpi_op_t, 1);
- smpi_mpi_global->mpi_land->func = smpi_mpi_land_func;
- smpi_mpi_global->mpi_sum = xbt_new(s_smpi_mpi_op_t, 1);
- smpi_mpi_global->mpi_sum->func = smpi_mpi_sum_func;
- smpi_mpi_global->mpi_prod = xbt_new(s_smpi_mpi_op_t, 1);
- smpi_mpi_global->mpi_prod->func = smpi_mpi_prod_func;
- smpi_mpi_global->mpi_min = xbt_new(s_smpi_mpi_op_t, 1);
- smpi_mpi_global->mpi_min->func = smpi_mpi_min_func;
- smpi_mpi_global->mpi_max = xbt_new(s_smpi_mpi_op_t, 1);
- smpi_mpi_global->mpi_max->func = smpi_mpi_max_func;