From c5e54ca6234d9568e1185e1ff92f4d04c41faa6c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 24 Apr 2015 02:11:35 +0300 Subject: Add configure option for enable/disable CilkPlus support. By default disabled. --- configure.ac | 11 +++++++++++ src/Makefile.am | 5 +++++ src/localconsts.h | 25 ++++++++++++++++++++++--- src/logger.h | 27 +++++++++++++++++++++------ 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index dbf134319..d8abded8c 100755 --- a/configure.ac +++ b/configure.ac @@ -368,6 +368,17 @@ esac],[googleprofiler_enabled=false]) AM_CONDITIONAL(ENABLE_GOOGLE_PROFILER, test x$googleprofiler_enabled = xtrue) +# Enable cilk plus +AC_ARG_ENABLE(cilkplus, +[ --enable-cilkplus Turn on parallelisation with CilkPlus], +[case "${enableval}" in + yes) cilkplus_enabled=true ;; + no) cilkplus_enabled=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-cilkplus) ;; +esac],[cilkplus_enabled=false]) + +AM_CONDITIONAL(ENABLE_CILKPLUS, test x$cilkplus_enabled = xtrue) + AC_CONFIG_FILES([ manaplus.spec Makefile diff --git a/src/Makefile.am b/src/Makefile.am index c9951189e..8f6f457e7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,6 +28,11 @@ else manaplus_SOURCES = endif +if ENABLE_CILKPLUS +manaplus_CXXFLAGS += -DENABLE_CILKPLUS -fcilkplus -lcilkrts +dyecmd_CXXFLAGS += -DENABLE_CILKPLUS -fcilkplus -lcilkrts +endif + dyecmd_CXXFLAGS += -DDYECMD dyecmd_SOURCES = gui/cliprect.cpp \ gui/color.cpp \ diff --git a/src/localconsts.h b/src/localconsts.h index 1c43ebc58..4c4827d70 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -33,6 +33,10 @@ #endif #endif +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + #if !defined(__GXX_EXPERIMENTAL_CXX0X__) #undef nullptr #define nullptr 0 @@ -43,9 +47,6 @@ #define A_DELETE(func) #define A_DELETE_COPY(func) #else -#define GCC_VERSION (__GNUC__ * 10000 \ - + __GNUC_MINOR__ * 100 \ - + __GNUC_PATCHLEVEL__) #if GCC_VERSION < 40700 #define final #define override @@ -80,6 +81,20 @@ #define gnu_printf printf #endif +#ifdef __GNUC__ +#ifdef ENABLE_CILKPLUS +#if GCC_VERSION < 50000 +#define cilk_for for +#elif GCC_VERSION < 49000 +#define cilk_for for +#define cilk_spawn +#endif // GCC_VERSION < 50000 +#else // ENABLE_CILKPLUS +#define cilk_for for +#define cilk_spawn +#endif // ENABLE_CILKPLUS +#endif // __GNUC__ + #define notfinal #define FOR_EACH(type, iter, array) for (type iter = array.begin(), \ @@ -142,3 +157,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif + +#ifdef ENABLE_CILKPLUS +#include +#endif diff --git a/src/logger.h b/src/logger.h index 9e82670ad..40ea191c2 100644 --- a/src/logger.h +++ b/src/logger.h @@ -84,11 +84,19 @@ class Logger final void log(const char *const log_text, ...) #ifdef __GNUC__ #ifdef __OpenBSD__ + __attribute__((__format__(printf, 2, 3))) -#else +#else // __OpenBSD__ + +#ifdef ENABLE_CILKPLUS + __attribute__((__format__(gnu_printf, 1, 2))) +#else // ENABLE_CILKPLUS + __attribute__((__format__(gnu_printf, 2, 3))) -#endif -#endif +#endif // ENABLE_CILKPLUS + +#endif // __OpenBSD__ +#endif // __GNUC__ ; /** @@ -98,10 +106,17 @@ class Logger final #ifdef __GNUC__ #ifdef __OpenBSD__ __attribute__((__format__(printf, 2, 3))) -#else +#else // __OpenBSD__ + +#ifdef ENABLE_CILKPLUS + __attribute__((__format__(gnu_printf, 1, 2))) +#else // ENABLE_CILKPLUS + __attribute__((__format__(gnu_printf, 2, 3))) -#endif -#endif +#endif // ENABLE_CILKPLUS + +#endif // __OpenBSD__ +#endif // __GNUC__ ; /** -- cgit v1.2.3-60-g2f50