diff --git a/Makefile b/Makefile index 27bc003e53030819c3a0f2eb506cf209543b8700..d1619e13e0870c76704655be27be1a4bf336ddef 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ default: groupConnectivity.so clean_obj -groupConnectivity.so: groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h rings.h fast-array.h parmap.py +groupConnectivity.so: groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h generateCompileTimeOptions.sh rings.h fast-array.h parmap.py + ./generateCompileTimeOptions.sh > options.h python setup.py build_ext cp build/lib*/groupConnectivity.so . clean_obj: - rm -f *.o groupConnectivity.cpp + rm -f *.o groupConnectivity.cpp options.h rm -rf build clean: clean_obj diff --git a/compileTimeOptions.h b/compileTimeOptions.h index 865d26f9eca3f95bbd7cccfba52ab4192f453a4a..5218ac0465b927d93b5e9ae28e04eeb74d20b2ea 100644 --- a/compileTimeOptions.h +++ b/compileTimeOptions.h @@ -1,50 +1,16 @@ -#ifndef __COMPILE_TIME_OPTIONS_H__ -#define __COMPILE_TIME_OPTIONS_H__ +#error "DON'T include directly" // bool; use vector<bool> instead of vector<size_t> for classes -#ifndef SAVE_MEMORY -#define SAVE_MEMORY 1 -#endif -#if SAVE_MEMORY -#pragma message "SAVE_MEMORY ON" -#else -#pragma message "SAVE_MEMORY off" -#endif +BOOL_OPTION(SAVE_MEMORY, 1) +BOOL_OPTION(OPTIMIZED_MAPPINGS, 1) -#ifndef OPTIMIZED_MAPPINGS -#define OPTIMIZED_MAPPINGS 1 -#endif -#if OPTIMIZED_MAPPINGS -#pragma message "OPTIMIZED_MAPPINGS ON" -#else -#pragma message "OPTIMIZED_MAPPINGS off" -#endif - - -#ifndef OPTIMIZE_COMBINE -#define OPTIMIZE_COMBINE 0 -#endif -#if OPTIMIZE_COMBINE -#pragma message "OPTIMIZE_COMBINE ON" -#else -#pragma message "OPTIMIZE_COMBINE off" -#endif - - -#ifndef USE_NEXT_FORB -#define USE_NEXT_FORB 1 -#endif -#if USE_NEXT_FORB -#pragma message "USE_NEXT_FORB ON" -#else -#pragma message "USE_NEXT_FORB off" -#endif +BOOL_OPTION(OPTIMIZE_COMBINE, 0) +BOOL_OPTION(USE_NEXT_FORB, 1) #ifndef MAX_EDGES #define MAX_EDGES 48 #endif -#endif diff --git a/fast-array.h b/fast-array.h index 1614691b2ad4c974118903690f26ee909ca80213..32b45ff2eef2cc23fff712c90b0360d8357124ff 100644 --- a/fast-array.h +++ b/fast-array.h @@ -2,6 +2,7 @@ #define __FAST_ARRAY_H__ #include "rings.h" +#include "options.h" template < typename Ring > struct Mapping { diff --git a/generateCompileTimeOptions.sh b/generateCompileTimeOptions.sh new file mode 100755 index 0000000000000000000000000000000000000000..19c2de6c56c34e05f25dc54597e39900c7fe61e7 --- /dev/null +++ b/generateCompileTimeOptions.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +cat <<EOF +#ifndef __COMPILE_TIME_OPTIONS_H__ +#define __COMPILE_TIME_OPTIONS_H__ +EOF + +tail -n +2 compileTimeOptions.h | +sed -re 's/BOOL_OPTION\((.*), *(.*)\)/#ifndef \1\ +#define \1 \2\ +#endif\ +#if \1\ +#pragma message "\1 ON"\ +#else\ +#pragma message "\1 off"\ +#endif\ +/' + +cat <<EOF +#endif +EOF + diff --git a/group-connectivity.h b/group-connectivity.h index 1ad4100c246040d3528e21e899db9e512f3134ad..110faf4a264ed04f50726bb43d732e7e5dbf3847 100644 --- a/group-connectivity.h +++ b/group-connectivity.h @@ -2,7 +2,7 @@ #define __GROUP_CONNECTIVITY_H__ #include <vector> -#include "compileTimeOptions.h" +#include "options.h" #include "rings.h" #include "fast-array.h"