Commit db05fb0a authored by Rob Latham's avatar Rob Latham

clean up configure to select from multiple bakcends

also lets us use strange/specific CXXFLAGS only when needed
parent f502c2ce
......@@ -4,7 +4,6 @@ bin_PROGRAMS = test/bench-client \
test/test-client \
test/test-server
test_bench_client_SOURCES = test/bench-client.cc
test_bench_client_CXXFLAGS = -pthread -std=c++11 -g -Wall -mcx16 -Wno-invalid-offsetof
test_bench_client_CPPFLAGS = ${CPPFLAGS} -I${srcdir}/src
test_bench_client_DEPENDENCIES = lib/libkvclient.la
test_bench_client_LDFLAGS = -Llib -lkvclient
......@@ -18,7 +17,6 @@ lib_LTLIBRARIES = lib/libkvclient.la \
lib_libkvclient_la_SOURCES = src/kv-client.c
lib_libkvgroupclient_la_SOURCES = src/kvgroup-client.cc
lib_libkvgroupclient_la_CXXFLAGS = -pthread -std=c++11 -g -Wall -mcx16 -Wno-invalid-offsetof
lib_libkvgroupclient_la_CPPFLAGS = ${CPPFLAGS}
lib_libkvserver_la_SOURCES = src/kv-server.cc \
......@@ -34,11 +32,9 @@ noinst_HEADERS = src/datastore.h \
src/BwTree/src/bloom_filter.h \
src/BwTree/src/sorted_small_set.h
lib_libkvserver_la_CXXFLAGS = -pthread -std=c++11 -g -Wall -mcx16 -Wno-invalid-offsetof
lib_libkvserver_la_CPPFLAGS = ${CPPFLAGS} -I${srcdir}/src/BwTree/src
lib_libkvgroupserver_la_SOURCES = src/kvgroup-server.cc
lib_libkvgroupserver_la_CXXFLAGS = -pthread -std=c++11 -g -Wall -mcx16 -Wno-invalid-offsetof
lib_libkvgroupserver_la_CPPFLAGS = ${CPPFLAGS}
......@@ -56,20 +52,17 @@ TESTS = test/test-client \
test/test-mpi-group
test_test_client_SOURCES = test/test-client.cc
test_test_client_CXXFLAGS = -pthread -std=c++11 -g -Wall -mcx16 -Wno-invalid-offsetof
test_test_client_CPPFLAGS = ${CPPFLAGS} -I${srcdir}/src
test_test_client_DEPENDENCIES = lib/libkvclient.la
test_test_client_LDFLAGS = -Llib -lkvclient
test_test_server_SOURCES = test/test-server.cc
test_test_server_CXXFLAGS = -pthread -std=c++11 -g -Wall -mcx16 -Wno-invalid-offsetof
test_test_server_CPPFLAGS = ${CPPFLAGS} -I${srcdir}/src
test_test_server_DEPENDENCIES = lib/libkvserver.la
test_test_server_LDFLAGS = -Llib -lkvserver -lssg -lboost_filesystem -lboost_system
test_test_mpi_SOURCES = test/test-mpi.cc
test_test_mpi_CXXFLAGS = -pthread -std=c++11 -g -Wall -mcx16 -Wno-invalid-offsetof
test_test_mpi_CPPFLAGS = ${CPPFLAGS} -I${srcdir}/src
......@@ -77,7 +70,6 @@ test_test_mpi_DEPENDENCIES = lib/libkvserver.la lib/libkvclient.la
test_test_mpi_LDFLAGS = -Llib -lkvclient -lkvserver -lssg -lboost_filesystem -lboost_system
test_test_mpi_group_SOURCES = test/test-mpi-group.cc
test_test_mpi_group_CXXFLAGS = -pthread -std=c++11 -g -Wall -mcx16 -Wno-invalid-offsetof
test_test_mpi_group_CPPFLAGS = ${CPPFLAGS} -I${srcdir}/src
test_test_mpi_group_DEPENDENCIES = lib/libkvgroupserver.la lib/libkvgroupclient.la lib/libkvserver.la lib/libkvclient.la
test_test_mpi_group_LDFLAGS = -Llib -lkvgroupserver -lkvgroupclient -lkvclient -lkvserver -lssg -lch-placement -lleveldb -ldb_cxx -lboost_filesystem -lboost_system
......
......@@ -3,14 +3,14 @@ To Build:
./prepare.sh
On Darwin, run configure like this:
With BwTree: ./configure CC=mpicc CXX=mpicxx --prefix=$HOME/mochi --enable-BWTREE
With BerkeleyDB: ./configure CC=mpicc CXX=mpicxx --prefix=$HOME/mochi --enable-BERKELEYDB
With LevelDB: ./configure CC=mpicc CXX=mpicxx --prefix=$HOME/mochi --enable-LEVELDB
With BwTree: ./configure CC=mpicc CXX=mpicxx --prefix=$HOME/mochi --enable-bwtree
With BerkeleyDB: ./configure CC=mpicc CXX=mpicxx --prefix=$HOME/mochi --enable-berkeleydb
With LevelDB: ./configure CC=mpicc CXX=mpicxx --prefix=$HOME/mochi --enable-leveldb
On Cori, run configure like this:
With BwTree: ./configure CC=cc CXX=CC LDFLAGS="-dynamic -latomic" --prefix=$HOME/mochi --enable-BWTREE
With BerkeleyDB: ./configure CC=cc CXX=CC LDFLAGS="-dynamic -latomic" --prefix=$HOME/mochi --enable-BERKELEYDB
With LevelDB: ./configure CC=cc CXX=CC LDFLAGS="-dynamic -latomic" --prefix=$HOME/mochi --enable-LEVELDB
With BwTree: ./configure CC=cc CXX=CC LDFLAGS="-dynamic -latomic" --prefix=$HOME/mochi --enable-bwtree
With BerkeleyDB: ./configure CC=cc CXX=CC LDFLAGS="-dynamic -latomic" --prefix=$HOME/mochi --enable-berkeleydb
With LevelDB: ./configure CC=cc CXX=CC LDFLAGS="-dynamic -latomic" --prefix=$HOME/mochi --enable-leveldb
make -j16
make install
......
......@@ -23,40 +23,6 @@ AC_PROG_INSTALL
# Checks for libraries.
# Checks for header files.
#pkg-config and libraries supporting that
PKG_PROG_PKG_CONFIG
if test "x$PKG_CONFIG" == "x"; then
AC_MSG_ERROR([Could not find pkg-config utility!])
fi
PKG_CHECK_MODULES([MARGO],[margo],[],
AC_MSG_ERROR([Could not find working margo installation!]) )
LIBS="$MARGO_LIBS $LIBS"
CPPFLAGS="$MARGO_CFLAGS $CPPFLAGS"
CFLAGS="$MARGO_CFLAGS $CFLAGS"
AC_ARG_ENABLE([BWTREE], [],
[CPPFLAGS="-DBWTREE $CPPFLAGS"
CFLAGS="-DBWTREE $CFLAGS"])
AC_ARG_ENABLE([BERKELEYDB], [],
[CPPFLAGS="-DBERKELEYDB $CPPFLAGS"
CFLAGS="-DBERKELEYDB $CFLAGS"
LDFLAGS="-ldb_cxx"])
# spack provides a pkgconfig file for leveldb but other leveldb packages probably do not provide one
leveldb_backend=no
AC_ARG_ENABLE([LEVELDB],
AS_HELP_STRING([--enable-LEVELDB], [Select "leveldb" as storage backend (default is no)]),
[leveldb_backend=${enableval}]
)
if test "x${leveldb_backend}" == xyes ; then
AC_CHECK_HEADERS([leveldb/c.h], ,
AC_ERROR("Could not find leveldb headers"))
LIBS="${LIBS} -lleveldb"
fi
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT64_T
......@@ -67,24 +33,73 @@ AC_TYPE_SSIZE_T
AC_FUNC_MALLOC
AC_FUNC_REALLOC
#pkg-config and libraries supporting that
PKG_PROG_PKG_CONFIG
if test "x$PKG_CONFIG" == "x"; then
AC_MSG_ERROR([Could not find pkg-config utility!])
fi
PKG_CHECK_MODULES([MARGO],[margo],[],
AC_MSG_ERROR([Could not find working margo installation!]) )
LIBS="$MARGO_LIBS $LIBS"
CPPFLAGS="$MARGO_CFLAGS $CPPFLAGS"
CFLAGS="$MARGO_CFLAGS $CFLAGS"
# we have three possible backends for our datastore. If none are selected,
# then nothing will initialize the class and well that doesn't make any sense
# anyway. Set BwTree as a default option as it's self-contained to the tree.
# Other backends can be selected
bwtree_backend=yes
leveldb_backend=no
berkelydb_backend=no
AC_ARG_ENABLE([berkeleydb],
AS_HELP_STRING([--enable-berkeleydb], [Select "berkeleydb" as
storage backend (default is no)]),
[berkelydb_backend=${enableval}]
)
AC_ARG_ENABLE([leveldb],
AS_HELP_STRING([--enable-leveldb], [Select "leveldb" as storage
backend (default is no)]),
[leveldb_backend=${enableval}]
)
AC_ARG_ENABLE([bwtree],
AS_HELP_STRING([--disable-bwtree], [Disable BwTree as server backend. Will use Berkely DB if disabled (default is no) ]),
AS_HELP_STRING([--enable-bwtree], [Enable BwTree as server
backend. (default is yes) ]),
[bwtree_backend=${enableval}], [bwtree_backend=yes]
)
if test "x${bwtree_backend}" != xyes ; then
AC_DEFINE([DISABLE_BWTREE], 1, [do not use BwTree backend])
AC_CHECK_HEADERS([db.h], ,
AC_ERROR("Could not find alternate backend") )
LIBS="${LIBS} -ldb"
if test "x${berkelydb_backend}" == xyes ; then
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([db_cxx.h], ,
AC_ERROR("Could not find Berkely DB C++ headers"))
AC_CHECK_HEADERS([dbstl_map.h],,
AC_ERROR("Could not find Berkely DB STL headers"))
AC_DEFINE([USE_BDB], 1, [Use Berkely DB backend])
bwtree_backend=no
leveldb_backend=no
LIBS="${LIBS} -ldb_cxx -ldb_stl"
AC_LANG_POP
fi
if test "x${leveldb_backend}" == xyes ; then
# spack provides a pkgconfig file for leveldb but other leveldb
# packages probably do not provide one
AC_CHECK_HEADERS([leveldb/c.h], ,
AC_ERROR("Could not find leveldb headers"))
AC_DEFINE([USE_LEVELDB], 1, [use leveldb backend])
LIBS="${LIBS} -lleveldb"
berkelydb_backend=no
bwtree_backend=no
fi
if test "x${bwtree_backend}" == xyes ; then
AC_DEFINE([USE_BWTREE], 1, [use BwTree backend])
CXXFLAGS="-pthread -std=c++11 -g -Wall -mcx16 -Wno-invalid-offsetof ${CXXFLAGS}"
berkeleydb_backend=no
leveldb_backend=no
fi
AC_CONFIG_FILES([Makefile maint/kv-client.pc maint/kv-server.pc])
......
......@@ -26,7 +26,7 @@ AbstractDataStore::AbstractDataStore(Duplicates duplicates, bool eraseOnGet, boo
AbstractDataStore::~AbstractDataStore()
{};
#if BWTREE
#if USE_BWTREE
BwTreeDataStore::BwTreeDataStore() :
AbstractDataStore(Duplicates::IGNORE, false, false) {
_tree = NULL;
......@@ -131,9 +131,7 @@ bool BwTreeDataStore::get(ds_bulk_t &key, std::vector<ds_bulk_t> &data) {
void BwTreeDataStore::BwTreeDataStore::set_in_memory(bool enable)
{};
#endif
#if LEVELDB
#elif USE_LEVELDB
LevelDBDataStore::LevelDBDataStore() :
AbstractDataStore(Duplicates::IGNORE, false, false) {
_dbm = NULL;
......@@ -246,10 +244,7 @@ bool LevelDBDataStore::get(ds_bulk_t &key, std::vector<ds_bulk_t> &data) {
void LevelDBDataStore::LevelDBDataStore::set_in_memory(bool enable)
{};
#endif
#if BERKELEYDB
#elif USE_BDB
BerkeleyDBDataStore::BerkeleyDBDataStore() :
AbstractDataStore(Duplicates::IGNORE, false, false) {
_dbm = NULL;
......@@ -443,4 +438,6 @@ bool BerkeleyDBDataStore::get(ds_bulk_t &key, std::vector<ds_bulk_t> &data) {
void BerkeleyDBDataStore::BerkeleyDBDataStore::set_in_memory(bool enable) {
_in_memory = enable;
};
#else
#error "No backend for datastore selected"
#endif
......@@ -9,17 +9,16 @@
#include <boost/functional/hash.hpp>
#include <vector>
#if LEVELDB
#if USE_LEVELDB
#include <leveldb/db.h>
#include <leveldb/env.h>
#endif
#if BERKELEYDB
#elif USE_BDB
#include <db_cxx.h>
#include <dbstl_map.h>
#endif
#if BWTREE
#elif USE_BWTREE
using namespace wangziqi2013::bwtree;
#else
#error "No backend selected at configure time"
#endif
#ifndef datastore_h
......@@ -68,7 +67,7 @@ protected:
bool _in_memory;
};
#if BWTREE
#if USE_BWTREE
class BwTreeDataStore : public AbstractDataStore {
public:
BwTreeDataStore();
......@@ -84,9 +83,7 @@ protected:
my_less, my_equal, my_hash,
my_equal, my_hash> *_tree = NULL;
};
#endif
#if LEVELDB
#elif USE_LEVELDB
// may want to implement some caching for persistent stores like LevelDB
class LevelDBDataStore : public AbstractDataStore {
public:
......@@ -104,9 +101,7 @@ private:
std::string toString(ds_bulk_t &key);
ds_bulk_t fromString(std::string &keystr);
};
#endif
#if BERKELEYDB
#elif USE_BDB
// may want to implement some caching for persistent stores like BerkeleyDB
class BerkeleyDBDataStore : public AbstractDataStore {
public:
......@@ -122,6 +117,8 @@ protected:
DbEnv *_dbenv = NULL;
Db *_dbm = NULL;
};
#else
#error "No datastore backend selected"
#endif
#endif // datastore_h
......@@ -31,14 +31,16 @@ static hg_return_t open_handler(hg_handle_t handle)
#endif
if (!datastore) {
#if BWTREE
#if USE_BWTREE
datastore = new BwTreeDataStore(); // testing BwTree
#elif BERKELEYDB
#elif USE_BDB
datastore = new BerkeleyDBDataStore(); // testing BerkeleyDB
// in-memory implementation not working, needs debugging
//datastore->set_in_memory(true); // testing in-memory BerkeleyDB
#elif LEVELDB
#elif USE_LEVELDB
datastore = new LevelDBDataStore(); // testing LevelDB
#else
#error "No datastore backend selected at configure-time"
#endif
db_name = in_name;
datastore->createDatabase(db_name);
......@@ -370,7 +372,7 @@ static void shutdown_handler(hg_handle_t handle)
}
DEFINE_MARGO_RPC_HANDLER(shutdown_handler)
#if BWTREE
#if USE_BWTREE
/*
* from BwTree tests:
* RandomInsertSpeedTest() - Tests how fast it is to insert keys randomly
......
......@@ -80,12 +80,10 @@ int main(int argc, char **argv)
RandomInsertSpeedTest(context, items, &rpc);
print_results(&rpc);
#if BWTREE // kv_benchmark code only supported when BwTree enabled
bench_result_t *server;
server = kv_benchmark(context, items);
print_results(server);
free(server);
#endif
/* close */
ret = kv_close(context);
......
......@@ -64,7 +64,6 @@ int main(int argc, char **argv) {
std::cout << "remote_bulk_val: " << remote_bulk_val[0] << std::endl;
}
#if BWTREE // kv_benchmark code only supported when BwTree enabled
bench_result_t *output;
output = kv_benchmark(context, 1000);
printf("inserts: %zd keys in %f seconds: %f Million-inserts per sec\n",
......@@ -75,7 +74,6 @@ int main(int argc, char **argv) {
output->nkeys/(output->read_time*1000*1000) );
printf("overhead: %f seconds\n", output->overhead);
free(output);
#endif
/* close */
ret = kv_close(context);
......
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