double reference_speed;
// state vars
- int root_ready:1;
- int ready_process_count;
- smx_mutex_t start_stop_mutex;
- smx_cond_t start_stop_cond;
smx_host_t *hosts;
int host_count;
SIMIX_host_set_data(host, hdata);
- // node 0 sets the globals
- if (0 == i) {
-
-
- // signal all nodes to perform initialization
- SIMIX_mutex_lock(smpi_global->start_stop_mutex);
- smpi_global->root_ready = 1;
- SIMIX_cond_broadcast(smpi_global->start_stop_cond);
- SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
-
- } else {
-
- // make sure root is done before own initialization
- SIMIX_mutex_lock(smpi_global->start_stop_mutex);
- while (!smpi_global->root_ready) {
- SIMIX_cond_wait(smpi_global->start_stop_cond,
- smpi_global->start_stop_mutex);
- }
- SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
-
- }
-
- // wait for all nodes to signal initializatin complete
- SIMIX_mutex_lock(smpi_global->start_stop_mutex);
- smpi_global->ready_process_count++;
- if (smpi_global->ready_process_count >= 3 * smpi_global->host_count) {
- SIMIX_cond_broadcast(smpi_global->start_stop_cond);
- }
- while (smpi_global->ready_process_count < 3 * smpi_global->host_count) {
- SIMIX_cond_wait(smpi_global->start_stop_cond,
- smpi_global->start_stop_mutex);
- }
- SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
-
return;
}
i = --smpi_global->running_hosts_count;
SIMIX_mutex_unlock(smpi_global->running_hosts_count_mutex);
- SIMIX_mutex_lock(smpi_global->start_stop_mutex);
- smpi_global->ready_process_count--;
- SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
-
SIMIX_mutex_destroy(smpi_host_mutex());
SIMIX_cond_destroy(smpi_host_cond());
// config variable
smpi_global->reference_speed = SMPI_DEFAULT_SPEED;
- smpi_global->root_ready = 0;
- smpi_global->ready_process_count = 0;
-
- // start/stop
- smpi_global->start_stop_mutex = SIMIX_mutex_init();
- smpi_global->start_stop_cond = SIMIX_cond_init();
-
// host info blank until sim starts
// FIXME: is this okay?
smpi_global->hosts = NULL;
smpi_do_once_duration_node_t curr, next;
- // start/stop
- SIMIX_mutex_destroy(smpi_global->start_stop_mutex);
- SIMIX_cond_destroy(smpi_global->start_stop_cond);
-
// processes
xbt_free(smpi_global->sender_processes);
xbt_free(smpi_global->receiver_processes);
self = SIMIX_process_self();
- // make sure root is done before own initialization
- SIMIX_mutex_lock(smpi_global->start_stop_mutex);
- while (!smpi_global->root_ready) {
- SIMIX_cond_wait(smpi_global->start_stop_cond,
- smpi_global->start_stop_mutex);
- }
- SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
-
index = smpi_host_index();
request_queue = smpi_global->pending_recv_request_queues[index];
smpi_global->receiver_processes[index] = self;
- // wait for all nodes to signal initializatin complete
- SIMIX_mutex_lock(smpi_global->start_stop_mutex);
- smpi_global->ready_process_count++;
- if (smpi_global->ready_process_count >= 3 * smpi_global->host_count) {
- SIMIX_cond_broadcast(smpi_global->start_stop_cond);
- }
- while (smpi_global->ready_process_count < 3 * smpi_global->host_count) {
- SIMIX_cond_wait(smpi_global->start_stop_cond,
- smpi_global->start_stop_mutex);
- }
- SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
-
do {
// FIXME: better algorithm, maybe some kind of balanced tree? or a heap?
self = SIMIX_process_self();
shost = SIMIX_host_self();
- // make sure root is done before own initialization
- SIMIX_mutex_lock(smpi_global->start_stop_mutex);
- while (!smpi_global->root_ready) {
- SIMIX_cond_wait(smpi_global->start_stop_cond,
- smpi_global->start_stop_mutex);
- }
- SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
-
index = smpi_host_index();
request_queue = smpi_global->pending_send_request_queues[index];
smpi_global->sender_processes[index] = self;
- // wait for all nodes to signal initializatin complete
- SIMIX_mutex_lock(smpi_global->start_stop_mutex);
- smpi_global->ready_process_count++;
- if (smpi_global->ready_process_count >= 3 * smpi_global->host_count) {
- SIMIX_cond_broadcast(smpi_global->start_stop_cond);
- }
- while (smpi_global->ready_process_count < 3 * smpi_global->host_count) {
- SIMIX_cond_wait(smpi_global->start_stop_cond,
- smpi_global->start_stop_mutex);
- }
- SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
-
do {
SIMIX_mutex_lock(request_queue_mutex);