Skip to content

Commit 8f251cb

Browse files
committed
Initial commit
0 parents  commit 8f251cb

File tree

93 files changed

+37434
-0
lines changed

Some content is hidden

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

93 files changed

+37434
-0
lines changed

.clang-format

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
BasedOnStyle: Google
3+
IndentWidth: 2
4+
---
5+
Language: Cpp
6+
AccessModifierOffset: -2
7+
AlignTrailingComments: false
8+
AllowAllParametersOfDeclarationOnNextLine: false
9+
AllowShortIfStatementsOnASingleLine: false
10+
AllowShortLoopsOnASingleLine: false
11+
AlwaysBreakBeforeMultilineStrings: false
12+
BinPackArguments: false
13+
BinPackParameters: false
14+
ContinuationIndentWidth: 2
15+
DerivePointerAlignment: false
16+
IndentCaseLabels: false
17+
TabWidth: 2

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.gch
2+
*.o
3+
*.out
4+
*.cmake
5+
!IBVerbsConfig.cmake
6+
build/
7+
data/
8+
cmake-build-debug/
9+
cmake-build-release/
10+
.DS_Store
11+
.cache
12+
.idea

CMakeCompilerConfig.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set(CMAKE_CXX_COMPILER clang++)
2+
set(CMAKE_CXX_STANDARD 17)
3+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4+
add_compile_options(-Wall -Wextra -Wpedantic -Wfatal-errors)
5+
6+
# add_compile_options(-DVERIFY) # checks whether the insert queries did not mess up the index
7+
# add_compile_options(-DNOHUGEPAGES) # disables hugepages
8+
# add_compile_options(-DDEV_DEBUG) # outputs additional debugging information
9+
10+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g -O0")
11+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
12+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
if (APPLE)
3+
project(rdma_inverted_index)
4+
include("CMakeCompilerConfig.txt")
5+
else ()
6+
include("CMakeCompilerConfig.txt")
7+
project(rdma_inverted_index)
8+
endif ()
9+
10+
# set module path
11+
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
12+
include_directories(src)
13+
add_subdirectory(rdma-library)
14+
add_subdirectory(src/data_processing)
15+
16+
# executables
17+
add_executable(term_index src/index/term_based/main.cc src/timing/timing.cc)
18+
target_link_libraries(term_index rdma_library)
19+
20+
add_executable(document_index src/index/document_based/main.cc src/timing/timing.cc)
21+
target_link_libraries(document_index rdma_library)
22+
23+
add_executable(block_index src/index/block_based/main.cc src/timing/timing.cc)
24+
target_link_libraries(block_index rdma_library)
25+
26+
add_executable(dynamic_block_index src/index/block_based_dynamic/main.cc src/timing/timing.cc)
27+
target_link_libraries(dynamic_block_index rdma_library)

README.md

Lines changed: 320 additions & 0 deletions
Large diffs are not rendered by default.

rdma-library/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
3+
set(IBVerbs_DIR .)
4+
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
5+
6+
# required packages
7+
find_package(IBVerbs REQUIRED)
8+
find_package(Boost COMPONENTS program_options REQUIRED)
9+
find_package(Threads REQUIRED)
10+
find_package(TBB REQUIRED)
11+
12+
# our library
13+
file(GLOB_RECURSE LIBRARY_CC library/**.cc)
14+
add_library(rdma_library STATIC ${LIBRARY_CC})
15+
target_include_directories(rdma_library PUBLIC .)
16+
target_link_libraries(rdma_library ${IBVERBS_LIBRARY} ${Boost_LIBRARIES} TBB::tbb Threads::Threads)

rdma-library/IBVerbsConfig.cmake

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FIND_PATH(IBVERBS_INCLUDE_DIR infiniband/verbs.h
2+
PATHS
3+
$ENV{IBVERBS_HOME}
4+
NO_DEFAULT_PATH
5+
PATH_SUFFIXES include
6+
)
7+
8+
FIND_PATH(IBVERBS_INCLUDE_DIR infiniband/verbs.h
9+
PATHS
10+
/usr/local/include
11+
/usr/include
12+
/sw/include # Fink
13+
/opt/local/include # DarwinPorts
14+
/opt/csw/include # Blastwave
15+
/opt/include
16+
)
17+
18+
FIND_LIBRARY(IBVERBS_LIBRARY
19+
NAMES ibverbs
20+
PATHS $ENV{IBVERBS_HOME}
21+
NO_DEFAULT_PATH
22+
PATH_SUFFIXES lib64 lib
23+
)
24+
25+
FIND_LIBRARY(IBVERBS_LIBRARY
26+
NAMES ibverbs
27+
PATHS
28+
/usr/local
29+
/usr
30+
/sw
31+
/opt/local
32+
/opt/csw
33+
/opt
34+
/usr/freeware
35+
PATH_SUFFIXES lib64 lib
36+
)
37+
SET(IBVERBS_FOUND FALSE)
38+
IF (IBVERBS_LIBRARY AND IBVERBS_INCLUDE_DIR)
39+
SET(IBVERBS_FOUND TRUE)
40+
ENDIF (IBVERBS_LIBRARY AND IBVERBS_INCLUDE_DIR)
41+
42+
include(FindPackageHandleStandardArgs)
43+
find_package_handle_standard_args(IBVerbs DEFAULT_MSG IBVERBS_LIBRARY IBVERBS_INCLUDE_DIR)
44+
45+
mark_as_advanced(IBVERBS_INCLUDE_DIR IBVERBS_LIBRARIES)

rdma-library/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RDMA Library
2+
3+
"High-level" library to connect machines, connect queue pairs, register memory regions, post RDMA verbs, etc.
4+
The goal of this library is to conveniently wrap
5+
the [ibverbs library](https://github.com/linux-rdma/rdma-core/tree/master/libibverbs).
6+
7+
[TODO: public library interface and namespaces...]
8+
9+
## Required C++ Libraries
10+
11+
* ibverbs
12+
* Boost (for CLI parsing)
13+
* pthreads (for multithreading)
14+
* oneTBB (for concurrent data structures)

rdma-library/library/batched_read.hh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#ifndef RDMA_LIBRARY_BATCHED_READ_HH
2+
#define RDMA_LIBRARY_BATCHED_READ_HH
3+
4+
#include "queue_pair.hh"
5+
#include "utils.hh"
6+
7+
struct BatchedREAD {
8+
const u32 max_size;
9+
u32 requests{0};
10+
u64 total_size{0};
11+
12+
vec<ibv_send_wr> work_requests;
13+
vec<ibv_sge> scatter_gather_entries;
14+
ibv_send_wr* bad_work_request{nullptr};
15+
16+
explicit BatchedREAD(size_t max_batch_size)
17+
: max_size(max_batch_size),
18+
work_requests(max_batch_size),
19+
scatter_gather_entries(max_batch_size) {}
20+
21+
void add_to_batch(u64 local_address,
22+
u64 remote_address,
23+
u32 length,
24+
u32 lkey,
25+
u32 rkey,
26+
u64 wr_id,
27+
bool signaled = true) {
28+
lib_assert(length > 0, "Cannot READ 0 bytes");
29+
lib_assert(requests < max_size, "Batch exceeds maximum batch size");
30+
31+
auto& sge = scatter_gather_entries[requests];
32+
auto& wr = work_requests[requests];
33+
34+
sge.addr = local_address;
35+
sge.length = length;
36+
sge.lkey = lkey;
37+
38+
wr.opcode = IBV_WR_RDMA_READ;
39+
wr.send_flags = signaled ? IBV_SEND_SIGNALED : 0;
40+
wr.wr_id = wr_id;
41+
wr.sg_list = &sge;
42+
wr.num_sge = 1;
43+
44+
wr.next = nullptr;
45+
if (requests > 0) {
46+
work_requests[requests - 1].next = &wr;
47+
}
48+
49+
wr.wr.rdma.remote_addr = remote_address;
50+
wr.wr.rdma.rkey = rkey;
51+
52+
++requests;
53+
total_size += length;
54+
}
55+
56+
void post_batch(QP& qp) {
57+
lib_assert(requests > 0, "Empty READ batch");
58+
59+
// send final WR signaled in any case
60+
work_requests[requests - 1].send_flags = IBV_SEND_SIGNALED;
61+
62+
lib_assert(
63+
ibv_post_send(
64+
qp->get_ibv_qp(), work_requests.data(), &bad_work_request) == 0,
65+
"Cannot post send request");
66+
67+
// reset batch
68+
requests = 0;
69+
total_size = 0;
70+
}
71+
};
72+
73+
#endif // RDMA_LIBRARY_BATCHED_READ_HH

rdma-library/library/configuration.cc

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#include "configuration.hh"
2+
3+
#include <boost/program_options.hpp>
4+
#include <iomanip>
5+
#include <iostream>
6+
7+
namespace configuration {
8+
9+
Configuration::Configuration() { create_rdma_options(); }
10+
11+
Configuration::Configuration(int argc, char** argv) : Configuration() {
12+
process_program_options(argc, argv);
13+
operator<<(std::cerr, *this);
14+
}
15+
16+
void Configuration::create_rdma_options() {
17+
desc.add_options()("help,h", "Show help message")(
18+
"is-server,s",
19+
po::bool_switch(&is_server)->default_value(is_server),
20+
"Program acts as server if set")(
21+
"servers",
22+
po::value<vec<str>>(&server_nodes)->multitoken(),
23+
"A list of server nodes to which a client connects, e.g., \"cluster3\"")(
24+
"clients",
25+
po::value<vec<str>>(&client_nodes)->multitoken(),
26+
"A list of client nodes to which the initiator connects, e.g., "
27+
"\"cluster4 cluster5\"")(
28+
"initiator,i",
29+
po::bool_switch(&is_initiator)->default_value(is_initiator),
30+
"Program acts as initiating client if set")(
31+
"num-clients,c",
32+
po::value<u32>(&num_clients)->default_value(num_clients),
33+
"Number of clients that connect to each server (relevant only for "
34+
"server nodes)");
35+
36+
// configuration options
37+
desc.add_options()(
38+
"port", po::value<u32>(&port)->default_value(port), "TCP port")(
39+
"ib-port",
40+
po::value<u32>(&device_port)->default_value(device_port),
41+
"Port of infiniband device")(
42+
"max-poll-cqes",
43+
po::value<i32>(&max_poll_cqes)->default_value(max_poll_cqes),
44+
"Number of outstanding RDMA operations allowed (hardware-specific)")(
45+
"max-send-wrs",
46+
po::value<i32>(&max_send_queue_wr)->default_value(max_send_queue_wr),
47+
"Maximum number of outstanding send work requests")(
48+
"max-receive-wrs",
49+
po::value<i32>(&max_recv_queue_wr)->default_value(max_recv_queue_wr),
50+
"Maximum number of outstanding receive work requests");
51+
}
52+
53+
void Configuration::exit_with_help_message(char** argv) {
54+
std::cerr << "Try " << argv[0] << " --help" << std::endl;
55+
std::exit(EXIT_FAILURE);
56+
}
57+
58+
void Configuration::process_program_options(int argc, char** argv) {
59+
try {
60+
po::variables_map vm;
61+
po::store(po::parse_command_line(argc, argv, desc), vm);
62+
63+
if (vm.count("help")) {
64+
std::cerr << desc << std::endl;
65+
std::exit(EXIT_FAILURE);
66+
}
67+
68+
po::notify(vm);
69+
70+
if (!is_server && server_nodes.empty()) {
71+
std::cerr << "[ERROR]: --servers <arg-list> must be given if "
72+
"--server is not set"
73+
<< std::endl;
74+
exit_with_help_message(argv);
75+
}
76+
77+
if (is_server && is_initiator) {
78+
std::cerr << "[ERROR]: a server cannot be the initiator" << std::endl;
79+
exit_with_help_message(argv);
80+
}
81+
82+
if (!is_initiator && !client_nodes.empty()) {
83+
std::cerr << "[ERROR]: --clients <arg-list> is only required by the "
84+
"initiating client"
85+
<< std::endl;
86+
exit_with_help_message(argv);
87+
}
88+
89+
} catch (const std::exception& e) {
90+
std::cerr << "[ERROR]: " << e.what() << std::endl;
91+
exit_with_help_message(argv);
92+
}
93+
}
94+
95+
std::ostream& operator<<(std::ostream& os, const Configuration& config) {
96+
const int32_t width = 30;
97+
const int32_t max_width = width * 2;
98+
const char filler = '=';
99+
100+
os << std::setfill(filler) << std::setw(max_width) << "" << std::endl
101+
<< std::setfill(' ') << std::setw(width)
102+
<< (config.is_server ? "SERVER" : "CLIENT") << std::endl
103+
<< std::setfill(filler) << std::setw(max_width) << "" << std::endl;
104+
105+
os << std::left << std::setfill(' ');
106+
if (!config.is_server) {
107+
os << std::setw(width) << "connect to: "
108+
<< "[";
109+
for (const str& node : config.server_nodes) {
110+
os << node << ", ";
111+
}
112+
os << "\b\b]" << std::endl;
113+
os << std::boolalpha << std::setw(width)
114+
<< "is initiator: " << config.is_initiator << std::endl;
115+
if (config.is_initiator) {
116+
if (!config.client_nodes.empty()) {
117+
os << std::setw(width) << "client nodes: "
118+
<< "[";
119+
for (const str& node : config.client_nodes) {
120+
os << node << ", ";
121+
}
122+
os << "\b\b]" << std::endl;
123+
}
124+
}
125+
} else {
126+
os << std::setw(width) << "num clients: " << config.num_clients
127+
<< std::endl;
128+
}
129+
os << std::setw(width) << "TCP port: " << config.port << std::endl
130+
<< std::setw(width) << "IB port: " << config.device_port << std::endl
131+
<< std::setw(width) << "max outstanding CQEs: " << config.max_poll_cqes
132+
<< std::endl
133+
<< std::setw(width)
134+
<< "max send work requests: " << config.max_send_queue_wr << std::endl
135+
<< std::setw(width)
136+
<< "max receive work requests: " << config.max_recv_queue_wr << std::endl;
137+
138+
os << std::setfill(filler) << std::setw(max_width) << "" << std::endl;
139+
140+
return os;
141+
}
142+
143+
} // namespace configuration

0 commit comments

Comments
 (0)