Example #1
0
// Those are MC_state_get_internal_request(state)
bool request_depend(smx_simcall_t r1, smx_simcall_t r2)
{
  if (simgrid::mc::reduction_mode == simgrid::mc::ReductionMode::none)
    return true;

  if (r1->issuer == r2->issuer)
    return false;

  /* Wait with timeout transitions are not considered by the independance theorem, thus we consider them as dependant with all other transitions */
  if ((r1->call == SIMCALL_COMM_WAIT && simcall_comm_wait__get__timeout(r1) > 0)
      || (r2->call == SIMCALL_COMM_WAIT
          && simcall_comm_wait__get__timeout(r2) > 0))
    return TRUE;

  if (r1->call != r2->call)
    return request_depend_asymmetric(r1, r2)
      && request_depend_asymmetric(r2, r1);

  // Those are internal requests, we do not need indirection
  // because those objects are copies:
  smx_synchro_t synchro1 = MC_get_comm(r1);
  smx_synchro_t synchro2 = MC_get_comm(r2);

  switch(r1->call) {
  case SIMCALL_COMM_ISEND:
    return simcall_comm_isend__get__rdv(r1) == simcall_comm_isend__get__rdv(r2);
  case SIMCALL_COMM_IRECV:
    return simcall_comm_irecv__get__rdv(r1) == simcall_comm_irecv__get__rdv(r2);
  case SIMCALL_COMM_WAIT:
    if (synchro1->comm.src_buff == synchro2->comm.src_buff
        && synchro1->comm.dst_buff == synchro2->comm.dst_buff)
      return false;
    else if (synchro1->comm.src_buff != nullptr
        && synchro1->comm.dst_buff != nullptr
        && synchro2->comm.src_buff != nullptr
        && synchro2->comm.dst_buff != nullptr
        && synchro1->comm.dst_buff != synchro2->comm.src_buff
        && synchro1->comm.dst_buff != synchro2->comm.dst_buff
        && synchro2->comm.dst_buff != synchro1->comm.src_buff)
      return false;
    else
      return true;
  default:
    return true;
  }
}
Example #2
0
int MC_request_is_enabled(smx_simcall_t req)
{
  unsigned int index = 0;
  smx_action_t act;

  switch (req->call) {

  case SIMCALL_COMM_WAIT:
    /* FIXME: check also that src and dst processes are not suspended */

    /* If it has a timeout it will be always be enabled, because even if the
     * communication is not ready, it can timeout and won't block.
     * On the other hand if it hasn't a timeout, check if the comm is ready.*/
    if(simcall_comm_wait__get__timeout(req) >= 0){
      if(_surf_mc_timeout == 1){
        return TRUE;
      }else{
        act = simcall_comm_wait__get__comm(req);
        return (act->comm.src_proc && act->comm.dst_proc);
      }
    }else{
      act = simcall_comm_wait__get__comm(req);
      return (act->comm.src_proc && act->comm.dst_proc);
    }
    break;

  case SIMCALL_COMM_WAITANY:
    /* Check if it has at least one communication ready */
    xbt_dynar_foreach(simcall_comm_waitany__get__comms(req), index, act) {
      if (act->comm.src_proc && act->comm.dst_proc){
        return TRUE;
      }
    }
    return FALSE;
    break;

  default:
    /* The rest of the request are always enabled */
    return TRUE;
  }
}
Example #3
0
// Does half the job
static inline
bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2)
{
  if (r1->call == SIMCALL_COMM_ISEND && r2->call == SIMCALL_COMM_IRECV)
    return false;

  if (r1->call == SIMCALL_COMM_IRECV && r2->call == SIMCALL_COMM_ISEND)
    return false;

  // Those are internal requests, we do not need indirection
  // because those objects are copies:
  smx_synchro_t synchro1 = MC_get_comm(r1);
  smx_synchro_t synchro2 = MC_get_comm(r2);

  if ((r1->call == SIMCALL_COMM_ISEND || r1->call == SIMCALL_COMM_IRECV)
      && r2->call == SIMCALL_COMM_WAIT) {

    smx_mailbox_t rdv = MC_get_rdv(r1);

    if (rdv != synchro2->comm.rdv_cpy
        && simcall_comm_wait__get__timeout(r2) <= 0)
      return false;

    if ((r1->issuer != synchro2->comm.src_proc)
        && (r1->issuer != synchro2->comm.dst_proc)
        && simcall_comm_wait__get__timeout(r2) <= 0)
      return false;

    if ((r1->call == SIMCALL_COMM_ISEND)
        && (synchro2->comm.type == SIMIX_COMM_SEND)
        && (synchro2->comm.src_buff !=
            simcall_comm_isend__get__src_buff(r1))
        && simcall_comm_wait__get__timeout(r2) <= 0)
      return false;

    if ((r1->call == SIMCALL_COMM_IRECV)
        && (synchro2->comm.type == SIMIX_COMM_RECEIVE)
        && (synchro2->comm.dst_buff != simcall_comm_irecv__get__dst_buff(r1))
        && simcall_comm_wait__get__timeout(r2) <= 0)
      return false;
  }

  /* FIXME: the following rule assumes that the result of the
   * isend/irecv call is not stored in a buffer used in the
   * test call. */
  /*if(   (r1->call == SIMCALL_COMM_ISEND || r1->call == SIMCALL_COMM_IRECV)
     &&  r2->call == SIMCALL_COMM_TEST)
     return FALSE; */

  if (r1->call == SIMCALL_COMM_WAIT
      && (r2->call == SIMCALL_COMM_WAIT || r2->call == SIMCALL_COMM_TEST)
      && (synchro1->comm.src_proc == nullptr || synchro1->comm.dst_proc == NULL))
    return false;

  if (r1->call == SIMCALL_COMM_TEST &&
      (simcall_comm_test__get__comm(r1) == nullptr
       || synchro1->comm.src_buff == nullptr
       || synchro1->comm.dst_buff == nullptr))
    return false;

  if (r1->call == SIMCALL_COMM_TEST && r2->call == SIMCALL_COMM_WAIT
      && synchro1->comm.src_buff == synchro2->comm.src_buff
      && synchro1->comm.dst_buff == synchro2->comm.dst_buff)
    return false;

  if (r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_TEST
      && synchro1->comm.src_buff != nullptr
      && synchro1->comm.dst_buff != nullptr
      && synchro2->comm.src_buff != nullptr
      && synchro2->comm.dst_buff != nullptr
      && synchro1->comm.dst_buff != synchro2->comm.src_buff
      && synchro1->comm.dst_buff != synchro2->comm.dst_buff
      && synchro2->comm.dst_buff != synchro1->comm.src_buff)
    return false;

  return true;
}
Example #4
0
int MC_request_depend(smx_simcall_t r1, smx_simcall_t r2) {
  if(mc_reduce_kind == e_mc_reduce_none)
    return TRUE;

  if (r1->issuer == r2->issuer)
      return FALSE;

  if(r1->call == SIMCALL_COMM_ISEND && r2->call == SIMCALL_COMM_IRECV)
    return FALSE;

  if(r1->call == SIMCALL_COMM_IRECV && r2->call == SIMCALL_COMM_ISEND)
    return FALSE;

  if((r1->call == SIMCALL_COMM_ISEND || r1->call == SIMCALL_COMM_IRECV)
     &&  r2->call == SIMCALL_COMM_WAIT){

    smx_rdv_t rdv = r1->call == SIMCALL_COMM_ISEND ? simcall_comm_isend__get__rdv(r1) : simcall_comm_irecv__get__rdv(r1);

    if(rdv != simcall_comm_wait__get__comm(r2)->comm.rdv_cpy && simcall_comm_wait__get__timeout(r2) <= 0)
      return FALSE;

    if((r1->issuer != simcall_comm_wait__get__comm(r2)->comm.src_proc) && (r1->issuer != simcall_comm_wait__get__comm(r2)->comm.dst_proc))
      return FALSE;

    if((r1->call == SIMCALL_COMM_ISEND) && (simcall_comm_wait__get__comm(r2)->comm.type == SIMIX_COMM_SEND) 
       && (simcall_comm_wait__get__comm(r2)->comm.src_buff != simcall_comm_isend__get__src_buff(r1)))
      return FALSE;

    if((r1->call == SIMCALL_COMM_IRECV) && (simcall_comm_wait__get__comm(r2)->comm.type == SIMIX_COMM_RECEIVE) 
       && (simcall_comm_wait__get__comm(r2)->comm.dst_buff != simcall_comm_irecv__get__dst_buff(r1)))
      return FALSE;
  }

  if((r2->call == SIMCALL_COMM_ISEND || r2->call == SIMCALL_COMM_IRECV)
        &&  r1->call == SIMCALL_COMM_WAIT){

    smx_rdv_t rdv = r2->call == SIMCALL_COMM_ISEND ? simcall_comm_isend__get__rdv(r2) : simcall_comm_irecv__get__rdv(r2);

    if(rdv != simcall_comm_wait__get__comm(r1)->comm.rdv_cpy && simcall_comm_wait__get__timeout(r1) <= 0)
      return FALSE;

    if((r2->issuer != simcall_comm_wait__get__comm(r1)->comm.src_proc) && (r2->issuer != simcall_comm_wait__get__comm(r1)->comm.dst_proc))
        return FALSE;  

    if((r2->call == SIMCALL_COMM_ISEND) && (simcall_comm_wait__get__comm(r1)->comm.type == SIMIX_COMM_SEND) 
       && (simcall_comm_wait__get__comm(r1)->comm.src_buff != simcall_comm_isend__get__src_buff(r2)))
      return FALSE;

    if((r2->call == SIMCALL_COMM_IRECV) && (simcall_comm_wait__get__comm(r1)->comm.type == SIMIX_COMM_RECEIVE) 
       && (simcall_comm_wait__get__comm(r1)->comm.dst_buff != simcall_comm_irecv__get__dst_buff(r2)))
      return FALSE;
  }

  /* FIXME: the following rule assumes that the result of the
   * isend/irecv call is not stored in a buffer used in the
   * test call. */
  /*if(   (r1->call == SIMCALL_COMM_ISEND || r1->call == SIMCALL_COMM_IRECV)
        &&  r2->call == SIMCALL_COMM_TEST)
        return FALSE;*/

  /* FIXME: the following rule assumes that the result of the
   * isend/irecv call is not stored in a buffer used in the
   * test call.*/
  /*if(   (r2->call == SIMCALL_COMM_ISEND || r2->call == SIMCALL_COMM_IRECV)
        && r1->call == SIMCALL_COMM_TEST)
        return FALSE;*/

  if(r1->call == SIMCALL_COMM_ISEND && r2->call == SIMCALL_COMM_ISEND
     && simcall_comm_isend__get__rdv(r1) != simcall_comm_isend__get__rdv(r2))
    return FALSE;

  if(r1->call == SIMCALL_COMM_IRECV && r2->call == SIMCALL_COMM_IRECV
     && simcall_comm_irecv__get__rdv(r1) != simcall_comm_irecv__get__rdv(r2))
    return FALSE;

  if(r1->call == SIMCALL_COMM_WAIT && (r2->call == SIMCALL_COMM_WAIT || r2->call == SIMCALL_COMM_TEST)
     && (simcall_comm_wait__get__comm(r1)->comm.src_proc == NULL
         || simcall_comm_wait__get__comm(r1)->comm.dst_proc == NULL))
    return FALSE;

  if(r2->call == SIMCALL_COMM_WAIT && (r1->call == SIMCALL_COMM_WAIT || r1->call == SIMCALL_COMM_TEST)
     && (simcall_comm_wait__get__comm(r2)->comm.src_proc == NULL
         || simcall_comm_wait__get__comm(r2)->comm.dst_proc == NULL))
    return FALSE;

  if(r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_WAIT
     && simcall_comm_wait__get__comm(r1)->comm.src_buff == simcall_comm_wait__get__comm(r2)->comm.src_buff
     && simcall_comm_wait__get__comm(r1)->comm.dst_buff == simcall_comm_wait__get__comm(r2)->comm.dst_buff)
    return FALSE;

  if (r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_WAIT
      && simcall_comm_wait__get__comm(r1)->comm.src_buff != NULL
      && simcall_comm_wait__get__comm(r1)->comm.dst_buff != NULL
      && simcall_comm_wait__get__comm(r2)->comm.src_buff != NULL
      && simcall_comm_wait__get__comm(r2)->comm.dst_buff != NULL
      && simcall_comm_wait__get__comm(r1)->comm.dst_buff != simcall_comm_wait__get__comm(r2)->comm.src_buff
      && simcall_comm_wait__get__comm(r1)->comm.dst_buff != simcall_comm_wait__get__comm(r2)->comm.dst_buff
      && simcall_comm_wait__get__comm(r2)->comm.dst_buff != simcall_comm_wait__get__comm(r1)->comm.src_buff)
    return FALSE;

  if(r1->call == SIMCALL_COMM_TEST &&
     (simcall_comm_test__get__comm(r1) == NULL
      || simcall_comm_test__get__comm(r1)->comm.src_buff == NULL
      || simcall_comm_test__get__comm(r1)->comm.dst_buff == NULL))
    return FALSE;

  if(r2->call == SIMCALL_COMM_TEST &&
     (simcall_comm_test__get__comm(r2) == NULL
      || simcall_comm_test__get__comm(r2)->comm.src_buff == NULL
      || simcall_comm_test__get__comm(r2)->comm.dst_buff == NULL))
    return FALSE;

  if(r1->call == SIMCALL_COMM_TEST && r2->call == SIMCALL_COMM_WAIT
     && simcall_comm_test__get__comm(r1)->comm.src_buff == simcall_comm_wait__get__comm(r2)->comm.src_buff
     && simcall_comm_test__get__comm(r1)->comm.dst_buff == simcall_comm_wait__get__comm(r2)->comm.dst_buff)
    return FALSE;

  if(r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_TEST
     && simcall_comm_wait__get__comm(r1)->comm.src_buff == simcall_comm_test__get__comm(r2)->comm.src_buff
     && simcall_comm_wait__get__comm(r1)->comm.dst_buff == simcall_comm_test__get__comm(r2)->comm.dst_buff)
    return FALSE;

  if (r1->call == SIMCALL_COMM_WAIT && r2->call == SIMCALL_COMM_TEST
      && simcall_comm_wait__get__comm(r1)->comm.src_buff != NULL
      && simcall_comm_wait__get__comm(r1)->comm.dst_buff != NULL
      && simcall_comm_test__get__comm(r2)->comm.src_buff != NULL
      && simcall_comm_test__get__comm(r2)->comm.dst_buff != NULL
      && simcall_comm_wait__get__comm(r1)->comm.dst_buff != simcall_comm_test__get__comm(r2)->comm.src_buff
      && simcall_comm_wait__get__comm(r1)->comm.dst_buff != simcall_comm_test__get__comm(r2)->comm.dst_buff
      && simcall_comm_test__get__comm(r2)->comm.dst_buff != simcall_comm_wait__get__comm(r1)->comm.src_buff)
    return FALSE;

  if (r1->call == SIMCALL_COMM_TEST && r2->call == SIMCALL_COMM_WAIT
      && simcall_comm_test__get__comm(r1)->comm.src_buff != NULL
      && simcall_comm_test__get__comm(r1)->comm.dst_buff != NULL
      && simcall_comm_wait__get__comm(r2)->comm.src_buff != NULL
      && simcall_comm_wait__get__comm(r2)->comm.dst_buff != NULL
      && simcall_comm_test__get__comm(r1)->comm.dst_buff != simcall_comm_wait__get__comm(r2)->comm.src_buff
      && simcall_comm_test__get__comm(r1)->comm.dst_buff != simcall_comm_wait__get__comm(r2)->comm.dst_buff
      && simcall_comm_wait__get__comm(r2)->comm.dst_buff != simcall_comm_test__get__comm(r1)->comm.src_buff)
    return FALSE;


  return TRUE;
}