Example #1
0
JNIEXPORT jobject JNICALL
Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls,
                                         jstring jname) {
  msg_host_t host;                /* native host                                          */
  jobject jhost;                /* global reference to the java host instance returned  */

  /* get the C string from the java string */
  const char *name = (*env)->GetStringUTFChars(env, jname, 0);
  if (name == NULL) {
  	jxbt_throw_null(env,bprintf("No host can have a null name"));
  	return NULL;
  }
  /* get the host by name       (the hosts are created during the grid resolution) */
  host = MSG_get_host_by_name(name);

  if (!host) {                  /* invalid name */
    jxbt_throw_host_not_found(env, name);
    (*env)->ReleaseStringUTFChars(env, jname, name);
    return NULL;
  }
  (*env)->ReleaseStringUTFChars(env, jname, name);

  if (!MSG_host_get_data(host)) {       /* native host not associated yet with java host */

    /* Instantiate a new java host */
    jhost = jhost_new_instance(env);

    if (!jhost) {
      jxbt_throw_jni(env, "java host instantiation failed");
      return NULL;
    }

    /* get a global reference to the newly created host */
    jhost = jhost_ref(env, jhost);

    if (!jhost) {
      jxbt_throw_jni(env, "new global ref allocation failed");
      return NULL;
    }
    /* Sets the java host name */
    (*env)->SetObjectField(env, jhost, jhost_field_Host_name, jname);
    /* bind the java host and the native host */
    jhost_bind(jhost, host, env);

    /* the native host data field is set with the global reference to the
     * java host returned by this function
     */
    MSG_host_set_data(host, (void *) jhost);
  }

  /* return the global reference to the java host instance */
  return (jobject) MSG_host_get_data(host);
}
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;
      }
    }
  }
Example #3
0
void TTPT_init(){
  msched_args_t ps_args = (msched_args_t)MSG_host_get_data(MSG_host_self()); 
  task_t facto,update,elim;
  
  unsigned int BS = ps_args->ui_BS;
  unsigned int p = ps_args->ui_p;
  unsigned int q = ps_args->ui_q;
  int K, M, RD; 
  int k,mmm, nnn;
  
  K = min( p, q); 
  
  for (k = 0; k < K; k++) {
    for (M = k;
         //M < p-1 || M == k;  // No bottom single-row subdomain
         M < p || M == k; // The line above is PLASMA code, the line here is our variants, note: we need square tiles
         M += BS) {
      
      facto = new_task(F, ps_args,NULL,M, k,0,0);
      
      for (nnn = k+1; nnn < q; nnn++) {
        update = new_task(H,ps_args,facto, M,k, nnn,0);
      }
      
      for (mmm = M+1;
           //(mmm < M+BS && mmm < p) || mmm == p-1; // Suck in bottom single-row domain
           (mmm < M+BS && mmm < p); // The line above is PLASMA code, the line here is our variants, note: we need square tiles
           mmm++) {
        
        facto = new_task(F, ps_args,NULL,mmm, k,0,0);
        elim = new_task(Z,ps_args,NULL, mmm, M, k,0);
    
        for (nnn = k+1; nnn < q; nnn++) {
          update = new_task(H,ps_args,facto, mmm,k, nnn,0);
          update = new_task(V,ps_args,elim, mmm,M, k,nnn);
        }
      }
    }
    for (RD = BS; RD < p-k; RD *= 2) {
      for (M = k;
           //M+RD < p-1; // No reduction with bottom single-row subdomain
           M+RD < p; // The line above is PLASMA code, the line here is our variants, note: we need square tiles
           M += 2*RD) {
        
        elim = new_task(Z,ps_args,NULL, M+RD, M, k,0);

        for (nnn = k+1; nnn < q; nnn++) {
          update = new_task(V,ps_args,elim, M+RD,M, k,nnn);
        }
        
      }
      
    }    
  }
}
Example #4
0
JNIEXPORT jobject JNICALL
Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jclass cls) {
  jobject jhost;

  msg_host_t host = MSG_host_self();

  if (!MSG_host_get_data(host)) {
    /* the native host not yet associated with the java host instance */

    /* instanciate a new java host instance */
    jhost = jhost_new_instance(env);

    if (!jhost) {
      jxbt_throw_jni(env, "java host instantiation failed");
      return NULL;
    }

    /* get a global reference to the newly created host */
    jhost = jhost_ref(env, jhost);

    if (!jhost) {
      jxbt_throw_jni(env, "global ref allocation failed");
      return NULL;
    }
    /* Sets the host name */
    const char *name = MSG_host_get_name(host);
    jobject jname = (*env)->NewStringUTF(env,name);
    (*env)->SetObjectField(env, jhost, jhost_field_Host_name, jname);
    /* Bind & store it */
    jhost_bind(jhost, host, env);
    MSG_host_set_data(host, (void *) jhost);
  } else {
    jhost = (jobject) MSG_host_get_data(host);
  }

  return jhost;
}
Example #5
0
JNIEXPORT jobjectArray JNICALL
Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg)
{
  int index;
  jobjectArray jtable;
  jobject jhost;
  jstring jname;
  msg_host_t host;

  xbt_dynar_t table =  MSG_hosts_as_dynar();
  int count = xbt_dynar_length(table);

  jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");

  if (!cls) {
    return NULL;
  }

  jtable = (*env)->NewObjectArray(env, (jsize) count, cls, NULL);

  if (!jtable) {
    jxbt_throw_jni(env, "Hosts table allocation failed");
    return NULL;
  }

  for (index = 0; index < count; index++) {
    host = xbt_dynar_get_as(table,index,msg_host_t);
    jhost = (jobject) (MSG_host_get_data(host));

    if (!jhost) {
      jname = (*env)->NewStringUTF(env, MSG_host_get_name(host));

      jhost =
      		Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname);
      /* FIXME: leak of jname ? */
    }

    (*env)->SetObjectArrayElement(env, jtable, index, jhost);
  }
  xbt_dynar_free(&table);
  return jtable;
}
Example #6
0
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) {
Example #7
0
 /**
  * Returns the StarsNode instance associated to the current process.
  */
 StarsNode & getCurrentNode() {
     if (inSimulation)
         return *static_cast<StarsNode *>(MSG_host_get_data(MSG_host_self()));
     else return routingTable[currentNode];
 }
Example #8
0
 xbt_dynar_foreach(host_list, i, host) {
   RngStream stream = MSG_host_get_data(host);
   RngStream_DeleteStream(&stream);
 }