diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-04-24 02:11:35 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-04-24 02:13:45 +0300 |
commit | c5e54ca6234d9568e1185e1ff92f4d04c41faa6c (patch) | |
tree | ed5a86099956c00753d410dc637388480971a808 | |
parent | 4e6c08b939fbfb1cd4a8a5653bd16d285b55150c (diff) | |
download | mv-c5e54ca6234d9568e1185e1ff92f4d04c41faa6c.tar.gz mv-c5e54ca6234d9568e1185e1ff92f4d04c41faa6c.tar.bz2 mv-c5e54ca6234d9568e1185e1ff92f4d04c41faa6c.tar.xz mv-c5e54ca6234d9568e1185e1ff92f4d04c41faa6c.zip |
Add configure option for enable/disable CilkPlus support.
By default disabled.
-rwxr-xr-x | configure.ac | 11 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/localconsts.h | 25 | ||||
-rw-r--r-- | 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 <cilk/cilk.h> +#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__ ; /** |