Commit 3ed767b6 authored by Dominik Charousset's avatar Dominik Charousset

added configure option to disable mem. mgmt.

parent c71a2281
......@@ -26,7 +26,7 @@ else (CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "-std=c++11 -Wextra -Wall -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
endif (CMAKE_CXX_FLAGS)
......@@ -72,11 +72,11 @@ endif ()
# set build type (evaluate ENABLE_DEBUG flag)
if (ENABLE_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_DEBUG_MODE")
add_definitions(-DCPPA_DEBUG_MODE)
endif (ENABLE_DEBUG)
if (CPPA_LOG_LEVEL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_LOG_LEVEL=${CPPA_LOG_LEVEL}")
add_definitions(-DCPPA_LOG_LEVEL=${CPPA_LOG_LEVEL})
endif(CPPA_LOG_LEVEL)
# set build default build type if not set
......@@ -185,9 +185,13 @@ if (ENABLE_OPENCL)
src/opencl/program.cpp
src/opencl/actor_facade.cpp
src/opencl/command_dispatcher.cpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_OPENCL")
add_definitions(-DCPPA_OPENCL)
endif (ENABLE_OPENCL)
if (DISABLE_MEM_MANAGEMENT)
add_definitions(-DCPPA_DISABLE_MEM_MANAGEMENT)
endif (DISABLE_MEM_MANAGEMENT)
if (DISABLE_CONTEXT_SWITCHING)
# explicitly disabled
else (DISABLE_CONTEXT_SWITCHING)
......@@ -355,8 +359,10 @@ endmacro ()
toYesNo(ENABLE_DEBUG DEBUG_MODE_STR)
toYesNo(ENABLE_OPENCL BUILD_OPENCL_STR)
toYesNo(DISABLE_MEM_MANAGEMENT DISABLE_MEM_MANAGEMENT_STR)
invertYesNo(CPPA_NO_EXAMPLES BUILD_EXAMPLES)
invertYesNo(CPPA_NO_UNIT_TESTS BUILD_UNIT_TESTS)
invertYesNo(DISABLE_MEM_MANAGEMENT_STR WITH_MEM_MANAGEMENT)
if (NOT "${CPPA_BUILD_STATIC}" STREQUAL "yes")
set(CPPA_BUILD_STATIC "no")
......@@ -383,6 +389,7 @@ message("\n====================| Build Summary |===================="
"\nBuild static: ${CPPA_BUILD_STATIC}"
"\nBulid static only: ${CPPA_BUILD_STATIC_ONLY}"
"\nBuild OpenCL: ${BUILD_OPENCL_STR}"
"\nWith mem. mgmt.: ${WITH_MEM_MANAGEMENT}"
"\n"
"\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${build_type}}"
......
......@@ -35,6 +35,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--build-static build libcppa as static and shared library
--build-static-only build libcppa as static library only
--with-opencl build libcppa with OpenCL support
--without-memory-management build libcppa without memory management
Installation Directories:
--prefix=PREFIX installation directory [/usr/local]
......@@ -163,6 +164,9 @@ while [ $# -ne 0 ]; do
--with-opencl)
append_cache_entry ENABLE_OPENCL BOOL true
;;
--without-memory-management)
append_cache_entry DISABLE_MEM_MANAGEMENT BOOL true
;;
--with-cppa-log-level=*)
level=$(echo "$optarg" | tr '[:lower:]' '[:upper:]')
case $level in
......
......@@ -47,12 +47,18 @@ namespace cppa { namespace detail {
namespace {
constexpr size_t s_alloc_size = 1024*1024; // allocate ~1mb chunks
constexpr size_t s_min_elements = 5; // don't create less than 5 elements
constexpr size_t s_cache_size = 10*1024*1024; // cache about 10mb per thread
constexpr size_t s_alloc_size = 1024*1024; // allocate ~1mb chunks
constexpr size_t s_cache_size = 10*1024*1024; // cache about 10mb per thread
constexpr size_t s_min_elements = 5; // don't create < 5 elements
} // namespace <anonymous>
struct disposer {
inline void operator()(memory_managed* ptr) const {
ptr->request_deletion();
}
};
class instance_wrapper {
public:
......@@ -83,6 +89,36 @@ class memory_cache {
};
class instance_wrapper;
template<typename T>
class basic_memory_cache;
#ifdef CPPA_DISABLE_MEM_MANAGEMENT
class memory {
memory() = delete;
public:
/*
* @brief Allocates storage, initializes a new object, and returns
* the new instance.
*/
template<typename T, typename... Ts>
static T* create(Ts&&... args) {
return new T (std::forward<Ts>(args)...);
}
static inline memory_cache* get_cache_map_entry(const std::type_info*) {
return nullptr;
}
};
#else // CPPA_DISABLE_MEM_MANAGEMENT
template<typename T>
class basic_memory_cache : public memory_cache {
......@@ -163,12 +199,6 @@ class basic_memory_cache : public memory_cache {
};
struct disposer {
inline void operator()(memory_managed* ptr) const {
ptr->request_deletion();
}
};
class memory {
memory() = delete;
......@@ -209,6 +239,8 @@ class memory {
};
#endif // CPPA_DISABLE_MEM_MANAGEMENT
} } // namespace cppa::detail
#endif // CPPA_MEMORY_HPP
......@@ -36,6 +36,12 @@
using namespace std;
#ifdef CPPA_DISABLE_MEM_MANAGEMENT
int cppa_memory_keep_compiler_happy() { return 0; }
#else // CPPA_DISABLE_MEM_MANAGEMENT
namespace cppa { namespace detail {
namespace {
......@@ -84,17 +90,6 @@ void memory::add_cache_map_entry(const type_info* tinf, memory_cache* instance)
instance_wrapper::~instance_wrapper() { }
//pair<instance_wrapper*, void*> memory::allocate(const type_info* type) {
// return get_cache_map_entry(type)->allocate();
//}
//recursive_queue_node* memory::new_queue_node() {
// typedef recursive_queue_node type;
// return get_cache_map_entry(&typeid(type))->typed_new<type>();
//}
//void memory::deallocate(const type_info* type, void* ptr) {
// return get_cache_map_entry(type)->deallocate(ptr);
//}
} } // namespace cppa::detail
#endif // CPPA_DISABLE_MEM_MANAGEMENT
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