void schedule(task_data_t task_data) { int bestpos=-1; unsigned int i; double score; double best=10000; msg_host_t host; host_data_t host_data; xbt_dynar_foreach(hosts_dynar,i,host) { host_data=MSG_host_get_data(host); //filter if (filter_host(host_data,task_data)) { //check score score=(host_data->ntasks+0.01)*1000000000.0/MSG_get_host_speed(host); //XBT_INFO("score %f %f",score,MSG_get_host_speed(host)); if (score<best) { bestpos=i; best=score; } } }
/** * @brief Returns for how long a task is running. * @param task The task to be probed. * @return The amount of seconds since the beginning of the computation. */ static int task_time_elapsed (msg_task_t task) { task_info_t ti; ti = (task_info_t) MSG_task_get_data (task); return (MSG_task_get_compute_duration (task) - MSG_task_get_remaining_computation (task)) / MSG_get_host_speed (config.workers[ti->wid]); }
void worker(){ worker_t p_me = MSG_host_get_data(MSG_host_self()); while(1){ m_task_t p_task = MSG_TASK_UNINITIALIZED; msg_comm_t comm = MSG_task_irecv (&p_task, p_me->channel); MSG_comm_wait(comm, -1); MSG_comm_destroy(comm); task_t p_todo_task = MSG_task_get_data(p_task); if(p_todo_task!=FINALIZE){ MSG_task_destroy(p_task); double delay = 1.0 + p_me->lf_delay*(double)rand()/(double)(RAND_MAX); if(delay<0){ delay=0; } if (p_me->ps_ms_args->uc_coarse) { p_task = MSG_task_create(p_todo_task->name, delay*p_todo_task->f_unit_cost*MSG_get_host_speed(MSG_host_self()), 0, NULL); } else{ //p_task = MSG_task_create(p_todo_task->name, delay*p_todo_task->f_unit_cost*pow(p_todo_task->ui_tile_size,3)/3.0, 0, NULL); p_task = MSG_task_create(p_todo_task->name, delay*p_todo_task->f_unit_cost*MSG_get_host_speed(MSG_host_self()), 0, NULL); } MSG_task_execute(p_task); xbt_fifo_shift(p_me->a_workqueue); p_me->p_last_task = p_todo_task; p_todo_task->uc_done = 1; if(p_todo_task->e_type == Z || p_todo_task->e_type == ZS ){ /*put the topmost line again in the triangles*/ xbt_dynar_push_as(p_me->ps_ms_args->a_NT[p_todo_task->task.Z.ui_j],unsigned int,p_todo_task->task.Z.ui_ii); } else if (p_todo_task->e_type == F) {
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getSpeed(JNIEnv * env, jobject jhost) { msg_host_t host = jhost_get_native(env, jhost); if (!host) { jxbt_throw_notbound(env, "host", jhost); return -1; } return (jdouble) MSG_get_host_speed(host); }
/** * @brief Checks if a worker is a straggler. * @param worker The worker to be probed. * @return 1 if true, 0 if false. */ static int is_straggler (msg_host_t worker) { int task_count; size_t wid; wid = get_worker_id (worker); task_count = (config.slots[MAP] + config.slots[REDUCE]) - (job.heartbeats[wid].slots_av[MAP] + job.heartbeats[wid].slots_av[REDUCE]); if (MSG_get_host_speed (worker) < config.grid_average_speed && task_count > 0) return 1; return 0; }
xbt_dynar_foreach (process_list, cursor, process) { process_name = MSG_process_get_name (process); host = MSG_process_get_host (process); if ( strcmp (process_name, "worker") == 0 ) { config.workers[wid] = host; /* Set the worker ID as its data. */ wi = xbt_new (struct w_info_s, 1); wi->wid = wid; MSG_host_set_data (host, (void*)wi); /* Add the worker's cpu power to the grid total. */ config.grid_cpu_power += MSG_get_host_speed (host); wid++; }