Skip to content

Commit f86a8f6

Browse files
committed
NICA: memcached AFU
Based on 3d78b50
1 parent b09dd8a commit f86a8f6

Some content is hidden

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

72 files changed

+2532
-592
lines changed

CMakeLists.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ find_package(Threads REQUIRED)
5353
link_directories(../googletest/googlemock/gtest)
5454

5555
if(BUILD_SOFTWARE)
56+
add_subdirectory(libnica)
5657
add_subdirectory(baseline)
5758
endif()
5859

@@ -71,7 +72,7 @@ function(hls_target proj hls_target_name sources testbench_sources top_function)
7172
COMMAND bash -c ${cmd} > ${proj}.tcl
7273
DEPENDS ${CMAKE_SOURCE_DIR}/ikernels/ikernel.tcl.in
7374
)
74-
add_custom_target(${hls_target_name}
75+
add_custom_target(${hls_target_name}-hls
7576
COMMAND env PATH=${TCPDUMP_PATH}:$$PATH GTEST_ROOT=${GTEST_ROOT}
7677
NUM_IKERNELS=${NUM_IKERNELS}
7778
NUM_TC=${NUM_TC}
@@ -80,7 +81,7 @@ function(hls_target proj hls_target_name sources testbench_sources top_function)
8081
MEMCACHED_VALUE_SIZE=${MEMCACHED_VALUE_SIZE}
8182
${XILINX_VIVADO_HLS}/bin/vivado_hls
8283
${proj}.tcl
83-
DEPENDS ${proj}_tests ${proj}.tcl ${CMAKE_SOURCE_DIR}/nica/ikernel.tcl nica-hls
84+
DEPENDS ${proj}_tests ${proj}.tcl ${CMAKE_SOURCE_DIR}/nica/ikernel.tcl nica-csim
8485
)
8586
add_custom_target(${hls_target_name}-sim
8687
COMMAND env PATH=${TCPDUMP_PATH}:$$PATH GTEST_ROOT=${GTEST_ROOT}
@@ -91,15 +92,15 @@ function(hls_target proj hls_target_name sources testbench_sources top_function)
9192
MEMCACHED_VALUE_SIZE=${MEMCACHED_VALUE_SIZE}
9293
SIMULATION_BUILD=1
9394
${XILINX_VIVADO_HLS}/bin/vivado_hls ${proj}.tcl
94-
DEPENDS ${proj}_tests ${proj}.tcl ${CMAKE_SOURCE_DIR}/nica/ikernel.tcl nica-hls
95+
DEPENDS ${proj}_tests ${proj}.tcl ${CMAKE_SOURCE_DIR}/nica/ikernel.tcl nica-csim
9596
)
9697
endfunction(hls_target)
9798

9899
function(add_gtest name)
99100
target_link_libraries(${name}_tests ${GTEST_LIBRARIES} ${UUID_LIBRARIES})
100101
target_compile_features(${name}_tests PRIVATE cxx_lambdas)
101102
target_link_libraries(${name}_tests Threads::Threads)
102-
target_link_libraries(${name}_tests nica-hls)
103+
target_link_libraries(${name}_tests nica-csim)
103104
endfunction(add_gtest)
104105

105106
### Adds a new ikernel.

Jenkinsfile

+7-21
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ properties ([parameters([
3838
])])
3939

4040
def build_hls_project(build_dir, project, simulation) {
41-
def target = simulation ? "${project}-sim" : "${project}"
41+
def target = simulation ? "${project}-sim" : "${project}-hls"
4242
if (simulation) {
4343
echo "Running HLS RTL/C cosimulation for project ${project}."
4444
} else {
@@ -98,12 +98,6 @@ node {
9898
// Pull request build
9999
checkout scm
100100
}
101-
dir ('libvma') {
102-
// libvma is needed to build the host apps
103-
git credentialsId: '336fdc5e-b4a2-47dc-adde-ce4343484399', url:
104-
'[email protected]:haggai_e/libvma.git', branch: 'nica'
105-
}
106-
107101
dir ('googletest') {
108102
// Google test for the HLS ikernel tests and NICA tests
109103
git 'https://github.com/google/googletest'
@@ -112,24 +106,12 @@ node {
112106
$CMAKE -DBUILD_GMOCK=OFF -DBUILD_GTEST=ON .
113107
make -j"""
114108
}
115-
dir('libvma') {
116-
// Build libvma, pointing it to the HLS repository for its headers
117-
withEnv(["ACLOCAL_PATH=/usr/share/aclocal"]) {
118-
sh '''
119-
./autogen.sh
120-
./configure IKERNEL_PATH=`pwd`/../nica
121-
make -j
122-
'''
123-
}
124-
}
125109
dir('nica/build') {
126110
// Build the HLS repository (host part only)
127111
// One ikernel
128112
sh """
129113
rm -f CMakeCache.txt
130114
$CMAKE \
131-
-DNICA_DIR=`pwd`/../../libvma/src/nica \
132-
-DVMA_DIR=`pwd`/../../libvma/src \
133115
-DGTEST_ROOT=${GTEST_ROOT} \
134116
-DXILINX_VIVADO_VERSION=${params.VIVADO_VERSION} \
135117
-DNUM_IKERNELS=1 \
@@ -146,8 +128,6 @@ node {
146128
// // Two ikernels
147129
// sh """
148130
// $CMAKE \
149-
// -DNICA_DIR=`pwd`/../../libvma/src/nica \
150-
// -DVMA_DIR=`pwd`/../../libvma/src \
151131
// -DGTEST_ROOT=${GTEST_ROOT} \
152132
// -DNUM_IKERNELS=2 \
153133
// ..
@@ -182,6 +162,11 @@ node {
182162
]
183163
currentBuild.result = 'SUCCESS'
184164
parallel branches
165+
166+
// cleanup
167+
dir('nica/build') {
168+
sh "find -maxdepth 4 -name .autopilot -exec rm -r '{}' ';'"
169+
}
185170
}
186171

187172
// Choose the ikernel to build based on the branch name
@@ -191,6 +176,7 @@ def getBuildIkernel(branchName) {
191176
'pktgen': 'pktgen',
192177
'memcached-cr': 'memcached',
193178
'memcached-ddr': 'memcached',
179+
'async-memory': 'memcached',
194180
'echo': 'echo'
195181
].withDefault { key -> 'threshold' }
196182

README.md

+9-21
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,22 @@ It is also possible to build NICA building the `nica` target, and run an RTL/C
4343
co-simulation for that project by building the `nica-sim` target. Other
4444
ikernel targets are listed below.
4545

46-
| ikernel | target | RTL/C co-simulation |
47-
| ----------- | ------------- | ----------------- |
48-
| Passthrough | `passthrough` | `passthrough-sim` |
49-
| Threshold | `threshold` | `threshold-sim` |
50-
| pktgen | `pktgen` | `pktgen-sim` |
51-
| echo | `echo` | `echo-sim` |
52-
| Top-K | `cms` | `cms-sim` |
53-
| memcached | `memcached` | `memcached-sim` |
46+
| ikernel | target | RTL/C co-simulation |
47+
| ----------- | ----------------- | ----------------- |
48+
| Passthrough | `passthrough-hls` | `passthrough-sim` |
49+
| Threshold | `threshold-hls` | `threshold-sim` |
50+
| pktgen | `pktgen-hls` | `pktgen-sim` |
51+
| echo | `echo-hls` | `echo-sim` |
52+
| Top-K | `cms-hls` | `cms-sim` |
53+
| memcached | `memcached-hls` | `memcached-sim` |
5454

5555
## Building host software
5656

57-
The host software depends on `libnica`, which is part of a modified
58-
[libvma](https://bitbucket.org/haggai_e/libvma.git) repository:
59-
60-
```shell
61-
cd ~/workspace
62-
git clone [email protected]:haggai_e/libvma.git
63-
ACLOCAL_PATH=/usr/share/aclocal ./autogen.sh
64-
./configure IKERNEL_PATH=~/workspace/nica/nica/hls
65-
make -j
66-
```
67-
6857
Now this repository can be configured to build the software as well:
6958

7059
```shell
7160
cd ~/workspace/nica/build
72-
cmake -DGTEST_ROOT=~/workspace/googletest/googletest -DNUM_IKERNELS=1 -DBUILD_SOFTWARE=ON \
73-
-DNICA_DIR=~/workspace/libvma/src/nica -DVMA_DIR=~/workspace/libvma/src ..
61+
cmake -DGTEST_ROOT=~/workspace/googletest/googletest -DNUM_IKERNELS=1 -DBUILD_SOFTWARE=ON ..
7462
make -j
7563
```
7664

baseline/CMakeLists.txt

+3-18
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@ cmake_minimum_required(VERSION 3.1)
22
find_package(Boost COMPONENTS system program_options REQUIRED)
33
find_package(ibverbs REQUIRED)
44

5-
find_path(NICA_DIR nica.h
6-
HINTS
7-
~/workspace/libvma/src/nica
8-
)
9-
10-
find_path(VMA_DIR vma/vma_extra.h
11-
HINTS
12-
~/workspace/libvma/src
13-
)
14-
15-
find_library(LIBNICA nica
16-
HINTS
17-
${NICA_DIR}/.libs
18-
)
19-
205
find_path(NICA_HLS_DIR nica-top.hpp
216
HINTS
227
../nica/hls/
@@ -30,8 +15,8 @@ find_path(THRESHOLD_IKERNEL_DIR threshold.hpp
3015
include(FindPkgConfig)
3116
pkg_check_modules(UUID REQUIRED uuid)
3217

33-
include_directories(${UDP_INCLUDE_DIR} ${THRESHOLD_IKERNEL_DIR} ${NICA_HLS_DIR} ${NICA_DIR}
34-
${VMA_DIR} ${UUID_INCLUDE_DIRS} ${XILINX_VIVADO_HLS} ${IBVERBS_INCLUDE_DIRS})
18+
include_directories(${UDP_INCLUDE_DIR} ${THRESHOLD_IKERNEL_DIR} ${NICA_HLS_DIR}
19+
${UUID_INCLUDE_DIRS} ${XILINX_VIVADO_HLS} ${IBVERBS_INCLUDE_DIRS} ../libnica)
3520

3621
set(THREADS_PREFER_PTHREAD_FLAG ON)
3722
find_package(Threads REQUIRED)
@@ -48,7 +33,7 @@ add_executable(client RunnableUdpClient.cpp UdpClient.cpp)
4833
foreach(executable threshold_server cms_server echo_server client)
4934
target_link_libraries(${executable} Threads::Threads)
5035
target_link_libraries(${executable} ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
51-
target_link_libraries(${executable} ${LIBNICA})
36+
target_link_libraries(${executable} nica)
5237
target_link_libraries(${executable} ${UUID_LIBRARIES})
5338
target_link_libraries(${executable} ${IBVERBS_LIBRARIES})
5439
target_compile_features(${executable} PRIVATE cxx_rvalue_references cxx_generalized_initializers)

baseline/CmsServerMain.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "RunnableServerBase.hpp"
2727
#include "CmsUdpServer.hpp"
2828
#include "cms-ikernel.hpp"
29-
#include <vma/vma_extra.h>
3029

3130
#include <sstream>
3231
#include <future>

baseline/EchoServerMain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "RunnableServerBase.hpp"
2828
#include "passthrough.hpp"
2929
#include "echo.hpp"
30-
#include <vma/vma_extra.h>
30+
#include <uuid.h>
3131

3232
#include <future>
3333

baseline/ThresholdServerMain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include "StatisticsUdpServer.hpp"
2727
#include "RunnableServerBase.hpp"
2828
#include "threshold.hpp"
29-
#include <vma/vma_extra.h>
3029
#include <future>
30+
#include <uuid.h>
3131

3232
class threshold_main : public RunnableServerBase {
3333
public:

emulation/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Emulation library
22
add_library(nica-emu SHARED emu-top.cpp)
33
include_directories(../nica/hls ../ikernels/hls)
4-
target_link_libraries(nica-emu nica-hls)
4+
target_link_libraries(nica-emu nica-csim)
55
set(ikernels threshold passthrough pktgen memcached)
66
foreach(ikernel ${ikernels})
77
target_link_libraries(nica-emu ${ikernel}-emu)

emulation/emu-top.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,13 @@ namespace emulation {
9999

100100
struct ikernel_wrapper {
101101
hls_ik::ports ports;
102+
hls_ik::tc_ikernel_data_counts tc;
102103
hls_ik::ikernel_id id;
103104
virt_gateway_wrapper gateway;
104105
hls_ik::virt_gateway_registers gateway_regs;
105-
using ikernel_top_func = std::function<void(hls_ik::ports&, hls_ik::ikernel_id&, hls_ik::virt_gateway_registers&)>;
106+
using ikernel_top_func = std::function<void(hls_ik::ports&,
107+
hls_ik::ikernel_id&, hls_ik::virt_gateway_registers&,
108+
hls_ik::tc_ikernel_data_counts&)>;
106109
ikernel_top_func func;
107110

108111
ikernel_wrapper() :
@@ -125,12 +128,12 @@ namespace emulation {
125128
else
126129
throw std::exception();
127130

128-
hls_ik::init(ports);
131+
hls_ik::init(tc);
129132
}
130133

131134
void step()
132135
{
133-
func(ports, id, gateway.gateway);
136+
func(ports, id, gateway.gateway, tc);
134137
}
135138

136139
void reg_access(uint32_t address, uint32_t* value, bool read)
@@ -269,7 +272,7 @@ namespace emulation {
269272
flit.set_data(pkt->data + i, cur_len);
270273
flit.last = i + cur_len == pkt->len;
271274

272-
mlx::axi4s mlx_flit(flit, 1, 1);
275+
mlx::axi4s mlx_flit(flit, 0, 1);
273276

274277
if (pkt->dir == Net)
275278
prt_nw2sbu.write(mlx_flit);

ikernels/CMakeLists.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ include_directories(hls ../nica/hls)
88
foreach(pcap_file udp_rr.pcap
99
memcached-requests.pcap memcached-responses.pcap
1010
memcached-all-responses.pcap
11-
memcached-requests-16.pcap memcached-responses-16.pcap
12-
memcached-all-responses-16.pcap
11+
memcached-requests-16.pcap memcached-responses-16.pcap
12+
memcached-all-responses-16.pcap
13+
memcached-set-16.pcap
1314
ping.pcap pong.pcap
1415
)
1516
add_custom_target(${pcap_file}
1617
DEPENDS ${CMAKE_SOURCE_DIR}/ikernels/hls/tests/${pcap_file}
1718
COMMAND cp ${CMAKE_SOURCE_DIR}/ikernels/hls/tests/${pcap_file} ${pcap_file})
1819
endforeach(pcap_file)
1920

20-
foreach(f pong)
21+
foreach(f pong memcached-set-16)
2122
add_custom_target(${f}-padded.pcap
2223
COMMAND python ${CMAKE_SOURCE_DIR}/nica/hls/tests/pad_small_packets.py ${f}.pcap ${f}-padded.pcap
2324
DEPENDS ${f}.pcap ${CMAKE_SOURCE_DIR}/nica/hls/tests/pad_small_packets.py)
@@ -47,7 +48,7 @@ add_ikernel(pktgen "hls/pktgen.cpp;hls/passthrough.cpp" "hls/tests/pktgen_tests.
4748

4849
### Memcached
4950
add_ikernel(memcached "hls/memcached.cpp;hls/passthrough.cpp" "hls/tests/memcached_tests.cpp;../nica/hls/tests/tb.cpp" memcached memcached_top
50-
"memcached-requests.pcap;memcached-responses.pcap;memcached-all-responses.pcap;memcached-requests-16.pcap;memcached-responses-16.pcap;memcached-all-responses-16.pcap")
51+
"memcached-requests.pcap;memcached-responses.pcap;memcached-all-responses.pcap;memcached-requests-16.pcap;memcached-responses-16.pcap;memcached-all-responses-16.pcap;memcached-set-16.pcap;memcached-set-16-padded.pcap")
5152
set(MEMCACHED_CACHE_SIZE "4096" CACHE STRING
5253
"Cache size in entries for the memcached ikernel")
5354
set(MEMCACHED_KEY_SIZE "16" CACHE STRING

ikernels/hls/cms-ikernel.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void cms::read_heap(hls::stream<value_and_frequency>& heap_out, ap_uint<32> k_va
151151
}
152152
}
153153

154-
void cms::step(hls_ik::ports& p)
154+
void cms::step(hls_ik::ports& p, hls_ik::tc_ikernel_data_counts& tc)
155155
{
156156
#pragma HLS inline
157157
pass_packets(p.host);
@@ -163,7 +163,8 @@ void cms::step(hls_ik::ports& p)
163163
static cms cms_inst;
164164
void cms_ikernel(hls_ik::ports& ik, hls_ik::ikernel_id& uuid,
165165
hls_ik::virt_gateway_registers& gateway, value_and_frequency& to_heap,
166-
hls::stream<value_and_frequency>& heap_out, ap_uint<32> k_value)
166+
hls::stream<value_and_frequency>& heap_out, ap_uint<32> k_value,
167+
hls_ik::tc_ikernel_data_counts& tc)
167168
{
168169
DO_PRAGMA(HLS dataflow)
169170
DO_PRAGMA(HLS ARRAY_RESHAPE variable=uuid.uuid complete dim=1)
@@ -179,7 +180,7 @@ void cms_ikernel(hls_ik::ports& ik, hls_ik::ikernel_id& uuid,
179180

180181
using namespace hls_ik;
181182
static const ikernel_id __constant_uuid = { CMS_UUID };
182-
cms_inst.step(ik);
183+
cms_inst.step(ik, tc);
183184
cms_inst.write_to_heap(to_heap);
184185
cms_inst.read_heap(heap_out, k_value);
185186
cms_inst.gateway(&cms_inst, gateway);

ikernels/hls/cms-ikernel.hpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ struct value_and_frequency {
4545
value frequency;
4646
};
4747

48-
void cms_ikernel(hls_ik::ports& ik, hls_ik::ikernel_id& uuid, hls_ik::virt_gateway_registers& gateway,
49-
value_and_frequency& to_heap, hls::stream<value_and_frequency>& heap_out, ap_uint<32> k_value);
48+
void cms_ikernel(hls_ik::ports& ik, hls_ik::ikernel_id& uuid,
49+
hls_ik::virt_gateway_registers& gateway,
50+
value_and_frequency& to_heap,
51+
hls::stream<value_and_frequency>& heap_out,
52+
ap_uint<32> k_value,
53+
hls_ik::tc_ikernel_data_counts& tc);
5054

5155
class cms : public hls_ik::ikernel, public hls_ik::virt_gateway_impl<cms> {
5256
public:
5357

54-
virtual void step(hls_ik::ports& ports);
58+
virtual void step(hls_ik::ports& ports, hls_ik::tc_ikernel_data_counts& tc);
5559
virtual int reg_write(int address, int value, hls_ik::ikernel_id_t ikernel_id);
5660
virtual int reg_read(int address, int* value, hls_ik::ikernel_id_t ikernel_id);
5761

ikernels/hls/echo-impl.hpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ class echo : public hls_ik::ikernel, public hls_ik::virt_gateway_impl<echo> {
3636
public:
3737
echo();
3838

39-
virtual void step(hls_ik::ports& p);
39+
virtual void step(hls_ik::ports& p, hls_ik::tc_ikernel_data_counts& tc);
4040

4141
virtual int reg_write(int address, int value, hls_ik::ikernel_id_t ikernel_id);
4242
virtual int reg_read(int address, int* value, hls_ik::ikernel_id_t ikernel_id);
4343

4444
private:
45-
void echo_pipeline(hls_ik::ports& p);
45+
void echo_pipeline(hls_ik::ports& p, hls_ik::tc_ikernel_data_counts& tc);
4646

4747
enum { METADATA, DATA } state;
4848
/* First data word */
@@ -52,8 +52,7 @@ class echo : public hls_ik::ikernel, public hls_ik::virt_gateway_impl<echo> {
5252
/* Metadata of the current packet */
5353
hls_ik::metadata metadata;
5454

55-
bool dummy, dummy_cache;
56-
hls::stream<bool> dummy_update;
55+
hls::stream<bool> port_dummy_update;
5756

5857
/* By default, respond to all packets. When true, respond to sockperf
5958
* packets with "pong" requests. */

0 commit comments

Comments
 (0)