ROSS
io-serialize.c
Go to the documentation of this file.
1 #include "ross.h"
2 
3 size_t io_lp_serialize (tw_lp *lp, void *buffer) {
4  int i, j;
5 
6  io_lp_store tmp;
7 
8  tmp.gid = lp->gid;
9  for (i = 0; i < g_tw_nRNG_per_lp; i++) {
10  for (j = 0; j < 4; j++) {
11  tmp.rng[j] = lp->rng->Ig[j];
12  tmp.rng[j+4] = lp->rng->Lg[j];
13  tmp.rng[j+8] = lp->rng->Cg[j];
14  }
15 #ifdef RAND_NORMAL
16  tmp.tw_normal_u1 = lp->rng->tw_normal_u1;
17  tmp.tw_normal_u2 = lp->rng->tw_normal_u2;
19 #endif
20  }
21  tmp.critical_path = lp->critical_path;
22 
23  memcpy(buffer, &tmp, sizeof(io_lp_store));
24  return sizeof(io_lp_store);
25 }
26 
27 size_t io_lp_deserialize (tw_lp *lp, void *buffer) {
28  int i, j;
29 
30  io_lp_store tmp;
31  memcpy(&tmp, buffer, sizeof(io_lp_store));
32 
33  lp->gid = tmp.gid;
34 
35  for (i = 0; i < g_tw_nRNG_per_lp; i++) {
36  for (j = 0; j < 4; j++) {
37  lp->rng->Ig[j] = tmp.rng[j];
38  lp->rng->Lg[j] = tmp.rng[j+4];
39  lp->rng->Cg[j] = tmp.rng[j+8];
40  }
41 #ifdef RAND_NORMAL
42  lp->rng->tw_normal_u1 = tmp.tw_normal_u1;
43  lp->rng->tw_normal_u2 = tmp.tw_normal_u2;
45 #endif
46  }
47  lp->critical_path = tmp.critical_path;
48 
49  return sizeof(io_lp_store);
50 }
51 
52 size_t io_event_serialize (tw_event *e, void *buffer) {
53  int i;
54 
55  io_event_store tmp;
56 
57  memcpy(&(tmp.cv), &(e->cv), sizeof(tw_bf));
59  tmp.dest_lp = (tw_lpid)e->dest_lp; // ROSS HACK: dest_lp is gid
60  tmp.src_lp = e->src_lp->gid;
61  tmp.recv_ts = e->recv_ts - g_tw_ts_end;
62 
63  memcpy(buffer, &tmp, sizeof(io_event_store));
64  // printf("Storing event going to %lu at %f\n", tmp.dest_lp, tmp.recv_ts);
65  return sizeof(io_event_store);
66 }
67 
68 size_t io_event_deserialize (tw_event *e, void *buffer) {
69  int i;
70 
71  io_event_store tmp;
72  memcpy(&tmp, buffer, sizeof(io_event_store));
74 
75  memcpy(&(e->cv), &(tmp.cv), sizeof(tw_bf));
76  e->dest_lp = (tw_lp *) tmp.dest_lp; // ROSS HACK: e->dest_lp is GID for a bit
77  //undo pointer to GID conversion
78  if (g_tw_mapping == LINEAR) {
80  } else if (g_tw_mapping == CUSTOM) {
82  } else {
83  tw_error(TW_LOC, "RIO ERROR: Unsupported mapping");
84  }
85  e->recv_ts = tmp.recv_ts;
86  // printf("Loading event going to %lu at %f\n", tmp.dest_lp, tmp.recv_ts);
87  return sizeof(io_event_store);
88 }
#define TW_LOC
Definition: ross-extern.h:164
tw_lp * dest_lp
Destination LP ID.
Definition: ross-types.h:280
tw_lp ** g_tw_lp
Definition: ross-global.c:26
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_lpid g_tw_lp_offset
Definition: ross-global.c:24
size_t io_event_serialize(tw_event *e, void *buffer)
Definition: io-serialize.c:52
tw_stime recv_ts
Actual time to be received.
Definition: ross-types.h:282
double tw_normal_u2
Definition: rand-clcg4.h:43
tw_bf cv
Definition: io.h:77
double tw_normal_u1
Definition: io.h:69
tw_bf cv
Used by app during reverse computation.
Definition: ross-types.h:274
size_t io_event_deserialize(tw_event *e, void *buffer)
Definition: io-serialize.c:68
int32_t rng[12]
Definition: io.h:67
uint64_t tw_lpid
Definition: ross.h:160
double tw_normal_u1
Definition: rand-clcg4.h:42
Event Stucture.
Definition: ross-types.h:250
map_local_f g_tw_custom_lp_global_to_local_map
Definition: ross-global.c:19
tw_lpid gid
global LP id
Definition: ross-types.h:306
tw_lpid src_lp
Definition: io.h:80
unsigned int critical_path
Critical path of this event.
Definition: ross-types.h:278
size_t io_lp_serialize(tw_lp *lp, void *buffer)
Definition: io-serialize.c:3
tw_stime recv_ts
Definition: io.h:81
tw_lp_map g_tw_mapping
Definition: ross-global.c:21
double tw_normal_u2
Definition: io.h:70
Reverse Computation Bitfield.
Definition: ross-types.h:178
int32_t Ig[4]
Definition: rand-clcg4.h:35
int tw_normal_flipflop
Definition: rand-clcg4.h:44
tw_lpid gid
Definition: io.h:66
unsigned int g_tw_nRNG_per_lp
Definition: ross-global.c:29
unsigned int critical_path
Definition: io.h:78
int32_t Lg[4]
Definition: rand-clcg4.h:36
tw_lp * src_lp
Sending LP ID.
Definition: ross-types.h:281
size_t io_lp_deserialize(tw_lp *lp, void *buffer)
Definition: io-serialize.c:27
Definition: io.h:65
tw_lpid dest_lp
Definition: io.h:79
tw_rng_stream * rng
RNG stream array for this LP.
Definition: ross-types.h:317
int32_t Cg[4]
Definition: rand-clcg4.h:37
unsigned int critical_path
Definition: io.h:73
int tw_normal_flipflop
Definition: io.h:71
LP State Structure.
Definition: ross-types.h:304