Commit 32df83b9 authored by Philipp Götze's avatar Philipp Götze

Adapted the way of configuration using a config file and options

parent 541eb94f
......@@ -6,42 +6,38 @@ set(CMAKE_MACOSX_RPATH 1)
set (PTable_VERSION_MAJOR 0)
set (PTable_VERSION_MINOR 1)
#############################
# customization section
#############################
################################################################################
# customization section #
################################################################################
# Installation path
if(!PTABLE_DIR)
set(PTABLE_DIR "/usr/local/ptable")
endif()
# Set to 1 if you need log output
add_definitions(-DDO_LOG=0)
# Set the mount path of your pmem device where the should be stored
set(PMEM_MNT_PATH "/mnt/pmem/test")
# Build test cases for ptable functionality checks
# If switched to off, no test will be build
option(BUILD_TEST_CASES
"build tests for PTABLE functionality"
ON
)
option(ENABLE_LOG "enables log output for e.g. debugging" OFF)
option(BUILD_TEST_CASES "build tests for PTable functionality" ON )
option(BUILD_GOOGLE_BENCH "build google benchmark" OFF)
option(BUILD_BENCHMARKS "build benchmarks for Ptable" OFF)
#Build google benchmark library
option(BUILD_GOOGLE_BENCH
"build google benchmark"
OFF
)
# Build benchmark test
option(BUILD_BENCHMARKS
"build benchmarks for PTABLE"
OFF
)
################################################################################
# End of customization section #
################################################################################
# Benchmark test requires benchmark library
if (BUILD_BENCHMARKS)
set(BUILD_GOOGLE_BENCH ON)
endif()
if(ENABLE_LOG)
set(PLOG 1)
else()
set(PLOG 0)
endif()
# C++ compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-deprecated -g -O2 -Wsign-compare")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
......@@ -54,9 +50,6 @@ endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unused -Wno-uninitialized")
# End of customization section
#---------------------------------------------------------------------------
# Add our CMake directory to CMake's module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/")
......@@ -102,7 +95,10 @@ include_directories("${THIRD_PARTY_DIR}/variant/include")
# Building PTable library
#
include_directories("${PROJECT_SOURCE_DIR}")
configure_file(config.h.in ${CMAKE_BINARY_DIR}/generated/config.h)
include_directories(${PROJECT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/generated/
)
# because we have downloaded external projects into build we have to add them here
include_directories("${THIRD_PARTY_DIR}")
......
......@@ -44,7 +44,7 @@ struct root {
persistent_ptr<PTableType> pTable;
};
const std::string path = "/mnt/pmem/test/benchdb.db";
const std::string path = ptable::gPmemPath + "benchdb.db";
const auto NUM_TUPLES = 100 * 1000;
const auto POOL_SIZE = 1024 * 1024 * 256;
......
......@@ -28,7 +28,7 @@ static void BM_PointQuery(benchmark::State& state) {
pool<root> pop;
const std::string path = "/mnt/pmem/test/benchdb" + std::to_string(state.range(0)) + ".db";
const std::string path = ptable::gPmemPath + "benchdb" + std::to_string(state.range(0)) + ".db";
std::remove(path.c_str());
......
#ifndef PTABLE_CONFIG_H
#define PTABLE_CONFIG_H
#define PLOG(msg) if(@PLOG@) std::cout << "[PTable] " << msg << '\n';
namespace ptable {
const std::string gPmemPath("@PMEM_MNT_PATH@/");
}
#endif /* PTABLE_CONFIG_H */
......@@ -23,11 +23,10 @@
#include <array>
#include <unordered_map>
#include "config.h"
#include <libpmemobj++/make_persistent.hpp>
#include <libpmemobj++/persistent_ptr.hpp>
#define PLOG(msg) if(DO_LOG) std::cout << "[PTable] " << msg << '\n';
namespace ptable {
using nvml::obj::persistent_ptr;
......@@ -35,18 +34,18 @@ using nvml::obj::make_persistent;
using nvml::obj::delete_persistent;
/** Positions in NVM_Block */
const int gBDCCRangePos1 = 0;
const int gBDCCRangePos2 = 4;
const int gCountPos = 8;
const int gFreeSpacePos = 12;
const int gSmaOffsetPos = 14;
const int gDataOffsetPos = 16;
constexpr int gBDCCRangePos1 = 0;
constexpr int gBDCCRangePos2 = 4;
constexpr int gCountPos = 8;
constexpr int gFreeSpacePos = 12;
constexpr int gSmaOffsetPos = 14;
constexpr int gDataOffsetPos = 16;
/** Sizes/Lengths in NVM_Block */
const int gFixedHeaderSize = 14;
const int gBDCCValueSize = 4;
const int gAttrOffsetSize = 4;
const int gOffsetSize = 2;
constexpr int gFixedHeaderSize = 14;
constexpr int gBDCCValueSize = 4;
constexpr int gAttrOffsetSize = 4;
constexpr int gOffsetSize = 2;
/** The size of a single block in persistent memory */
static constexpr std::size_t gBlockSize = 1 << 12; // 12->4KB, 15->32KB, max 16 due to data types
......
......@@ -42,7 +42,7 @@ TEST_CASE("Testing storing tuples in PTable", "[PTable]") {
pool<root> pop;
const std::string path = "/mnt/pmem/test/testdb.db";
const std::string path = gPmemPath + "testdb.db";
if (access(path.c_str(), F_OK) != 0) {
pop = pool<root>::create(path, LAYOUT, 16 * 1024 * 1024);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment