 |
The ROme OpTimistic Simulator
3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
|
Go to the documentation of this file.
16 #include <stdatomic.h>
21 #define THREAD_REPS 100000
25 static struct lp_ctx lps_m[THREAD_CNT];
26 static atomic_uint msg_missing = THREAD_REPS * THREAD_CNT;
27 static atomic_uint msg_to_free = THREAD_CNT;
29 struct lp_ctx *lps = lps_m;
31 void msg_allocator_free(
struct lp_msg *msg)
33 atomic_fetch_sub_explicit(&msg_to_free, 1U, memory_order_relaxed);
37 static int msg_queue_test_init(
void)
43 static int msg_queue_test_fini(
void)
46 return -(atomic_load(&msg_missing) | atomic_load(&msg_to_free));
49 static int msg_queue_test(
void)
57 unsigned i = THREAD_REPS;
59 struct lp_msg *msg = malloc(
sizeof(*msg));
60 memset(msg, 0,
sizeof(*msg));
72 if(msg->
dest_t < last_time)
76 atomic_fetch_sub_explicit(&msg_missing, 1U, memory_order_relaxed);
82 msg = malloc(
sizeof(*msg));
83 memset(msg, 0,
sizeof(*msg));
94 .test_init_fnc = msg_queue_test_init,
95 .test_fini_fnc = msg_queue_test_fini,
96 .test_fnc = msg_queue_test
#define lcg_random(rng_state)
Computes a pseudo random number in the [0, 1] range.
double simtime_t
The type used to represent logical time in the simulation.
void msg_queue_init(void)
Initializes the message queue for the current thread.
struct lp_msg * msg_queue_extract(void)
Extracts the next message from the queue.
A model simulation message.
void msg_queue_global_init(void)
Initializes the message queue at the node level.
lp_id_t dest
The id of the recipient LP.
A complete test configuration.
LP construction functions.
bool test_thread_barrier(void)
Synchronizes threads on a barrier.
__thread rid_t rid
The identifier of the thread.
#define lcg_init(rng_state, initseq)
Initializes the random number generator.
void msg_queue_insert(struct lp_msg *msg)
Inserts a message in the queue.
void msg_queue_fini(void)
Finalizes the message queue for the current thread.
unsigned threads_count
test_fnc is executed with that many cores
Pseudo random number generator for tests.
void msg_queue_global_fini(void)
Finalizes the message queue at the node level.
simtime_t dest_t
The intended destination logical time of this message.
__uint128_t test_rng_state
The type of this pseudo random number generator state.
uint64_t n_lps_node
The total number of LPs hosted in the node.