Exemplo n.º 1
0
/**
* This function is invoked by the application level software to inject new events into the simulation
*
* @author Francesco Quaglia
*
* @param gid_receiver Global id of logical process at which the message must be delivered
* @param timestamp Logical Virtual Time associated with the event enveloped into the message
* @param event_type Type of the event
* @param event_content Payload of the event
* @param event_size Size of event's payload
*/
void ParallelScheduleNewEvent(unsigned int gid_receiver, simtime_t timestamp, unsigned int event_type, void *event_content, unsigned int event_size) {
	msg_t event;

	// In Silent execution, we do not send again already sent messages
	if(LPS[current_lp]->state == LP_STATE_SILENT_EXEC) {
		return;
	}

	// Check whether the destination LP is out of range
	if(gid_receiver > n_prc_tot - 1) {	// It's unsigned, so no need to check whether it's < 0
		rootsim_error(false, "Warning: the destination LP %d is out of range. The event has been ignored\n", gid_receiver);
		return;
	}

	// Check if the associated timestamp is negative
	if(timestamp < lvt(current_lp)) {
		rootsim_error(true, "LP %d is trying to generate an event (type %d) to %d in the past! (Current LVT = %f, generated event's timestamp = %f) Aborting...\n", current_lp, event_type, gid_receiver, lvt(current_lp), timestamp);
	}

        // Check if the event type is mapped to an internal control message
        if(event_type >= MIN_VALUE_CONTROL) {
                rootsim_error(true, "LP %d is generating an event with type %d which is a reserved type. Switch event type to a value less than %d. Aborting...\n", current_lp, event_type, MIN_VALUE_CONTROL);
        }


	// Copy all the information into the event structure
	bzero(&event, sizeof(msg_t));
	event.sender = LidToGid(current_lp);
	event.receiver = gid_receiver;
	event.type = event_type;
	event.timestamp = timestamp;
	event.send_time = lvt(current_lp);
	event.message_kind = positive;
	event.mark = generate_mark(current_lp);
	event.size = event_size;

	if(event.type == RENDEZVOUS_START) {
		event.rendezvous_mark = current_evt->rendezvous_mark;
	}

	if(event_size > MAX_EVENT_SIZE) {
		rootsim_error(true, "Event size (%d) exceeds MAX_EVENT_SIZE\n", event_size);
	}

	if (event_content != NULL) {
		memcpy(&event.event_content, event_content, event_size);
	}

	insert_outgoing_msg(&event);
}
Exemplo n.º 2
0
bool VarCollector::VisitBinaryOperator(BinaryOperator *e)  {

  CompilerInstance &CI = FullDirectives->GetCI(e->getLocStart());

  // If it's not an assignment, no contamination can occur
  if (!e->isAssignmentOp()) {
    return true;
  }
  
  // If we're not changing a pointer, no contamination can occur
  if (!e->getLHS()->getType()->isPointerType()) {
    return true;
  }
  
  assert(!e->getLHS()->getType()->isArrayType());
  
  // Get Dominant LHS DeclRef and its expr
  DeclRefExpr * LDominantRef = NULL;
  Expr * LDominantExpr = NULL;

  VarTraverser lvt(e->getLHS(), LDominantRef, LDominantExpr, CI);
  lvt.TraverseStmt(e->getLHS());
  
  // Shouldn't get this!!
  // But if there isn't a dominant variable being written to just return
  // Where on earth is it writing to!?
  // TODO: Convert to actual error!
  if (!LDominantRef) {
    llvm::errs() << "Warning: Found a pointer being modified that we have no "
                 << "idea where came from. Can't determine if private or not!\n";
    return true;
  }
  
  // Get Dominant RHS DeclRef and its expr
  DeclRefExpr * RDominantRef = NULL;
  Expr * RDominantExpr = NULL;

  VarTraverser rvt(e->getRHS(), RDominantRef, RDominantExpr, CI);
  rvt.TraverseStmt(e->getRHS());

  // If there isn't a dominant variable now being pointed to, just return
  if (!RDominantRef) {
    llvm::errs() << "No dominant right ref\n";
    return true;
  }

  VarDecl * VDLHS = dyn_cast<VarDecl>(LDominantRef->getDecl());
  VarDecl * VDRHS = dyn_cast<VarDecl>(RDominantRef->getDecl());

  const Type * T = LDominantExpr->getType().getTypePtr();

  string LT = GetType(LDominantExpr);
  string RT = GetType(RDominantExpr);

  maybeContaminated(VDLHS, LT, VDRHS, RT, T, e->getLocStart());

  return true;

}