ROSS
ross-inline.h
Go to the documentation of this file.
1 #ifndef INC_ross_inline_h
2 #define INC_ross_inline_h
3 
4 static inline tw_event *
6 {
7  tw_event *e = tw_eventq_pop(&pe->free_q);
8 
9  if (e)
10  {
11  e->cancel_next = NULL;
12  e->caused_by_me = NULL;
13  e->cause_next = NULL;
14  e->prev = e->next = NULL;
15 
16  memset(&e->state, 0, sizeof(e->state));
17  memset(&e->event_id, 0, sizeof(e->event_id));
18  }
19  return e;
20 }
21 
22 static inline void
23 tw_free_output_messages(tw_event *e, int print_message)
24 {
25  while (e->out_msgs) {
26  tw_out *temp = e->out_msgs;
27  if (print_message)
28  printf("%s", temp->message);
29  e->out_msgs = temp->next;
30  // Put it back
32  }
33 }
34 
35 /**
36  * @bug There's a bug in this function. We put dest_gid, which is
37  * a 64-bit value, into dest_lp which may be a 32-bit pointer.
38  */
39 static inline tw_event *
40 tw_event_new(tw_lpid dest_gid, tw_stime offset_ts, tw_lp * sender)
41 {
42  tw_pe *send_pe;
43  tw_event *e;
44  tw_stime recv_ts;
45 
46  if (TW_STIME_DBL(offset_ts) < 0.0) {
47  tw_error(TW_LOC, "Cannot send events into the past! Sending LP: %lu\n", sender->gid);
48  }
49 
50  send_pe = sender->pe;
51  recv_ts = TW_STIME_ADD(tw_now(sender), offset_ts);
52 
54  {
55  /* keep track of the smallest timestamp offset we have seen */
56  if(TW_STIME_DBL(offset_ts) < g_tw_min_detected_offset)
58  }
59 
60  /* If this event will be past the end time, or there
61  * are no more free events available, use abort event.
62  */
63  if (TW_STIME_DBL(recv_ts) >= g_tw_ts_end) {
64 #ifdef USE_RIO
65  e = io_event_grab(send_pe);
66 #else
67  e = send_pe->abort_event;
68 #endif
69  send_pe->stats.s_events_past_end++;
70  } else {
71  e = tw_event_grab(send_pe);
72  if (!e) {
76  "No free event buffers. Try increasing via g_tw_events_per_pe"
77  " or --extramem");
78  }
79  else
80  e = send_pe->abort_event;
81  }
82  }
83 
84  e->dest_lp = (tw_lp *) dest_gid;
85  e->dest_lpid = dest_gid;
86  e->src_lp = sender;
87  e->recv_ts = recv_ts;
88  e->send_ts = tw_now(sender);
89  e->critical_path = sender->critical_path + 1;
90 
92 
93  return e;
94 }
95 
96 static inline void
98 {
99  /*
100  * During the course of a rollback, events are supposed to put
101  * the membufs back on the event. The event is then cancelled
102  * and freed -- which is how a membuf could end up on a freed
103  * event.
104  */
106 
107  if (e->delta_buddy) {
108  tw_clock start = tw_clock_read();
110  g_tw_pe->stats.s_buddy += (tw_clock_read() - start);
111  e->delta_buddy = 0;
112  }
113 
114  e->state.owner = TW_pe_free_q;
115 
116  tw_eventq_unshift(&pe->free_q, e);
117 }
118 
119 static inline void *
121 {
122  return event + 1;
123 }
124 
125 #endif
tw_synch g_tw_synchronization_protocol
Definition: ross-global.c:18
static void * tw_event_data(tw_event *event)
Definition: ross-inline.h:120
#define TW_LOC
Definition: ross-extern.h:164
void * delta_buddy
Delta memory from buddy allocator.
Definition: ross-types.h:275
double g_tw_min_detected_offset
Definition: ross-global.c:55
tw_lp * dest_lp
Destination LP ID.
Definition: ross-types.h:280
double tw_stime
Definition: ross.h:150
static tw_event * tw_event_grab(tw_pe *pe)
Definition: ross-inline.h:5
char message[256-2 *sizeof(void *)]
Definition: ross-types.h:240
tw_eventid event_id
Unique id assigned by src_lp->pe if remote.
Definition: ross-types.h:264
double g_tw_ts_end
Definition: ross-global.c:68
unsigned int critical_path
Critical path value for this LP.
Definition: ross-types.h:319
void tw_error(const char *file, int line, const char *fmt,...) NORETURN
Definition: tw-util.c:74
tw_statistics stats
per PE counters
Definition: ross-types.h:415
tw_stime recv_ts
Actual time to be received.
Definition: ross-types.h:282
tw_event * cancel_next
Next event in the cancel queue for the dest_pe.
Definition: ross-types.h:260
static tw_clock tw_clock_read(void)
Definition: aarch64.h:6
Holds the entire PE state.
Definition: ross-types.h:375
tw_out * out_msgs
Output messages.
Definition: ross-types.h:289
tw_event * prev
Definition: ross-types.h:252
tw_eventq free_q
Linked list of free tw_events.
Definition: ross-types.h:383
uint64_t tw_lpid
Definition: ross.h:160
Event Stucture.
Definition: ross-types.h:250
tw_lpid gid
global LP id
Definition: ross-types.h:306
tw_event * abort_event
Placeholder event for when free_q is empty.
Definition: ross-types.h:384
tw_clock s_buddy
Definition: ross-types.h:149
unsigned int critical_path
Critical path of this event.
Definition: ross-types.h:278
static tw_stime tw_now(tw_lp const *lp)
tw_event * next
Definition: ross-types.h:251
struct tw_out * next
Definition: ross-types.h:237
tw_event * cause_next
Next in parent's caused_by_me chain.
Definition: ross-types.h:262
static void tw_free_output_messages(tw_event *e, int print_message)
Definition: ross-inline.h:23
tw_event * caused_by_me
Start of event list caused by this event.
Definition: ross-types.h:261
tw_lpid dest_lpid
Definition: ross-types.h:286
In tw_pe.free_q.
Definition: ross-types.h:222
static void tw_event_free(tw_pe *pe, tw_event *e)
Definition: ross-inline.h:97
static tw_event * tw_eventq_pop(tw_eventq *q)
Definition: tw-eventq.h:289
void buddy_free(void *ptr)
Definition: buddy.c:137
tw_pe * g_tw_pe
Definition: ross-global.c:75
tw_stime send_ts
Definition: ross-types.h:287
struct tw_event::@0 state
static void tw_eventq_unshift(tw_eventq *q, tw_event *e)
Definition: tw-eventq.h:320
tw_pe * pe
Definition: ross-types.h:308
#define TW_STIME_ADD(x, y)
Definition: ross.h:155
tw_pe * pe
Definition: avl_tree.c:11
uint64_t tw_clock
Definition: aarch64.h:4
tw_lp * src_lp
Sending LP ID.
Definition: ross-types.h:281
Rollback-aware output mechanism.
Definition: ross-types.h:236
tw_stat s_events_past_end
Definition: ross-types.h:154
void tw_kp_put_back_output_buffer(tw_out *out)
Definition: tw-kp.c:175
tw_event * io_event_grab(tw_pe *pe)
Definition: io-mpi.c:42
#define TW_STIME_DBL(x)
Definition: ross.h:153
static tw_event * tw_event_new(tw_lpid dest_gid, tw_stime offset_ts, tw_lp *sender)
Definition: ross-inline.h:40
LP State Structure.
Definition: ross-types.h:304
unsigned char owner
Owner of the next/prev pointers; see tw_event_owner.
Definition: ross-types.h:268