-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
180 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Default options. | ||
CXX := g++ | ||
CXX_WARNING_OPTIONS := -Wall -Wextra | ||
CXXFLAGS := -std=c++11 -O3 $(CXX_WARNING_OPTIONS) | ||
LDLIBS := -pthread -lprotobuf -lcapnp -lkj -lboost_serialization -lpthread | ||
SRC_DIR := src | ||
BUILD_DIR := build | ||
TEST_EXE := benchmark.out | ||
|
||
# Libraries. | ||
BOOST_DIR := $(TOOLS_DIR)/boost | ||
PROTOBUF_DIR := $(TOOLS_DIR)/protobuf | ||
CAPNPROTO_DIR := $(TOOLS_DIR)/capnproto | ||
CXXFLAGS := $(CXXFLAGS) -isystem $(BOOST_DIR)/include \ | ||
-isystem $(PROTOBUF_DIR)/include -isystem $(CAPNPROTO_DIR)/include | ||
LDLIBS := -L $(BOOST_DIR)/lib -L $(PROTOBUF_DIR)/lib -L $(CAPNPROTO_DIR)/lib $(LDLIBS) | ||
|
||
# Load Makefile.config if exists. | ||
LOCAL_MAKEFILE := local.mk | ||
ifneq ($(wildcard $(LOCAL_MAKEFILE)),) | ||
include $(LOCAL_MAKEFILE) | ||
endif | ||
|
||
# Sources and intermediate objects. | ||
BENCHMARK_DIR := $(SRC_DIR)/benchmark | ||
PROTOBUF_SRC := $(BENCHMARK_DIR)/protobuf_benchmark.proto | ||
PROTOBUF_COMPILED := $(BENCHMARK_DIR)/protobuf_benchmark.pb.h $(BENCHMARK_DIR)/protobuf_benchmark.pb.cc | ||
CAPNPROTO_SRC := $(BENCHMARK_DIR)/capnproto_benchmark.capnp | ||
CAPNPROTO_COMPILED_H := $(BENCHMARK_DIR)/capnproto_benchmark.capnp.h | ||
CAPNPROTO_COMPILED_CC := $(BENCHMARK_DIR)/capnproto_benchmark.capnp.cc | ||
CAPNPROTO_COMPILED_CXX := $(BENCHMARK_DIR)/capnproto_benchmark.capnp.c++ | ||
SRCS := $(shell find $(SRC_DIR) ! -name "*_test.cc" -name "*.cc") | ||
TESTS := $(shell find $(SRC_DIR)/benchmark -name "*_test.cc") | ||
HEADERS := $(shell find $(SRC_DIR) -name "*.h") | ||
OBJS := $(SRCS:$(SRC_DIR)/%.cc=$(BUILD_DIR)/%.o) | ||
TEST_OBJS := $(TESTS:$(SRC_DIR)/%.cc=$(BUILD_DIR)/%.o) | ||
|
||
# Test related. | ||
GTEST_DIR := gtest/googletest | ||
GMOCK_DIR := gtest/googlemock | ||
GTEST_ALL_SRC := ${GTEST_DIR}/src/gtest-all.cc | ||
GMOCK_ALL_SRC := ${GMOCK_DIR}/src/gmock-all.cc | ||
TEST_MAIN_SRC := ${GMOCK_DIR}/src/gmock_main.cc | ||
TEST_MAIN_OBJ := $(BUILD_DIR)/gtest_main.o | ||
TEST_CXXFLAGS := $(CXXFLAGS) -isystem $(GTEST_DIR)/include -isystem $(GMOCK_DIR)/include -pthread | ||
TEST_LIB := $(BUILD_DIR)/libgtest.a | ||
|
||
.PHONY: all benchmark test_build | ||
|
||
.SUFFIXES: | ||
|
||
all: | ||
$(MAKE) -f benchmark.mk benchmark | ||
|
||
benchmark: test_build | ||
./$(TEST_EXE) | ||
|
||
test_build: $(PROTOBUF_COMPILED) $(CAPNPROTO_COMPILED_H) $(CAPNPROTO_COMPILED_CC) | ||
$(MAKE) -f benchmark.mk $(TEST_EXE) | ||
|
||
$(TEST_EXE): $(TEST_OBJS) $(OBJS) $(TEST_LIB) | ||
$(CXX) $(TEST_CXXFLAGS) $(TEST_OBJS) $(OBJS) $(TEST_MAIN_SRC) $(TEST_LIB) -o $(TEST_EXE) $(LDLIBS) | ||
|
||
$(OBJS): $(BUILD_DIR)/%.o: $(SRC_DIR)/%.cc $(HEADERS) | ||
mkdir -p $(@D) && $(CXX) $(CXXFLAGS) -c $< -o $@ | ||
|
||
$(BUILD_DIR)/gtest-all.o: $(GTEST_ALL_SRC) | ||
mkdir -p $(@D) && $(CXX) $(TEST_CXXFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) -c $(GTEST_ALL_SRC) -o $@ | ||
|
||
$(BUILD_DIR)/gmock-all.o: $(GMOCK_ALL_SRC) | ||
mkdir -p $(@D) && $(CXX) $(TEST_CXXFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) -c $(GMOCK_ALL_SRC) -o $@ | ||
|
||
$(TEST_LIB): $(BUILD_DIR)/gtest-all.o $(BUILD_DIR)/gmock-all.o | ||
$(AR) $(ARFLAGS) $@ $(BUILD_DIR)/gtest-all.o $(BUILD_DIR)/gmock-all.o | ||
|
||
$(TEST_OBJS): $(BUILD_DIR)/%.o: $(SRC_DIR)/%.cc $(HEADERS) | ||
mkdir -p $(@D) && $(CXX) $(TEST_CXXFLAGS) -c $< -o $@ | ||
|
||
%.pb.h %.pb.cc: %.proto | ||
protoc -I=$(@D) --cpp_out=$(@D) $< | ||
|
||
%.capnp.c++ %.capnp.h: %.capnp | ||
capnp compile -oc++ $< | ||
|
||
%.capnp.cc: %.capnp.c++ | ||
cp $< $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
#ifndef HPS_BASIC_TYPE_H_ | ||
#define HPS_BASIC_TYPE_H_ | ||
#pragma once | ||
|
||
#include "float_serializer.h" | ||
#include "int_serializer.h" | ||
#include "string_serializer.h" | ||
#include "uint_serializer.h" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
#ifndef HPS_BUFFER_H_ | ||
#define HPS_BUFFER_H_ | ||
#pragma once | ||
|
||
#include "char_array_input_buffer.h" | ||
#include "stream_input_buffer.h" | ||
#include "stream_output_buffer.h" | ||
#include "string_input_buffer.h" | ||
#include "string_output_buffer.h" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include <cstring> | ||
#include "input_buffer.h" | ||
|
||
namespace hps { | ||
|
||
template <> | ||
class InputBuffer<char*> { | ||
public: | ||
InputBuffer(const char* arr) : arr(arr) { pos = 0; } | ||
|
||
void read(char* content, size_t length) { | ||
strncpy(content, &arr[pos], length); | ||
pos += length; | ||
} | ||
|
||
char read_char() { | ||
const char ch = arr[pos]; | ||
pos++; | ||
return ch; | ||
} | ||
|
||
private: | ||
const char* const arr; | ||
|
||
size_t pos; | ||
}; | ||
|
||
} // namespace hps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
#ifndef HPS_STREAM_H_ | ||
#define HPS_STREAM_H_ | ||
#pragma once | ||
|
||
namespace hps { | ||
|
||
class Stream {}; | ||
|
||
} // namespace hps | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
#ifndef HPS_BIT_FILTERS_H_ | ||
#define HPS_BIT_FILTERS_H_ | ||
#pragma once | ||
|
||
namespace hps { | ||
|
||
constexpr char BIT_FILTERS[] = {1, 2, 4, 8, 16, 32, 64, static_cast<char>(128)}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.