Exemple #1
0
/**
 * @brief Determines how to handle the buffer of event whose send operation
 * just finished.
 *
 * @param[in] me pointer to PE
 * @param[in] e pointer to event that we just received
 * @param[in] buffer not currently used
 */
static void
send_finish(tw_pe *me, tw_event *e, char * buffer)
{
  (void) buffer;
  me->stats.s_nsend_network++;
  // instrumentation
  e->src_lp->kp->kp_stats->s_nsend_network++;
  e->src_lp->lp_stats->s_nsend_network++;

  if (e->state.owner == TW_net_asend) {
    if (e->state.cancel_asend) {
      /* Event was cancelled during transmission.  We must
       * send another message to pass the cancel flag to
       * the other node.
       */
      e->state.cancel_asend = 0;
      e->state.cancel_q = 1;
      tw_eventq_push(&outq, e);
    } else {
      /* Event finished transmission and was not cancelled.
       * Add to our sent event queue so we can retain the
       * event in case we need to cancel it later.  Note it
       * is currently in remote format and must be converted
       * back to local format for fossil collection.
       */
      e->state.owner = TW_pe_sevent_q;
      if( g_tw_synchronization_protocol == CONSERVATIVE )
	tw_event_free(me, e);
    }

    return;
  }

  if (e->state.owner == TW_net_acancel) {
    /* We just finished sending the cancellation message
     * for this event.  We need to free the buffer and
     * make it available for reuse.
     */
    tw_event_free(me, e);
    return;
  }

  /* Never should happen, not unless we somehow broke this
   * module's other functions related to sending an event.
   */

  tw_error(
	   TW_LOC,
	   "Don't know how to finish send of owner=%u, cancel_q=%d",
	   e->state.owner,
	   e->state.cancel_q);

}
Exemple #2
0
void DajielkaSanctuary::calculate(void)
{
	STACKTRACE;

	SpaceObject::calculate();

	if (creator && !creator->exists()) {
		creator = 0;
	}

	int i,j;
	int oldSpriteIndex;
	int regenMultiplier;
								 //corrected for click-dependant regeneration. Tau.
	DajielkaSanctuary::addEnergy( iround(energyPerFrame*frame_time/25.0) );

	for ( i = 0; i < 30; i++) {
		if (tendril[i]) {
			if (!tendril[i]->exists()) {
				tw_error("a dead tendril? this should not happen");
				tendril[i] = 0;
			}

			if (tendril[i]->recreateMe == TRUE) {
				//tw_error("Want to recreate!");
				//tendril[i] = this->RecreateTendril(tendril[i]);
			}
		}
	}

	vel = 0;

	regenMultiplier=1;
	for(j=0;j<regenerationExponent;j++)
		regenMultiplier *= armour;
	if (!regenerationIsTendrilBased)
		regenerationCount += frame_time;
	if (regenerationCount>(regenerationThreshhold*regenMultiplier))
	if (armour<maxArmour && creator!=NULL) {
		//tw_error("armour=%d regenMultiplier=%d",armour,regenMultiplier);
		armour++;
		regenerationCount -= (regenerationThreshhold*regenMultiplier);
	}
	else
		regenerationCount=0;
	oldSpriteIndex = sprite_index;
	sprite_index = (int)((((double)armour / (double)maxArmour) * 10)+0.2);
	if (sprite_index<0) sprite_index=0;
	if (sprite_index>9) sprite_index=9;
	if (creator && oldSpriteIndex!=sprite_index&&oldSpriteIndex<sprite_index)
		creator->play_sound2(creator->data->sampleSpecial[creator->special_sample]);

}
Exemple #3
0
bool Control::die()
{
    STACKTRACE;
    if (channel == Game::channel_none)
        return Presence::die();
    // controls CANNOT arbitrarily be killed off, because the deal with networking directly
    tw_error("controls cannot be killed");
    //the error can be removed eventually...
    //I just want to find out if anything is actually calling this
    //because before this function was added, that would have resulted in a desynch
    return false;
}
Exemple #4
0
int
tw_client_socket_create(char *server, tw_socket * socket_addr, tw_port port)
{
	int             socket_fd;
	struct hostent *hp;

	if ((socket_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
		tw_error(TW_LOC, "Error creating socket.");

	bzero(socket_addr, sizeof(struct sockaddr_in));
	hp = gethostbyname(server);

	if (hp == NULL)
		tw_error(TW_LOC, "Unknown host: %s", server);

	bcopy((char *)hp->h_addr, (char *)&socket_addr->sin_addr, hp->h_length);
	socket_addr->sin_family = AF_INET;
	socket_addr->sin_port = htons(port);

	return socket_fd;
}
Exemple #5
0
void
tw_net_cancel(tw_event *e)
{
  tw_pe *src_pe = e->src_lp->pe;

  switch (e->state.owner) {
  case TW_net_outq:
    /* Cancelled before we could transmit it.  Do not
     * transmit the event and instead just release the
     * buffer back into our own free list.
     */
    tw_eventq_delete_any(&outq, e);
    tw_event_free(src_pe, e);

    return;

    break;

  case TW_net_asend:
    /* Too late.  We've already let MPI start to send
     * this event over the network.  We can't pull it
     * back now without sending another message to do
     * the cancel.
     *
     * Setting the cancel_q flag will signal us to do
     * another message send once the current send of
     * this message is completed.
     */
    e->state.cancel_asend = 1;
    break;

  case TW_pe_sevent_q:
    /* Way late; the event was already sent and is in
     * our sent event queue.  Mark it as a cancel and
     * place it at the front of the outq.
     */
    e->state.cancel_q = 1;
    tw_eventq_unshift(&outq, e);
    break;

  default:
    /* Huh?  Where did you come from?  Why are we being
     * told about you?  We did not send you so we cannot
     * cancel you!
     */
    tw_error(
	     TW_LOC,
	     "Don't know how to cancel event owned by %u",
	     e->state.owner);
  }

  service_queues(src_pe);
}
Exemple #6
0
void
ospf_rc_event_handler(ospf_state * state, tw_bf *bf, rn_message *rn_msg, tw_lp *lp)
{
#if 0
	ospf_message	*msg;
	ospf_nbr	*nbr;

	msg = rn_message_data(rn_msg);
	nbr = ospf_int_getinterface(state, rn_msg->src);

	if(!nbr)
		nbr = ospf_util_data(msg);

	if(msg->type == OSPF_IP)
		tw_error(TW_LOC, "IP packet forwarding not reversible yet!");

	switch(msg->type)
	{
		case OSPF_HELLO_MSG:
			ospf_hello_packet_rc(state, nbr, bf, msg, lp);
			state->stats->s_e_hello_in--;
			break;
		case OSPF_HELLO_SEND:
			// need to restart timer
			nbr->hello_timer =
				ospf_timer_start(nbr, nbr->hello_timer,
					 nbr->hello_interval,
					 OSPF_HELLO_SEND, lp);
			break;
		case OSPF_HELLO_TIMEOUT:
			state->stats->s_e_hello_timeouts--;
			ospf_nbr_event_handler(state, nbr,
					rc_ospf_nbr_inactivity_timer_ev, lp);
			break;
		default:
			tw_error(TW_LOC, "Unhandled event type (%d) in "
					 "rc_event_handler!", msg->type);
	}
#endif
}
Exemple #7
0
tw_event	*
tcp_rc_timer_reset(tw_event * timer, tw_bf * bf, tcp_message * old, tw_lp * lp)
{
	if(bf->c14)
	{
		// If I init'd a timer, cancel it.
		if(timer)
		{
			tw_memory_alloc_rc(lp, timer->memory, g_tcp_fd);
			timer->memory = NULL;

#if TCP_DEBUG
			printf("\t%lld: cancel timer at %lf (%ld)\n", 
				lp->id, timer->recv_ts, (long int) timer);
#endif

			rn_timer_cancel(lp, &timer);
		}

		// restore pointer to previous timer
		//timer = old->RC.timer;
		//old->RC.timer = NULL;
	} else
	{
		//rn_timer_reset(lp, &timer, old->RC.timer_ts);
	}

	if(bf->c13 == 0)
		return timer;

	if(timer)
	{
		tcp_message	*m;

#if TCP_DEBUG
		printf("\t%lld: new RTO at %lf (%ld)\n", 
			lp->id, tw_now(lp), (long int) timer);
#endif

		if(NULL == timer->memory)
			timer->memory = tw_memory_alloc(lp, g_tcp_fd);

		m = tw_memory_data(timer->memory);
		//m->seq_num = old->RC.timer_seq;
		m->src = old->src;
	}

	if(timer && !timer->memory)
		tw_error(TW_LOC, "no membuf here!");

	return timer;
}
Exemple #8
0
static int static_get_native_bpp_index()
{
	int i;
	for (i = 0; i< sizeof(color_depth)/sizeof(color_depth[0]); i++) {
		if (strcmp(color_depth[i], "Native") == 0) {
			break;
		}
	}
	if (i == sizeof(color_depth)/sizeof(color_depth[0])) {
		tw_error("Unable to find 'Native' in resolutions strings");
	}
	return i;
}
Exemple #9
0
void
rn_hash_insert(void *h, rn_link * event)
{
	rn_hash        *hash_t;

	hash_t = (rn_hash *) h;

	h_insert(hash_t->storage, event, hash_t->capacity);
	hash_t->nstored++;

	if(hash_t->nstored > floor(hash_t->capacity * RN_MAX_FRACTION))
		tw_error(TW_LOC, "Inserted beyond RN_MAX_FRACTION!");
}
Exemple #10
0
void GobPlayer::_add_pair(const char *id, int value)
{
	STACKTRACE;
	if (_get_pair(id)) {
		tw_error("GobPlayer::_add_pair - \"%s\" already exists", id);
		return;
	}
	pair_list = (pair*)realloc(pair_list, sizeof(pair) * (num_pairs+1));
	pair_list[num_pairs].id = strdup(id);
	pair_list[num_pairs].value = value;
	num_pairs += 1;
	return;
}
Exemple #11
0
int
tw_socket_read(int fd, char *buffer, int bytes, int tries)
{
	int             rv;
	int             total = 0;
	int             give_up;

	if(fd == 0)
		tw_error(TW_LOC, "Trying to read from invalid fd %d ! \n", fd);

	give_up = tries ? tries : 100;

	do
	{
		if ((rv = read(fd, &buffer[total], bytes - total)) > 0)
		{
			total += rv;
		} else if (errno == EAGAIN && total == 0)
		{
			return 0;
		} else if (errno != EAGAIN && errno != 0)
		{
			perror("network read error");
			tw_error(TW_LOC, "network receive error occurred.");
		}
	} while (total < bytes || (give_up-- && (total == 0)));
	//} while(--give_up || total < bytes);


	if (give_up == 0 && total != bytes)
		tw_error(TW_LOC, "Giving up in read!");

	if (total != bytes)
	{
		tw_error(TW_LOC, "Only read %d out of %d bytes!", total, bytes);
	}

	return total;
}
Exemple #12
0
void Control::select_ship(Ship* ship_pointer, const char* ship_name)
{
    STACKTRACE;
    ship = ship_pointer;
    if (ship) {
        ship->control = this;
        if (temporary && (channel != Game::channel_none) && (already != 0) && (already != game->lag_frames)) {
            tw_error ("Control::select_ship - bad operation (incompatible with networking)");
        }
    }
    target_stuff() ;
    return;
}
Exemple #13
0
void
tw_lp_suspend(tw_lp * lp, int do_orig_event_rc, int error_num )
{
  if(!lp)
    tw_error(TW_LOC, "Bad LP pointer!");

  lp->suspend_flag=1;
  lp->suspend_event = lp->pe->cur_event; // only valid prior to GVT
  lp->suspend_time = tw_now(lp);
  lp->suspend_error_number = error_num;
  lp->suspend_do_orig_event_rc = do_orig_event_rc;

}
ip_link	*
rc_getlink(ip_state * state, rn_machine * me, rn_link * link)
{
	int	i;

	for(i = 0; i < me->nlinks; i++)
		if(state->links[i].link == link)
			return &state->links[i];

	tw_error(TW_LOC, "Unable to find link!");

	return NULL;
}
Exemple #15
0
AvlTree avl_alloc(void)
{
    AvlTree head = g_tw_pe[0]->avl_list_head;
    g_tw_pe[0]->avl_list_head = head->next;
    
    if (g_tw_pe[0]->avl_list_head == NULL) {
        tw_error(TW_LOC, "avl_list_head is invalid!");
    }
    
    head->next = NULL;
    
    return head;
}
Exemple #16
0
int
main(int argc, char **argv, char **env)
{
	int		 i;

        // get rid of error if compiled w/ MEMORY queues
        g_tw_memory_nqueues=1;
	// set a min lookahead of 1.0
	lookahead = 1.0;
	tw_opt_add(app_opt);
	tw_init(&argc, &argv);

	if( lookahead > 1.0 )
	  tw_error(TW_LOC, "Lookahead > 1.0 .. needs to be less\n");

	//reset mean based on lookahead
        mean = mean - lookahead;

        g_tw_memory_nqueues = 16; // give at least 16 memory queue event

	offset_lpid = g_tw_mynode * nlp_per_pe;
	ttl_lps = tw_nnodes() * g_tw_npe * nlp_per_pe;
	g_tw_events_per_pe = (mult * nlp_per_pe * g_phold_start_events) +
				optimistic_memory;
	//g_tw_rng_default = TW_FALSE;
	g_tw_lookahead = lookahead;

	tw_define_lps(nlp_per_pe, sizeof(phold_message));

	for(i = 0; i < g_tw_nlp; i++)
		tw_lp_settype(i, &mylps[0]);

        if( g_tw_mynode == 0 )
	  {
	    printf("========================================\n");
	    printf("PHOLD Model Configuration..............\n");
	    printf("   Lookahead..............%lf\n", lookahead);
	    printf("   Start-events...........%u\n", g_phold_start_events);
	    printf("   stagger................%u\n", stagger);
	    printf("   Mean...................%lf\n", mean);
	    printf("   Mult...................%lf\n", mult);
	    printf("   Memory.................%u\n", optimistic_memory);
	    printf("   Remote.................%lf\n", percent_remote);
	    printf("========================================\n\n");
	  }

	tw_run();
	tw_end();

	return 0;
}
Exemple #17
0
static int
recv_begin(tw_pe *me)
{
  MPI_Status status;

  tw_event	*e = NULL;

  int flag = 0;
  int changed = 0;

  while (posted_recvs.cur < read_buffer)
    {
      unsigned id = posted_recvs.cur;

      if(!(e = tw_event_grab(me)))
      {
	  if(tw_gvt_inprogress(me))
	      tw_error(TW_LOC, "Out of events in GVT! Consider increasing --extramem");
	  return changed;	  
      }

#if ROSS_MEMORY
      if( MPI_Irecv(posted_recvs.buffers[id],
		   EVENT_SIZE(e),
		   MPI_BYTE,
		   MPI_ANY_SOURCE,
		   EVENT_TAG,
		   MPI_COMM_ROSS,
		   &posted_recvs.req_list[id]) != MPI_SUCCESS)
#else
	if( MPI_Irecv(e,
		     (int)EVENT_SIZE(e),
		     MPI_BYTE,
		     MPI_ANY_SOURCE,
		     EVENT_TAG,
		     MPI_COMM_ROSS,
		     &posted_recvs.req_list[id]) != MPI_SUCCESS)
#endif
	  {
	    tw_event_free(me, e);
	    return changed;
	  }

      posted_recvs.event_list[id] = e;
      posted_recvs.cur++;
      changed = 1;
    }

  return changed;
}
Exemple #18
0
void
tmr_init(tmr_state * s, tw_lp * lp)
{
	int              i;

	if(!lp->rng)
	{
		tw_error(TW_LOC, "No RNG!");
		lp->rng = tw_calloc(TW_LOC, "LP RNG", sizeof(tw_rng_stream), 1);
		tw_rand_initial_seed(lp->pe->rng, lp->rng, lp->gid);
	}

	for (i = 0; i < g_tmr_start_events; i++)
	{
		tw_event_send(
			tw_event_new(lp->gid, 
				     tw_rand_exponential(lp->rng, mean), 
				     lp));
	}

	if((s->timer = tw_timer_init(lp, 100.0)) == NULL)
		tw_error(TW_LOC, "scheduled timer past end time \n");
}
Exemple #19
0
/*
 * This function inits the parser and gets the total number of LPs to create
 */
void
rn_xml_init()
{
#if RN_XML_DEBUG
	printf("Reading in XML topology file: %s\n\n", g_rn_xml_topology);
#endif

	xmlXPathInit();
	document_network = xmlReadFile(g_rn_xml_topology, NULL , 0);

	if(!document_network)
		tw_error(TW_LOC, "Parsing of network topology file %s failed!", 
			g_rn_xml_topology);

	ctxt = xmlXPathNewContext(document_network);

	if(!ctxt)
		tw_error(TW_LOC, "Could not create network topology XML context!");

	/* read in the XML network topology */
	rn_xml_topology();

	if(g_rn_xml_link_topology != NULL)
	{
		document_links = xmlReadFile(g_rn_xml_link_topology, NULL ,0);

		if(!document_links)
			tw_error(TW_LOC, "Parsing of link topology file %s failed!", 
				g_rn_xml_link_topology);

		ctxt_links = xmlXPathNewContext(document_links);

		if(!ctxt_links)
			tw_error(TW_LOC, "Unable to create model XML context!");

		/* read in the XML link topology */
		rn_xml_link_topology();
		xmlXPathFreeContext(ctxt_links);
	}

	if(NULL != g_rn_xml_model && 0 != strcmp(g_rn_xml_model, ""))
	{
		document_model = xmlReadFile(g_rn_xml_model, NULL, 0);

		if(!document_model)
			tw_error(TW_LOC, "Parsing of model file %s failed!", 
				g_rn_xml_model);

		ctxt_model = xmlXPathNewContext(document_model);

		if(!ctxt_model)
			tw_error(TW_LOC, "Unable to create model XML context!");

		rn_xml_model();
		xmlXPathFreeContext(ctxt_model);
	}
}
Exemple #20
0
/* delete the given value */
tw_event *
avlDelete(AvlTree *t, tw_event *key)
{
    tw_event *target = NULL;
    AvlTree oldroot;
    
    if (*t == AVL_EMPTY) {
        tw_error(TW_LOC, "We never look for non-existent events!");
        return target;
    }
    
    if (key->recv_ts == (*t)->key->recv_ts) {
        // We have a timestamp tie, check the event ID
        if (key->event_id == (*t)->key->event_id) {
            // We have a event ID tie, check the send_pe
            if (key->send_pe == (*t)->key->send_pe) {
                // This is actually the one we want to delete
                target = (*t)->key;
                /* do we have a right child? */
                if ((*t)->child[1] != AVL_EMPTY) {
                    /* give root min value in right subtree */
                    (*t)->key = avlDeleteMin(&(*t)->child[1]);
                }
                else {
                    /* splice out root */
                    oldroot = (*t);
                    *t = (*t)->child[0];
                    avl_free(oldroot);
                }
            }
            else {
                // Timestamp and event IDs are the same, but different send_pe
                target = avlDelete(&(*t)->child[key->send_pe > (*t)->key->send_pe], key);
            }
        }
        else {
            // Timestamps are the same but event IDs differ
            target = avlDelete(&(*t)->child[key->event_id > (*t)->key->event_id], key);
        }
    }
    else {
        // Timestamps are different
        target = avlDelete(&(*t)->child[key->recv_ts > (*t)->key->recv_ts], key);
    }
    
    avlRebalance(t);
    
    return target;
}
Exemple #21
0
/*
 * tcp_timer_reset: reset the RTO timer properly
 */
tw_event	*
tcp_timer_reset(tw_event * timer, tw_bf * bf, tcp_message * old, 
		tw_stime ts, int sn, tw_lp * lp)
{
	tcp_message	*m;

	// this can happen because sometimes we rollback more events
	// than we need to when nkp < nlp.  So, sometimes our events
	// our rolled back that do NOT reset the RTO, and therefore
	// it might seem that we need to RC reset the timer, when in fact
	// we do not.
	if(timer && timer->recv_ts == ts)
		tw_error(TW_LOC, "%ld: bad timer reset: cur ts %lf!", lp->gid, ts);

	// if this IS the timer firing, then init new timer
	if((bf->c14 = (!timer || timer == lp->pe->cur_event)))
	{
		old->RC.timer = timer;
		timer = rn_timer_init(lp, ts);

#if TCP_DEBUG
		printf("\t%lld: init RTO to %lf (%ld)\n", lp->gid, ts, (long int) timer);
#endif
		
	} else
	{
#if TCP_DEBUG
		printf("\t%lld: reset RTO to %lf (was %lf)\n", 
			lp->gid, ts, timer->recv_ts);
#endif

		old->RC.timer_ts = timer->recv_ts;
		rn_timer_reset(lp, &timer, ts);
	}

	if((bf->c13 = (timer != NULL)))
	{
		if(!timer->memory)
			timer->memory = tw_memory_alloc(lp, g_tcp_fd);

		m = tw_memory_data(timer->memory);

		old->RC.timer_seq = m->seq_num;
		m->src = old->src;
		m->seq_num = sn;
	}

	return timer;
}
Exemple #22
0
void blit_singlecolor(BITMAP *src, BITMAP *dest, int copycolor)
{
	STACKTRACE;
	if ( src->w != dest->w || src->h != dest->h )
		tw_error("error in copying color in shpysr2");

	for ( int iy = 0; iy < src->h; ++iy ) {
		for ( int ix = 0; ix < src->w; ++ix ) {
			int color = getpixel(src, ix, iy);
			if ( color == copycolor )
				tw_putpixel(dest, ix, iy, color);
		}
	}

}
Exemple #23
0
void 
tcp_router_rc_EventHandler(Router_State *SV, tw_bf * CV,Msg_Data *M, tw_lp * lp)
{
  //printf("router rollback %f lp %d\n",tw_now(lp),lp->id);
  switch (M->MethodName)
    {
    case FORWARD:
      tcp_router_forward_rc(SV, CV, M, lp);
      break;
    default:
      tw_error(TW_LOC, "APP_ERROR(8)(%d): InValid MethodName(%d)\n",
	       lp->id, M->MethodName);
      tw_exit(1);
    }
}
Exemple #24
0
void
tw_pe_settype(const tw_petype * type)
{
	if (!g_tw_pe)
		tw_error(TW_LOC, "Undefined PE!");

#define copy_pef(f, d) \
		g_tw_pe->type.f = type->f ? type->f : d

	copy_pef(pre_lp_init, dummy_pe_f);
	copy_pef(post_lp_init, dummy_pe_f);
	copy_pef(gvt, dummy_pe_f);
	copy_pef(final, dummy_pe_f);

#undef copy_pef
}
void forwarder_event_handler(forwarder_state * ns, tw_bf * b, forwarder_msg * m,
		tw_lp * lp) {
	//printf("In forwarder_event_handler\n");
	assert(m->h.magic == forwarder_magic);

	switch (m->h.event_type) {
	case FORWARDER_FWD:
		handle_forwarder_fwd(ns, m, lp);
		break;
	case FORWARDER_RECV:
		handle_forwarder_recv(ns, m, lp);
		break;
	default:
		tw_error(TW_LOC, "unknown forwarder event type");
	}
}
Exemple #26
0
void wifi_access_point_event_handler_rc(wifi_access_point_state * s, tw_bf * bf, wifi_message * m, tw_lp * lp)
{
  switch( m->type )
    {
    case WIFI_PACKET_ARRIVAL_AT_ACCESS_POINT:
      wifi_access_point_arrival_rc(s, bf, m, lp);
      break;

    case WIFI_PACKET_ARRIVAL_AT_STATION:
      wifi_station_arrival_rc(s, bf, m, lp);
      break;

    default:
      tw_error(TW_LOC, "Undefined type, corrupted message \n");
      break;
    }
}
Exemple #27
0
void save_spacesprite2(SpaceSprite *ss, const char *spritename, const char *destination, const char *extension)
{
	STACKTRACE;
	int i;
	char buf[512];

	if (ss->frames() != 64)
		tw_error("save_spacesprite2 - error");

	BITMAP *tmp = create_bitmap(int(ss->width() * 8), int(ss->height() * 8));
	for (i = 0; i < ss->frames(); i += 1) {
		blit(ss->get_bitmap(i), tmp, 0, 0, (i&7) * (int)ss->width(), int((i/8) * ss->height()), (int)ss->width(), (int)ss->height());
		sprintf(buf, "%s%i.%s", spritename, i, extension);
		save_bitmap(buf, tmp, NULL);
	}
	return;
}
Exemple #28
0
void tw_init(int *argc, char ***argv) {
    int i;
#if HAVE_CTIME
    time_t raw_time;
#endif

    tw_opt_add(tw_net_init(argc, argv));

    // Print out the command-line so we know what we passed in
    if (tw_ismaster()) {
        for (i = 0; i < *argc; i++) {
            printf("%s ", (*argv)[i]);
        }
        printf("\n\n");
    }

    // Print our revision if we have it
#ifdef ROSS_VERSION
    if (tw_ismaster()) {
#if HAVE_CTIME
        time(&raw_time);
        printf("%s\n", ctime(&raw_time));
#endif
        printf("ROSS Revision: %s\n\n", ROSS_VERSION);
    }
#endif

    tw_opt_add(kernel_options);
    tw_opt_add(tw_gvt_setup());
    tw_opt_add(tw_clock_setup());
#ifdef USE_RIO
    tw_opt_add(io_opts);
#endif

    // by now all options must be in
    tw_opt_parse(argc, argv);

    if(tw_ismaster() && NULL == (g_tw_csv = fopen("ross.csv", "a"))) {
        tw_error(TW_LOC, "Unable to open: ross.csv\n");
    }

    tw_opt_print();

    tw_net_start();
    tw_gvt_start();
}
Exemple #29
0
/* this may replace root, which is why we pass
 * in a AvlTree * */
void
avlInsert(AvlTree *t, tw_event *key)
{
    /* insertion procedure */
    if (*t == AVL_EMPTY) {
        /* new t */
        *t = avl_alloc();
        if (*t == NULL) {
            tw_error(TW_LOC, "Out of AVL tree nodes!");
        }
        
        (*t)->child[0] = AVL_EMPTY;
        (*t)->child[1] = AVL_EMPTY;
        
        (*t)->key = key;
        
        (*t)->height = 1;
        
        /* done */
        return;
    }
    
    if (key->recv_ts == (*t)->key->recv_ts) {
        // We have a timestamp tie, check the event ID
        if (key->event_id == (*t)->key->event_id) {
            // We have a event ID tie, check the send_pe
            if (key->send_pe == (*t)->key->send_pe) {
                // This shouldn't happen but we'll allow it
                tw_printf(TW_LOC, "The events are identical!!!\n");
            }
            avlInsert(&(*t)->child[key->send_pe > (*t)->key->send_pe], key);
            avlRebalance(t);
        }
        else {
            // Event IDs are different
            avlInsert(&(*t)->child[key->event_id > (*t)->key->event_id], key);
            avlRebalance(t);
        }
        return;
    }
    else {
        // Timestamps are different
        avlInsert(&(*t)->child[key->recv_ts > (*t)->key->recv_ts], key);
        avlRebalance(t);
    }
}
Exemple #30
0
/**
 * @brief If there are any openings in the posted_sends queue, start sends
 * for events in the outgoing queue.
 *
 * @param[in] me pointer to the PE
 * @return 0 if no changes are made to the posted_sends queue, 1 otherwise.
 */
static int
send_begin(tw_pe *me)
{
  int changed = 0;

  while (posted_sends.cur < send_buffer)
    {
      tw_event *e = tw_eventq_peek(&outq);
      tw_peid dest_pe;

      unsigned id = posted_sends.cur;

      if (!e)
	break;

      if(e == me->abort_event)
	tw_error(TW_LOC, "Sending abort event!");

      dest_pe = (*e->src_lp->type->map) ((tw_lpid) e->dest_lp);

      e->send_pe = (tw_peid) g_tw_mynode;
      e->send_lp = e->src_lp->gid;

      if (MPI_Isend(e,
		    (int)EVENT_SIZE(e),
		    MPI_BYTE,
		    (int)dest_pe,
		    EVENT_TAG,
		    MPI_COMM_ROSS,
		    &posted_sends.req_list[id]) != MPI_SUCCESS) {
	return changed;
      }

      tw_eventq_pop(&outq);
      e->state.owner = e->state.cancel_q
	? TW_net_acancel
	: TW_net_asend;

      posted_sends.event_list[id] = e;
      posted_sends.cur++;
      me->s_nwhite_sent++;

      changed = 1;
    }
  return changed;
}