ROSS
io-serialize.c
Go to the documentation of this file.
1#include "ross.h"
2
3size_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 }
22
23 memcpy(buffer, &tmp, sizeof(io_lp_store));
24 return sizeof(io_lp_store);
25}
26
27size_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 }
48
49 return sizeof(io_lp_store);
50}
51
52size_t io_event_serialize (tw_event *e, void *buffer) {
53 int i;
54
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
68size_t io_event_deserialize (tw_event *e, void *buffer) {
69 int i;
70
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}
uint64_t tw_lpid
Definition ross-base.h:49
tw_lp ** g_tw_lp
Definition ross-global.c:28
void tw_error(const char *file, int line, const char *fmt,...)
Definition tw-util.c:77
map_local_f g_tw_custom_lp_global_to_local_map
Definition ross-global.c:20
unsigned int g_tw_nRNG_per_lp
Definition ross-global.c:31
tw_lp_map g_tw_mapping
Definition ross-global.c:22
tw_lpid g_tw_lp_offset
Definition ross-global.c:26
double g_tw_ts_end
Definition ross-global.c:72
#define TW_LOC
@ CUSTOM
Definition ross-types.h:50
@ LINEAR
Definition ross-types.h:48
size_t io_lp_serialize(tw_lp *lp, void *buffer)
Definition io-serialize.c:3
size_t io_lp_deserialize(tw_lp *lp, void *buffer)
size_t io_event_deserialize(tw_event *e, void *buffer)
size_t io_event_serialize(tw_event *e, void *buffer)
tw_lpid src_lp
Definition io.h:83
tw_bf cv
Definition io.h:80
tw_lpid dest_lp
Definition io.h:82
unsigned int critical_path
Definition io.h:81
tw_stime recv_ts
Definition io.h:84
unsigned int critical_path
Definition io.h:76
int tw_normal_flipflop
Definition io.h:74
tw_lpid gid
Definition io.h:69
double tw_normal_u1
Definition io.h:72
int32_t rng[12]
Definition io.h:70
double tw_normal_u2
Definition io.h:73
Reverse Computation Bitfield.
Definition ross-types.h:188
Event Stucture.
Definition ross-types.h:277
tw_lp * src_lp
Sending LP ID.
Definition ross-types.h:313
tw_stime recv_ts
Actual time to be received.
Definition ross-types.h:314
unsigned int critical_path
Critical path of this event.
Definition ross-types.h:310
tw_bf cv
Used by app during reverse computation.
Definition ross-types.h:306
tw_lp * dest_lp
Destination LP ID.
Definition ross-types.h:312
LP State Structure.
Definition ross-types.h:336
tw_rng_stream * rng
RNG stream array for this LP.
Definition ross-types.h:349
tw_lpid gid
global LP id
Definition ross-types.h:338
unsigned int critical_path
Critical path value for this LP.
Definition ross-types.h:352
int32_t Ig[4]
Definition rand-clcg4.h:38
double tw_normal_u1
Definition rand-clcg4.h:45
int32_t Cg[4]
Definition rand-clcg4.h:40
int32_t Lg[4]
Definition rand-clcg4.h:39
int tw_normal_flipflop
Definition rand-clcg4.h:47
double tw_normal_u2
Definition rand-clcg4.h:46