The ROme OpTimistic Simulator  3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
msg.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <core/core.h>
14 
15 #include <stdatomic.h>
16 #include <stddef.h>
17 
18 #define BASE_PAYLOAD_SIZE 48
19 
20 #define msg_is_before(msg_a, msg_b) ((msg_a)->dest_t < (msg_b)->dest_t)
21 #define msg_bare_size(msg) (offsetof(struct lp_msg, pl) + (msg)->pl_size)
22 
23 #define msg_id_get(msg, cur_phase) \
24  (((uintptr_t)msg) | ((unsigned)(cur_phase) << 1))
25 #define msg_id_phase_get(msg_id) (((msg_id) >> 1) & 1U)
26 #define msg_id_anti_phase_get(msg_id) ((msg_id) & 1U)
27 #define msg_id_anti_phase_set(msg_id, phase) \
28 __extension__({ \
29  (msg_id) &= ~((uintptr_t) 1U); \
30  (msg_id) |= (phase); \
31 })
32 
34 struct lp_msg {
40  uint_fast32_t m_type;
41 #if LOG_LEVEL <= LOG_DEBUG
42  lp_id_t send;
43  simtime_t send_t;
44 #endif
45  uint_fast32_t pl_size;
47  union {
49  atomic_int flags;
51  uintptr_t msg_id;
52  };
54  unsigned char pl[BASE_PAYLOAD_SIZE];
56  unsigned char extra_pl[];
57 };
58 
59 enum msg_flag {
60  MSG_FLAG_ANTI = 1,
61  MSG_FLAG_PROCESSED = 2
62 };
63 
64 
65 
simtime_t
double simtime_t
The type used to represent logical time in the simulation.
Definition: core.h:62
lp_msg::extra_pl
unsigned char extra_pl[]
The continuation of the payload.
Definition: msg.h:56
lp_msg::flags
atomic_int flags
The flags to handle local anti messages.
Definition: msg.h:49
lp_msg::m_type
uint_fast32_t m_type
The message type, a user controlled field.
Definition: msg.h:40
lp_msg
A model simulation message.
Definition: msg.h:34
lp_msg::dest
lp_id_t dest
The id of the recipient LP.
Definition: msg.h:36
lp_msg::pl
unsigned char pl[48]
The initial part of the payload.
Definition: msg.h:54
lp_id_t
uint64_t lp_id_t
Used to uniquely identify LPs in the simulation.
Definition: core.h:75
core.h
Core ROOT-Sim functionalities.
lp_msg::pl_size
uint_fast32_t pl_size
The message payload size.
Definition: msg.h:46
lp_msg::msg_id
uintptr_t msg_id
The message unique id, used for inter-node anti messages.
Definition: msg.h:51
lp_msg::dest_t
simtime_t dest_t
The intended destination logical time of this message.
Definition: msg.h:38