Skip to content

Commit f27cff5

Browse files
authored
Merge pull request #193 from ROSS-org/develop
New ROSS version 8.1.0 !
2 parents a9a7f8d + e488793 commit f27cff5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1958
-451
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# ignore models that aren't already in tree
22
# (must manually add models to override this)
3-
models/*
3+
build/
4+
models/*/
5+
!models/phold
46
*.swp

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ ROSS developers typically do out-of-tree builds. See the [Installation page](ht
6565
cd ROSS-build
6666
ccmake ~/path-to/ROSS
6767
```
68+
We reccomend the following CMake parameters:
69+
```
70+
cmake .. -DROSS_BUILD_MODELS=ON -DCMAKE_INSTALL_PREFIX="$(realpath ./bin)" \
71+
-DCMAKE_C_COMPILER=mpicc -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-g -Wall"
72+
```
6873

6974
5. Make your model(s) with one of the following commands
7075
```
@@ -80,5 +85,22 @@ See [this blog post](https://ross-org.github.io/setup/running-sim.html) for deta
8085
./your-model --synch=1 // sequential mode
8186
mpirun -np 2 ./your-model --synch=2 // conservative mode
8287
mpirun -np 2 ./your-model --synch=3 // optimistic mode
83-
./your-model --synch=4 // optimistic debug mode (note: not a parallel execution!)
88+
mpirun -np 1 ./your-model --synch=4 // optimistic debug mode (note: not a parallel execution!)
89+
mpirun -np 2 ./your-model --synch=5 // optimistic realtime mode
90+
mpirun -np 1 ./your-model --synch=6 // reverse handler check mode
91+
```
92+
93+
You can pass arguments to your model from the command line as shown above. However, for better readability, it is also possible to pass command line arguments through a text file.
94+
95+
A sample text file sample.txt is included below.
96+
```
97+
# Synchonization protocol
98+
--synch=4
99+
# AVL Tree contains 2^avl-size nodes (default 18)
100+
--avl-size=18
101+
```
102+
103+
The text file is then parsed by ROSS through the args-file command line argument.
104+
```
105+
./your-model --args-file=sample.txt
84106
```

core/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ queue/tw-queue.h
77
queue/${QUEUE}.c
88

99
ross-random.h
10-
ross-random.c
10+
ross-random-internal.h
11+
ross-random-internal.c
1112
rand-${RAND}.h
1213
rand-${RAND}.c
1314

1415
clock/${CLOCK}.h
1516
clock/${CLOCK}.c
1617

1718
ross-gvt.h
19+
ross-gvt-internal.h
1820
gvt/${GVT}.h
1921
gvt/${GVT}.c
2022

23+
ross-network.h
2124
network-${NETWORK}.h
2225
network-${NETWORK}.c
2326

@@ -33,10 +36,12 @@ tw-state.c
3336
ross-extern.h
3437
ross-global.c
3538

39+
ross-base.h
3640
ross-inline.h
3741
ross-kernel-inline.h
3842
ross.h
3943
ross-types.h
44+
ross-clock.h
4045

4146
tw-eventq.h
4247
tw-event.c
@@ -64,7 +69,11 @@ instrumentation/st-event-trace.c
6469
instrumentation/st-model-data.c
6570
instrumentation/ross-lps/analysis-lp.h
6671
instrumentation/ross-lps/analysis-lp.c
67-
instrumentation/ross-lps/specialized-lps.c)
72+
instrumentation/ross-lps/specialized-lps.c
73+
74+
check-revent/crv-state.h
75+
check-revent/crv-state.c
76+
)
6877

6978
# ROSS VERSION INFORMATION
7079
## Print Date and Time at top of ROSS output
@@ -167,6 +176,7 @@ SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENE
167176
# CODES config bin
168177
SET(ROSS_CC $ENV{CC})
169178
SET(ROSS_CXX $ENV{CXX})
179+
STRING(REPLACE " " "\\ " CMAKE_INSTALL_PREFIX_ESCAPED "\"${CMAKE_INSTALL_PREFIX}\"")
170180
CONFIGURE_FILE(ross-config.in ross-config @ONLY)
171181
CONFIGURE_FILE(ross.pc.in ross.pc @ONLY)
172182
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/ross.pc.in PROPERTIES GENERATED FALSE)

core/avl_tree.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#include <stdio.h>
2-
#include <stdlib.h>
1+
#include "avl_tree.h"
2+
#include <math.h>
33
#include <assert.h>
4+
#include "ross-kernel-inline.h"
45

56
/* Copied and modified from http://pine.cs.yale.edu/pinewiki/C/AvlTree google cache */
67

7-
#include "avl_tree.h"
8-
98
/* implementation of an AVL tree with explicit heights */
109

1110
tw_pe *pe;

core/avl_tree.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#include <ross.h>
1+
#ifndef INC_avl_tree_h
2+
#define INC_avl_tree_h
3+
4+
#include "ross-types.h"
25

36
/* Copied and modified from http://pine.cs.yale.edu/pinewiki/C/AvlTree google cache */
47

@@ -43,3 +46,5 @@ tw_event * avlDelete(AvlTree *t, tw_event *key);
4346
AvlTree avl_alloc(void);
4447

4548
void avl_free(AvlTree t);
49+
50+
#endif /* INC_avl_tree_h */

core/buddy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef BUDDY_H
22
#define BUDDY_H
33

4+
#include <stdint.h>
45
#include <sys/queue.h>
56

67
/**

core/check-revent/crv-state.c

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
#include "ross.h"
2+
3+
// Defining simple linked list because we don't care about speed at
4+
// initialization for SEQUENTIAL_ROLLBACK_CHECK
5+
struct llist_chptr {
6+
crv_checkpointer * val;
7+
struct llist_chptr * next;
8+
};
9+
struct llist_chptr * head_linked_list = NULL;
10+
struct llist_chptr * tail_linked_list = NULL;
11+
12+
struct crv_checkpointer ** checkpointer_for_lps = NULL;
13+
14+
void crv_add_custom_state_checkpoint(crv_checkpointer * state_checkpoint) {
15+
struct llist_chptr * next = malloc(sizeof(struct llist_chptr));
16+
if (next == NULL) {
17+
tw_error(TW_LOC, "Could not allocate memory");
18+
}
19+
next->val = state_checkpoint;
20+
next->next = NULL;
21+
22+
if (head_linked_list == NULL) {
23+
tail_linked_list = head_linked_list = next;
24+
} else {
25+
tail_linked_list->next = next;
26+
tail_linked_list = next;
27+
}
28+
}
29+
30+
static void crv_clean_linkedlist(void) {
31+
if (head_linked_list == NULL) {
32+
return;
33+
}
34+
35+
struct llist_chptr * prev = head_linked_list;
36+
struct llist_chptr * iter = prev->next;
37+
while (iter != NULL) {
38+
free(prev);
39+
prev = iter;
40+
iter = iter->next;
41+
}
42+
free(tail_linked_list);
43+
head_linked_list = NULL;
44+
tail_linked_list = NULL;
45+
}
46+
47+
size_t crv_init_checkpoints(void) {
48+
// No need to construct array with crv_checkpointer's if there isn't any
49+
if (head_linked_list == NULL) {
50+
return 0;
51+
}
52+
53+
checkpointer_for_lps = malloc(g_tw_nlp * sizeof(struct crv_checkpointer *));
54+
55+
size_t largest_lp_checkpoint = 0;
56+
for (size_t i = 0; i < g_tw_nlp; i++) {
57+
tw_lp * lp = g_tw_lp[i];
58+
struct crv_checkpointer * state_checkpointer = NULL;
59+
60+
// Finding crv_checkpointer, if it exists, for current lp
61+
for (struct llist_chptr * iter = head_linked_list; iter != NULL; iter = iter->next) {
62+
if (lp->type == iter->val->lptype) {
63+
state_checkpointer = iter->val;
64+
break;
65+
}
66+
}
67+
68+
checkpointer_for_lps[i] = state_checkpointer;
69+
70+
if (state_checkpointer != NULL && state_checkpointer->sz_storage > largest_lp_checkpoint) {
71+
largest_lp_checkpoint = state_checkpointer->sz_storage;
72+
}
73+
74+
}
75+
76+
crv_clean_linkedlist();
77+
78+
return largest_lp_checkpoint;
79+
}
80+
81+
static crv_checkpointer * get_chkpntr(tw_lpid id) {
82+
if (checkpointer_for_lps == NULL) {
83+
return NULL;
84+
}
85+
return checkpointer_for_lps[id];
86+
}
87+
88+
static void print_event(crv_checkpointer const * chkptr, tw_lp * clp, tw_event * cev) {
89+
fprintf(stderr, "\n Event:\n ---------\n");
90+
fprintf(stderr, " Bit field contents\n");
91+
tw_bf b = cev->cv;
92+
fprintf(stderr, " c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15\n");
93+
fprintf(stderr, " %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", b.c0, b.c1, b.c2, b.c3, b.c4, b.c5, b.c6, b.c7, b.c8, b.c9, b.c10, b.c11, b.c12, b.c13, b.c14, b.c15);
94+
fprintf(stderr, " c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31\n");
95+
fprintf(stderr, " %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", b.c16, b.c17, b.c18, b.c19, b.c20, b.c21, b.c22, b.c23, b.c24, b.c25, b.c26, b.c27, b.c28, b.c29, b.c30, b.c31);
96+
fprintf(stderr, " ---------\n Event contents\n");
97+
tw_fprint_binary_array(stderr, "", tw_event_data(cev), g_tw_msg_sz);
98+
if (chkptr && chkptr->print_event) {
99+
fprintf(stderr, "---------------------------------\n");
100+
chkptr->print_event(stderr, "", clp->cur_state, tw_event_data(cev));
101+
}
102+
fprintf(stderr, "---------------------------------\n");
103+
}
104+
105+
void crv_check_lpstates(
106+
tw_lp * clp,
107+
tw_event * cev,
108+
crv_lpstate_checkpoint_internal const * before_state,
109+
char const * before_msg,
110+
char const * after_msg
111+
) {
112+
crv_checkpointer const * chkptr = get_chkpntr(clp->id);
113+
114+
bool state_equal;
115+
if (chkptr && chkptr->check_lps) {
116+
state_equal = chkptr->check_lps(before_state->state, clp->cur_state);
117+
} else {
118+
state_equal = !memcmp(before_state->state, clp->cur_state, clp->type->state_sz);
119+
}
120+
121+
if (!state_equal) {
122+
fprintf(stderr, "Error found by a rollback of an event\n");
123+
fprintf(stderr, " The state of the LP is not consistent when rollbacking!\n");
124+
fprintf(stderr, " LPID = %lu\n", clp->gid);
125+
fprintf(stderr, "\n LP contents (%s):\n", before_msg);
126+
tw_fprint_binary_array(stderr, "", before_state->state, clp->type->state_sz);
127+
if (chkptr && chkptr->print_checkpoint) {
128+
fprintf(stderr, "---------------------------------\n");
129+
chkptr->print_checkpoint(stderr, "", before_state->state);
130+
fprintf(stderr, "---------------------------------\n");
131+
}
132+
fprintf(stderr, "\n LP contents (%s):\n", after_msg);
133+
tw_fprint_binary_array(stderr, "", clp->cur_state, clp->type->state_sz);
134+
if (chkptr && chkptr->print_lp) {
135+
fprintf(stderr, "---------------------------------\n");
136+
chkptr->print_lp(stderr, "", clp->cur_state);
137+
fprintf(stderr, "---------------------------------\n");
138+
}
139+
print_event(chkptr, clp, cev);
140+
tw_net_abort();
141+
}
142+
if (memcmp(&before_state->rng, clp->rng, sizeof(struct tw_rng_stream))) {
143+
fprintf(stderr, "Error found by rollback of an event\n");
144+
fprintf(stderr, " Random number generation `rng` did not rollback properly!\n");
145+
fprintf(stderr, " This often happens if the random number generation was not properly rollbacked by the reverse handler!\n");
146+
fprintf(stderr, " LPID = %lu\n", clp->gid);
147+
fprintf(stderr, "\n rng contents (%s):\n", before_msg);
148+
tw_fprint_binary_array(stderr, "", &before_state->rng, sizeof(struct tw_rng_stream));
149+
fprintf(stderr, "\n rng contents (%s):\n", after_msg);
150+
tw_fprint_binary_array(stderr, "", clp->rng, sizeof(struct tw_rng_stream));
151+
print_event(chkptr, clp, cev);
152+
tw_net_abort();
153+
}
154+
if (memcmp(&before_state->core_rng, clp->core_rng, sizeof(struct tw_rng_stream))) {
155+
fprintf(stderr, "Error found by rollback of an event\n");
156+
fprintf(stderr, " Random number generation `core_rng` did not rollback properly!\n");
157+
fprintf(stderr, " LPID = %lu\n", clp->gid);
158+
fprintf(stderr, "\n core_rng contents (%s):\n", before_msg);
159+
tw_fprint_binary_array(stderr, "", &before_state->core_rng, sizeof(struct tw_rng_stream));
160+
fprintf(stderr, "\n core_rng contents (%s):\n", after_msg);
161+
tw_fprint_binary_array(stderr, "", clp->core_rng, sizeof(struct tw_rng_stream));
162+
print_event(chkptr, clp, cev);
163+
tw_net_abort();
164+
}
165+
if (before_state->triggered_gvt_hook != clp->triggered_gvt_hook) {
166+
fprintf(stderr, "Error found by rollback of an event\n");
167+
fprintf(stderr, " triggered_gvt_hook incogruent value, this is most likely the result of not calling tw_trigger_gvt_hook_now_rev when rollbacking tw_trigger_gvt_hook_now!\n");
168+
fprintf(stderr, " LPID = %lu\n", clp->gid);
169+
fprintf(stderr, "\n lp->triggered_gvt_hook (%s) = %d\n", before_msg, before_state->triggered_gvt_hook);
170+
fprintf(stderr, "\n lp->triggered_gvt_hook contents (%s) = %d\n", after_msg, clp->triggered_gvt_hook);
171+
print_event(chkptr, clp, cev);
172+
tw_net_abort();
173+
}
174+
}
175+
176+
void crv_copy_lpstate(crv_lpstate_checkpoint_internal * into, tw_lp const * clp) {
177+
crv_checkpointer const * chkptr = get_chkpntr(clp->id);
178+
179+
if (chkptr && chkptr->save_lp) {
180+
chkptr->save_lp(into->state, clp->cur_state);
181+
} else {
182+
memcpy(into->state, clp->cur_state, clp->type->state_sz);
183+
}
184+
memcpy(&into->rng, clp->rng, sizeof(struct tw_rng_stream));
185+
memcpy(&into->core_rng, clp->core_rng, sizeof(struct tw_rng_stream));
186+
into->triggered_gvt_hook = clp->triggered_gvt_hook;
187+
}
188+
189+
void crv_clean_lpstate(crv_lpstate_checkpoint_internal * state, tw_lp const * clp) {
190+
crv_checkpointer const * chkptr = get_chkpntr(clp->id);
191+
192+
if (chkptr && chkptr->clean_lp) {
193+
chkptr->clean_lp(state->state);
194+
}
195+
}

0 commit comments

Comments
 (0)