Skip to content

Commit c0dfa0f

Browse files
authored
Merge pull request #1 from kaajalbgupta/hybrid_backend
Introducing the Hybrid Backend
2 parents ff949c4 + 4bdf8f7 commit c0dfa0f

36 files changed

+1799
-366
lines changed

hardware/input_gen/generate_synthetic_trace.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ static constexpr uint32_t ip(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
5454
}
5555

5656
int main(int argc, char const* argv[]) {
57-
if (argc != 6) {
58-
std::cerr << "Usage: " << argv[0] << " NB_PKTS PKT_SIZE NB_SRC NB_DST "
57+
if (argc != 7) {
58+
std::cerr << "Usage: " << argv[0]
59+
<< " NB_PKTS PKT_SIZE NB_SRC NB_DST DST_START "
5960
<< "OUTPUT_PCAP" << std::endl;
6061
exit(1);
6162
}
@@ -64,7 +65,8 @@ int main(int argc, char const* argv[]) {
6465
const int pkt_size = std::stoi(argv[2]);
6566
const int nb_src = std::stoi(argv[3]);
6667
const int nb_dst = std::stoi(argv[4]);
67-
const std::string output_pcap = argv[5];
68+
const int dst_start = std::stoi(argv[5]);
69+
const std::string output_pcap = argv[6];
6870

6971
// Skip if pcap with same name already exists.
7072
{
@@ -109,7 +111,7 @@ int main(int argc, char const* argv[]) {
109111
pkt_hdr.ts = ts;
110112

111113
uint32_t src_ip = ip(192, 168, 0, 0);
112-
uint32_t dst_ip = ip(192, 168, 0, 0);
114+
uint32_t dst_ip = ip(192, 168, 0, dst_start);
113115

114116
uint32_t mss =
115117
pkt_size - sizeof(*l2_hdr) - sizeof(*l3_hdr) - sizeof(*l4_hdr) - 4;

meson_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ option('enso_pipe_size', type: 'integer', min: 0, max: 32768, value: 32768,
66
description: 'Buffer size used by each software enso pipe')
77
option('latency_opt', type: 'boolean', value: true,
88
description: 'Optimize for latency')
9-
option('dev_backend', type: 'combo', choices: ['intel_fpga', 'software'],
9+
option('dev_backend', type: 'combo', choices: ['intel_fpga', 'hybrid'],
1010
value: 'intel_fpga', description: 'Device backend to use')

software/examples/example_helpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
3232

33-
#ifndef SOFTWARE_EXAMPLES_EXAMPLE_HELPERS_H_
34-
#define SOFTWARE_EXAMPLES_EXAMPLE_HELPERS_H_
33+
#ifndef ENSO_SOFTWARE_EXAMPLES_EXAMPLE_HELPERS_H_
34+
#define ENSO_SOFTWARE_EXAMPLES_EXAMPLE_HELPERS_H_
3535

3636
#include <arpa/inet.h>
3737

@@ -41,4 +41,4 @@ const uint32_t kBaseIpAddress = ntohl(inet_addr("192.168.0.0"));
4141
const uint32_t kDstPort = 80;
4242
const uint32_t kProtocol = 0x11;
4343

44-
#endif // SOFTWARE_EXAMPLES_EXAMPLE_HELPERS_H_
44+
#endif // ENSO_SOFTWARE_EXAMPLES_EXAMPLE_HELPERS_H_

software/examples/meson.build

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
thread_dep = dependency('threads')
33
pcap_dep = dependency('pcap', version : '>=1.0')
44

5-
executable('echo', 'echo.cpp', dependencies: thread_dep, link_with: enso_lib,
5+
executable('echo', 'echo.cpp', dependencies: [thread_dep], link_with: enso_lib,
66
include_directories: inc)
7-
executable('echo_event', 'echo_event.cpp', dependencies: thread_dep,
7+
executable('echo_event', 'echo_event.cpp', dependencies: [thread_dep],
88
link_with: enso_lib, include_directories: inc)
9-
executable('echo_prefetch', 'echo_prefetch.cpp', dependencies: thread_dep,
9+
executable('echo_prefetch', 'echo_prefetch.cpp', dependencies: [thread_dep],
1010
link_with: enso_lib, include_directories: inc)
11-
executable('echo_copy', 'echo_copy.cpp', dependencies: thread_dep,
11+
executable('echo_copy', 'echo_copy.cpp', dependencies: [thread_dep],
1212
link_with: enso_lib, include_directories: inc)
1313
executable('ensogen', 'ensogen.cpp', dependencies: [thread_dep, pcap_dep],
1414
link_with: enso_lib, include_directories: inc)
1515
executable('capture', 'capture.cpp', dependencies: [thread_dep, pcap_dep],
1616
link_with: enso_lib, include_directories: inc)
17-
executable('l2_forward', 'l2_forward.cpp', dependencies: thread_dep,
17+
executable('l2_forward', 'l2_forward.cpp', dependencies: [thread_dep],
1818
link_with: enso_lib, include_directories: inc)

software/include/enso/config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
* @author Hugo Sadok <[email protected]>
3838
*/
3939

40-
#ifndef SOFTWARE_INCLUDE_ENSO_CONFIG_H_
41-
#define SOFTWARE_INCLUDE_ENSO_CONFIG_H_
40+
#ifndef ENSO_SOFTWARE_INCLUDE_ENSO_CONFIG_H_
41+
#define ENSO_SOFTWARE_INCLUDE_ENSO_CONFIG_H_
4242

4343
#include <enso/internals.h>
4444

@@ -165,4 +165,4 @@ int update_fallback_queues_config(
165165

166166
} // namespace enso
167167

168-
#endif // SOFTWARE_INCLUDE_ENSO_CONFIG_H_
168+
#endif // ENSO_SOFTWARE_INCLUDE_ENSO_CONFIG_H_

software/include/enso/consts.h

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
* @author Hugo Sadok <[email protected]>
3939
*/
4040

41-
#ifndef SOFTWARE_INCLUDE_ENSO_CONSTS_H_
42-
#define SOFTWARE_INCLUDE_ENSO_CONSTS_H_
41+
#ifndef ENSO_SOFTWARE_INCLUDE_ENSO_CONSTS_H_
42+
#define ENSO_SOFTWARE_INCLUDE_ENSO_CONSTS_H_
4343

4444
#include <cstdint>
4545
#include <string>
@@ -87,6 +87,10 @@ static constexpr std::string_view kHugePageRxPipePathPrefix = "_rx_pipe:";
8787
static constexpr std::string_view kHugePagePathPrefix = "_tx_pipe:";
8888
static constexpr std::string_view kHugePageNotifBufPathPrefix = "_notif_buf:";
8989
static constexpr std::string_view kHugePageQueuePathPrefix = "_queue:";
90+
static constexpr std::string_view kHugePageUthreadsPathPrefix = "_uthread:";
91+
static constexpr std::string_view kHugePageKthreadsPathPrefix = "_kthread:";
92+
static constexpr std::string_view kHugePageQueueTailPathPrefix = "_queue_tail";
93+
static constexpr std::string_view kHugePageQueueHeadPathPrefix = "_queue_head";
9094

9195
// We need this to allow the same huge page to be mapped to adjacent memory
9296
// regions.
@@ -146,50 +150,79 @@ enum class NotifType : uint8_t {
146150
kSetRrStatus = 6,
147151
kGetRrStatus = 7,
148152
kFreeNotifBuf = 8,
149-
kFreePipe = 9
153+
kFreePipe = 9,
154+
kGetShinkansenNotifBufId = 10,
155+
kRegisterKthread = 11,
156+
kUthreadWaiting = 12,
157+
kKthreadYield = 13
150158
};
151159

152160
struct MmioNotification {
153161
NotifType type;
154162
uint64_t address;
155163
uint64_t value;
164+
uint64_t padding;
156165
};
157166

158167
struct FallbackNotification {
159168
NotifType type;
160169
uint64_t nb_fallback_queues;
161170
uint64_t result;
171+
uint64_t padding;
162172
};
163173

164174
struct RoundRobinNotification {
165175
NotifType type;
166176
uint64_t round_robin;
167177
uint64_t result;
178+
uint64_t padding;
168179
};
169180

170181
struct NotifBufNotification {
171182
NotifType type;
172183
uint64_t notif_buf_id;
184+
uint64_t uthread_id;
173185
uint64_t result;
174186
};
175187

176188
struct AllocatePipeNotification {
177189
NotifType type;
178190
uint64_t fallback;
179191
uint64_t pipe_id;
192+
uint64_t padding;
180193
};
181194

182195
struct FreePipeNotification {
183196
NotifType type;
184197
uint64_t pipe_id;
185198
uint64_t result;
199+
uint64_t padding;
200+
};
201+
202+
struct ShinkansenNotification {
203+
NotifType type;
204+
uint64_t notif_queue_id;
205+
uint64_t padding[2];
206+
};
207+
208+
struct KthreadNotification {
209+
NotifType type;
210+
uint64_t application_id;
211+
uint64_t padding[2];
212+
};
213+
214+
struct YieldNotification {
215+
NotifType type;
216+
uint64_t notif_buf_id;
217+
uint64_t last_rx_notif_head;
218+
uint64_t last_tx_consumed_head;
186219
};
187220

188221
struct PipeNotification {
189222
NotifType type;
190-
uint64_t data[2];
223+
uint64_t data[3];
191224
};
192225

193226
} // namespace enso
194227

195-
#endif // SOFTWARE_INCLUDE_ENSO_CONSTS_H_
228+
#endif // ENSO_SOFTWARE_INCLUDE_ENSO_CONSTS_H_

software/include/enso/helpers.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
* @author Hugo Sadok <[email protected]>
3737
*/
3838

39-
#ifndef SOFTWARE_INCLUDE_ENSO_HELPERS_H_
40-
#define SOFTWARE_INCLUDE_ENSO_HELPERS_H_
39+
#ifndef ENSO_SOFTWARE_INCLUDE_ENSO_HELPERS_H_
40+
#define ENSO_SOFTWARE_INCLUDE_ENSO_HELPERS_H_
4141

4242
#include <endian.h>
4343
#include <enso/consts.h>
@@ -128,6 +128,20 @@ void print_pkt_header(uint8_t* pkt);
128128

129129
void print_buf(void* buf, const uint32_t nb_cache_lines);
130130

131+
/**
132+
* @brief Sets the core ID of current thread using C methods.
133+
*
134+
* @param core_id the core ID to set the thread to.
135+
*
136+
* @return Success/failure of sched_setaffinity.
137+
*/
138+
int set_self_core_id(int core_id);
139+
140+
/**
141+
* @brief Gets the TID of the current thread.
142+
*/
143+
pid_t get_tid(void);
144+
131145
int set_core_id(std::thread& thread, int core_id);
132146

133147
void show_stats(const std::vector<stats_t>& thread_stats,
@@ -180,4 +194,4 @@ _enso_always_inline void memcpy_64_align(void* dst, const void* src, size_t n) {
180194

181195
} // namespace enso
182196

183-
#endif // SOFTWARE_INCLUDE_ENSO_HELPERS_H_
197+
#endif // ENSO_SOFTWARE_INCLUDE_ENSO_HELPERS_H_

software/include/enso/internals.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
*/
4040

4141
// TODO(sadok): Do not expose this header.
42-
#ifndef SOFTWARE_INCLUDE_ENSO_INTERNALS_H_
43-
#define SOFTWARE_INCLUDE_ENSO_INTERNALS_H_
42+
#ifndef ENSO_SOFTWARE_INCLUDE_ENSO_INTERNALS_H_
43+
#define ENSO_SOFTWARE_INCLUDE_ENSO_INTERNALS_H_
4444

4545
#include <stdint.h>
4646

@@ -83,7 +83,10 @@ struct __attribute__((__packed__)) TxNotification {
8383
struct NotificationBufPair {
8484
// First cache line:
8585
struct RxNotification* rx_buf;
86-
enso_pipe_id_t* next_rx_pipe_ids; // Next pipe ids to consume from rx_buf.
86+
struct RxNotification**
87+
next_rx_pipe_notifs; // Next pipe notifications to consume from rx_buf:
88+
// stored in ring buffer by next_rx_ids_head and
89+
// next_rx_ids_tail
8790
struct TxNotification* tx_buf;
8891
uint32_t* rx_head_ptr;
8992
uint32_t* tx_tail_ptr;
@@ -118,8 +121,9 @@ struct RxEnsoPipeInternal {
118121
uint64_t phys_buf_offset; // Use to convert between phys and virt address.
119122
enso_pipe_id_t id;
120123
std::string huge_page_prefix;
124+
void* uio_mmap_bar2_addr; // UIO mmap address for BAR 2.
121125
};
122126

123127
} // namespace enso
124128

125-
#endif // SOFTWARE_INCLUDE_ENSO_INTERNALS_H_
129+
#endif // ENSO_SOFTWARE_INCLUDE_ENSO_INTERNALS_H_

software/include/enso/ixy_helpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
* [ixy driver](https://github.com/emmericp/ixy/blob/master/src/memory.c)
3636
*/
3737

38-
#ifndef SOFTWARE_INCLUDE_ENSO_IXY_HELPERS_H_
39-
#define SOFTWARE_INCLUDE_ENSO_IXY_HELPERS_H_
38+
#ifndef ENSO_SOFTWARE_INCLUDE_ENSO_IXY_HELPERS_H_
39+
#define ENSO_SOFTWARE_INCLUDE_ENSO_IXY_HELPERS_H_
4040

4141
#include <cstdint>
4242
#include <string>
@@ -70,4 +70,4 @@ void* get_huge_page(const std::string& path, size_t size = 0,
7070

7171
} // namespace enso
7272

73-
#endif // SOFTWARE_INCLUDE_ENSO_IXY_HELPERS_H_
73+
#endif // ENSO_SOFTWARE_INCLUDE_ENSO_IXY_HELPERS_H_

software/include/enso/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ public_enso_headers = files(
99
'socket.h'
1010
)
1111

12-
install_headers(public_enso_headers, subdir: 'enso')
12+
install_headers(public_enso_headers, subdir: library_name)

0 commit comments

Comments
 (0)