From 3b5e293c088b359fbb86807c153fb60976d9c23c Mon Sep 17 00:00:00 2001 From: Takayuki Tanabe Date: Tue, 4 Aug 2020 01:45:58 +0900 Subject: [PATCH] adapt mocc's cmake. --- common/Makefile | 4 --- ermia/README.md | 2 +- mocc/CMakeLists.txt | 87 +++++++++++++++++++++++++++++++++++++++++++++ mocc/Makefile | 48 ------------------------- mocc/README.md | 41 ++++++++++++++++----- 5 files changed, 121 insertions(+), 61 deletions(-) create mode 100644 mocc/CMakeLists.txt delete mode 100644 mocc/Makefile diff --git a/common/Makefile b/common/Makefile index d92373d4..551feb3c 100644 --- a/common/Makefile +++ b/common/Makefile @@ -1,8 +1,4 @@ -ERMIA_SRCS1+=\ -$(REL)result.cc\ -$(REL)util.cc\ - MOCC_SRCS1+=\ $(REL)result.cc\ $(REL)util.cc\ diff --git a/ermia/README.md b/ermia/README.md index c0b1c868..82b21606 100644 --- a/ermia/README.md +++ b/ermia/README.md @@ -32,7 +32,7 @@ $ ./ermia.exe -help $ numactl --interleave=all ./ermia.exe -tuple_num=1000 -max_ope=10 -thread_num=224 -rratio=100 -rmw=0 -zipf_skew=0 -ycsb=1 -clocks_per_us=2100 -gc_inter_us=10 -pre_reserve_version=10000 -pre_reserve_tmt_element=100 -extime=3 ``` -## How to select build options in Makefile +## How to customize options in CMakeLists.txt - `ADD_ANALYSIS` : If this is 1, it is deeper analysis than setting 0.
default : `0` - `BACK_OFF` : If this is 1, it use Cicada's backoff.
diff --git a/mocc/CMakeLists.txt b/mocc/CMakeLists.txt new file mode 100644 index 00000000..58cd309e --- /dev/null +++ b/mocc/CMakeLists.txt @@ -0,0 +1,87 @@ +cmake_minimum_required(VERSION 3.10) + +project(ccbench_mocc + VERSION 0.0.1 + DESCRIPTION "mocc of ccbench" + LANGUAGES CXX) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake") + +option(ENABLE_SANITIZER "enable sanitizer on debug build" ON) +option(ENABLE_UB_SANITIZER "enable undefined behavior sanitizer on debug build" OFF) +option(ENABLE_COVERAGE "enable coverage on debug build" OFF) + +find_package(Doxygen) +find_package(Threads REQUIRED) +find_package(gflags REQUIRED) +find_package(glog REQUIRED) +find_package(Boost + COMPONENTS filesystem) + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) +include(CompileOptions) + +file(GLOB ERMIA_SOURCES + "../common/result.cc" + "../common/util.cc" + "lock.cc" + "mocc.cc" + "result.cc" + "transaction.cc" + "util.cc" + ) + +add_executable(mocc.exe ${ERMIA_SOURCES}) + +target_link_libraries(mocc.exe + Boost::filesystem + gflags::gflags + ${PROJECT_SOURCE_DIR}/../third_party/mimalloc/out/release/libmimalloc.a + ${PROJECT_SOURCE_DIR}/../third_party/masstree/libkohler_masstree_json.a + Threads::Threads + ) + +if (DEFINED ADD_ANALYSIS) + add_definitions(-DADD_ANALYSIS=${ADD_ANALYSIS}) +else () + add_definitions(-DADD_ANALYSIS=0) +endif () + +if (DEFINED BACK_OFF) + add_definitions(-DBACK_OFF=${BACK_OFF}) +else () + add_definitions(-DBACK_OFF=0) +endif () + +if (DEFINED KEY_SIZE) + add_definitions(-DKEY_SIZE=${KEY_SIZE}) +else () + add_definitions(-DKEY_SIZE=8) +endif () + +if (DEFINED KEY_SORT) + add_definitions(-DKEY_SORT=${KEY_SORT}) +else () + add_definitions(-DKEY_SORT=0) +endif () + +if (DEFINED MASSTREE_USE) + add_definitions(-DMASSTREE_USE=${MASSTREE_USE}) +else () + add_definitions(-DMASSTREE_USE=1) +endif () + +add_definitions(-DRWLOCK) + +if (DEFINED TEMPERATURE_RESET_OPT) + add_definitions(-DTEMPERATURE_RESET_OPT=${TEMPERATURE_RESET_OPT}) +else () + add_definitions(-DTEMPERATURE_RESET_OPT=1) +endif () + +if (DEFINED VAL_SIZE) + add_definitions(-DVAL_SIZE=${VAL_SIZE}) +else () + add_definitions(-DVAL_SIZE=4) +endif () diff --git a/mocc/Makefile b/mocc/Makefile deleted file mode 100644 index 8bca1a95..00000000 --- a/mocc/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -PROG1 = mocc.exe -MOCC_SRCS1 := mocc.cc transaction.cc lock.cc util.cc result.cc - -REL := ../common/ -include $(REL)Makefile -MOCC_ALLSRC = $(MOCC_SRCS1) $(wildcard include/*.hh) - -KEY_SIZE=8 -VAL_SIZE=4 -ADD_ANALYSIS=1 -BACK_OFF=1 -KEY_SORT=0 -MASSTREE_USE=1 -TEMPERATURE_RESET_OPT=1 - -CC = g++ -CFLAGS = -c -pipe -g -O3 -std=c++17 -march=native \ - -Wall -Wextra -Wdangling-else -Wchkp -Winvalid-memory-model \ - -D$(shell uname) \ - -D$(shell hostname) \ - -DRWLOCK \ - -DKEY_SIZE=$(KEY_SIZE) \ - -DVAL_SIZE=$(VAL_SIZE) \ - -DADD_ANALYSIS=$(ADD_ANALYSIS) \ - -DBACK_OFF=$(BACK_OFF) \ - -DKEY_SORT=$(KEY_SORT) \ - -DMASSTREE_USE=$(MASSTREE_USE) \ - -DTEMPERATURE_RESET_OPT=$(TEMPERATURE_RESET_OPT) \ - -LD_PATH = -L../third_party/masstree/ -LIBS = -lpthread -lgflags -lglog ../third_party/masstree/libkohler_masstree_json.a - -OBJS1 = $(MOCC_SRCS1:.cc=.o) - -all : $(PROG1) - -$(PROG1) : $(OBJS1) - $(CC) -o $@ $^ $(LIBS) - -.cc.o: - $(CC) $(CFLAGS) -c $< -o $@ - -format: - clang-format -i -verbose -style=Google $(MOCC_ALLSRC) - -clean: - rm -f *~ *.o *.exe *.stackdump *.log - rm -f ../common/*~ ../common/*.o ../common/*.exe ../common/*.stackdump diff --git a/mocc/README.md b/mocc/README.md index 58b7b52f..da396ac8 100644 --- a/mocc/README.md +++ b/mocc/README.md @@ -7,10 +7,19 @@ It was proposed at VLDB'2017 by Tianzheng Wang. $ cd ../ $ ./bootstrap.sh ``` -This makes ../third_party/masstree/libkohler_masstree_json.a used below building. +This makes ../third_party/masstree/libkohler_masstree_json.a used by building cicada. +- Build mimalloc +``` +$ cd ../ +$ ./bootstrap_mimalloc.sh +``` +This makes ../third_party/mimalloc/out/release/libmimalloc.a used by building cicada. - Build ``` -$ make +$ mkdir build +$ cd build +$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .. +$ ninja ``` - Confirm usage ``` @@ -21,13 +30,29 @@ $ ./mocc.exe -help $ numactl --interleave=all ./mocc.exe -clocks_per_us=2100 -epoch_time=40 -extime=3 -max_ope=10 -rmw=0 -rratio=100 -thread_num=224 -tuple_num=1000000 -ycsb=1 -zipf_skew=0 -per_xx_temp=4096 ``` -## How to select build options in Makefile -- `ADD_ANALYSIS` : If this is 1, it is deeper analysis than setting 0. -- `BACK_OFF` : If this is 1, it use Cicada's backoff. -- `KEY_SORT` : If this is 1, its transaction accesses records in ascending key order. +## How to customize options in CMakeLists.txt +- `ADD_ANALYSIS` : If this is 1, it is deeper analysis than setting 0.
+default : `0` +- `BACK_OFF` : If this is 1, it use Cicada's backoff.
+default : `0` +- `KEY_SORT` : If this is 1, its transaction accesses records in ascending key order.
+default : `0` - `MASSTREE_USE` : If this is 1, it use masstree as data structure. If not, it use simple array αs data structure. -- `TEMPERATURE_RESET_OPT` : If this is 1, it uses new temprature control protocol which reduces contentions and improves throughput much. -- `VAL_SIZE` : Value of key-value size. In other words, payload size. +default : `1` +- `TEMPERATURE_RESET_OPT` : If this is 1, it uses new temprature control protocol which reduces contentions and improves throughput much.
+default : `1` +- `VAL_SIZE` : Value of key-value size. In other words, payload size.
+default : `4` + +## Custom build examples +``` +$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DKEY_SIZE=1000 -DVAL_SIZE=1000 .. +``` +- Note: If you re-run cmake, don't forget to remove cmake cache. +``` +$ rm CMakeCache.txt +``` +The cmake cache definition data is used in preference to the command line definition data. ## Optimizations - Backoff.