organized Makefile, preemptive initialization

dev
Bill 2 years ago
parent 5dad6e5270
commit be7fb9f523

@ -86,40 +86,56 @@ endif
ifeq ($(AQUERY_ITC_USE_SEMPH), 1)
Defines += -D__AQUERY_ITC_USE_SEMPH__
endif
SHAREDFLAGS += $(FPIC)
CXXFLAGS += $(OPTFLAGS) $(Defines) $(MonetDB_INC)
BINARYFLAGS = $(CXXFLAGS) $(LINKFLAGS) $(MonetDB_LIB)
SHAREDFLAGS += $(FPIC) $(BINARYFLAGS)
info:
$(info $(OPTFLAGS))
$(info $(OS_SUPPORT))
$(info $(OS))
$(info $(Defines))
$(info "test")
$(info $(LIBTOOL))
$(info $(MonetDB_INC))
$(info $(COMPILER))
$(info $(CXX))
$(info $(FPIC))
$(info This makefile script is used in AQuery to automatically build required libraries and executables.)
$(info Run it manually only for debugging purposes.)
$(info Targets (built by `make <target>`):)
$(info $" pch: generate precompiled header)
$(info $" libaquery.a: build static library)
$(info $" server.so: build execution engine)
$(info $" snippet: build generated query snippet)
$(info $" server_uselib: build execution engine using shared library and pch)
$(info $" snippet_uselib: build generated query snippet using shared library and pch)
$(info $" docker: build docker image with name aquery)
$(info $" launcher: build launcher for aquery ./aq)
$(info $" clean: remove all generated binaraies and caches)
$(info )
$(info Variables:)
$(info $" OPTFLAGS: $(OPTFLAGS))
$(info $" OS_SUPPORT: $(OS_SUPPORT))
$(info $" OS: $(OS))
$(info $" Defines: $(Defines))
$(info $" LIBTOOL: $(LIBTOOL))
$(info $" MonetDB_INC: $(MonetDB_INC))
$(info $" COMPILER: $(COMPILER))
$(info $" CXX: $(CXX))
$(info $" FPIC: $(FPIC))
pch:
$(CXX) -x c++-header server/pch.hpp $(FPIC) $(MonetDB_INC) $(OPTFLAGS) $(CXXFLAGS) $(Defines)
$(CXX) -x c++-header server/pch.hpp $(FPIC) $(CXXFLAGS)
libaquery.a:
$(CXX) -c $(FPIC) $(PCHFLAGS) $(LIBAQ_SRC) $(MonetDB_INC) $(MonetDB_LIB) $(OS_SUPPORT) $(Defines) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) &&\
$(CXX) -c $(FPIC) $(PCHFLAGS) $(LIBAQ_SRC) $(MonetDB_LIB) $(OS_SUPPORT) $(CXXFLAGS) &&\
$(LIBTOOL) libaquery.a $(LIBAQ_OBJ) &&\
$(RANLIB) libaquery.a
server.bin:
$(CXX) $(LIBAQ_SRC) $(LINKFLAGS) $(OS_SUPPORT) $(Defines) $(MonetDB_INC) $(MonetDB_LIB) $(OPTFLAGS) $(CXXFLAGS) -o server.bin
$(CXX) $(LIBAQ_SRC) $(BINARYFLAGS) $(OS_SUPPORT) -o server.bin
launcher:
$(CXX) -D__AQ_BUILD_LAUNCHER__ $(LIBAQ_SRC) $(LINKFLAGS) $(OS_SUPPORT) $(Defines) $(MonetDB_INC) $(MonetDB_LIB) $(OPTFLAGS) $(CXXFLAGS) -o aq
$(CXX) -D__AQ_BUILD_LAUNCHER__ $(LIBAQ_SRC) $(OS_SUPPORT) $(BINARYFLAGS) -o aq
server.so:
# $(CXX) -z muldefs server/server.cpp server/monetdb_conn.cpp -fPIC -shared $(OS_SUPPORT) monetdb/msvc/monetdbe.dll --std=c++1z -O3 -march=native -o server.so -I./monetdb/msvc
$(CXX) $(SHAREDFLAGS) $(PCHFLAGS) $(LIBAQ_SRC) $(OS_SUPPORT) $(Defines) $(MonetDB_INC) $(MonetDB_LIB) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) -o server.so
$(CXX) $(SHAREDFLAGS) $(PCHFLAGS) $(LIBAQ_SRC) $(OS_SUPPORT) -o server.so
server_uselib:
$(CXX) $(SHAREDFLAGS) $(USELIB_FLAG),libaquery.a $(MonetDB_LIB) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) -o server.so
$(CXX) $(SHAREDFLAGS) $(USELIB_FLAG),libaquery.a -o server.so
snippet:
$(CXX) $(SHAREDFLAGS) $(PCHFLAGS) out.cpp $(LIBAQ_SRC) $(MonetDB_INC) $(MonetDB_LIB) $(Defines) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) -o dll.so
$(CXX) $(SHAREDFLAGS) $(PCHFLAGS) out.cpp $(LIBAQ_SRC) -o dll.so
snippet_uselib:
$(CXX) $(SHAREDFLAGS) $(PCHFLAGS) out.cpp libaquery.a $(MonetDB_INC) $(Defines) $(MonetDB_LIB) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) -o dll.so
$(CXX) $(SHAREDFLAGS) $(PCHFLAGS) out.cpp libaquery.a -o dll.so
docker:
docker build -t aquery .

@ -195,7 +195,7 @@ class Config:
self.new_query = nq
self.server_mode = mode.value
self.running = 1
self.backend_type = Backend_Type.BACKEND_AQuery.value
self.backend_type = Backend_Type.BACKEND_MonetDB.value
self.has_dll = 0
self.n_buffers = n_bufs
self.monetdb_time = 0
@ -399,6 +399,8 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None):
payload = None
keep = True
cxt = engine.initialize()
parser.parse('SELECT "**** WELCOME TO AQUERY++! ****";')
# state.currstats = QueryStats()
# state.need_print = False
while running():

@ -11,6 +11,7 @@ private:
using vector = vector_type<T>;
template<class ...T>
using tuple = std::tuple<T...>;
size_t current_size = 0, max_size,
interval, forced_clean,
forceclean_timer = 0;
@ -19,9 +20,9 @@ private:
vector<tuple<void*, void (*)(void*)>> *q, *q_back;
std::thread handle;
std::atomic<std::thread::id> lock;
// maybe use volatile std::thread::id instead
protected:
void acquire_lock(){
void acquire_lock() {
auto this_pid = std::this_thread::get_id();
while(lock != this_pid)
{
@ -38,7 +39,7 @@ protected:
void gc()
{
if (q->size() == 0)
if (q->size == 0)
return;
auto t = q;
acquire_lock();

@ -217,8 +217,13 @@ int dll_main(int argc, char** argv, Context* cxt){
cxt->cfg = cfg;
cxt->n_buffers = cfg->n_buffers;
cxt->sz_bufs = buf_szs;
cxt->alt_server = NULL;
if (cfg->backend_type == BACKEND_MonetDB && cxt->alt_server == nullptr)
{
auto alt_server = new Server(cxt);
alt_server->exec("SELECT '**** WELCOME TO AQUERY++! ****';");
puts(*(const char**)(alt_server->getCol(0)));
cxt->alt_server = alt_server;
}
while(cfg->running){
ENGINE_ACQUIRE();
if (cfg->new_query) {

Loading…
Cancel
Save