Preprocessing Directives#

Some aspects of the MOCCA library can be customized by defining preprocessor tokens using #define command. These macros should be defined before the inclusion of any MOCCA header. Typically, they are set in the compilation phase.

Macros with Major Effects#

These macros have a major effect on the library and often can break the API (Application Programming Interface) and/or ABI(Application Binary Interface). They can be rather dangerous: if some parts of your program are compiled with one option and other parts of your program are compiled with another, your program may fail to link or exhibit some strange behaviour. Nevertheless, these options can be useful in some situations.

  • MOCCA_INDEX_TYPE - Define the type used as an index for all objects in the library. Set to std::ptrdiff_t by default.

  • MOCCA_ALLOC_BLOCK - Define the block size when (re)allocating containers. In order to reduce the number of reallocations when changing the size of the container, all memory allocations are based on a block with a fixed number of entries. Set to 1024 entries by default.

  • MOCCA_BLAS - Specify the interface of the external BLAS/LAPACK library. Options: MKL or CBLAS. See BLAS and LAPACK for more information.

Other Macros#

  • MOCCA_NO_DEBUG - If defined, disable all runtime assertion checks. Not defined by default.

  • MOCCA_DISABLE_BROADCAST - If defined, disable the Broadcast operation. Not defined by default.

  • MOCCA_NO_AUTO_RESIZE - If defined, disable the automatic resize of the container when assigning an expression to it. If the dimensions mismatch, MOCCA will throw an error unless MOCCA_NO_DEBUG is defined. Not defined by default.

  • MOCCA_SIMD_TARGET - By default, MOCCA will automatically detect and set the appropriate SIMD instruction set. Use this flag to explicitly set the SIMD target. Available options: OMP, AVX2 or AVX512.

  • MOCCA_NO_MULTITHREADING - By default, MOCCA run some algorithms in parallel using OpenMP threads. Note that you must also enable OpenMP in your compiler (e.g., passing the -fopenmp flag to the clang++ or g++ compilers) to enable multithreading. If MOCCA_NO_MULTITHREADING is defined, MOCCA will not parallelize the algorithms.

  • MOCCA_DISABLE_UNROLLING - If defined, disables loop unrolling. Not defined by default.

  • MOCCA_STRONG_INLINE - This setting forces the compiler to inline performance-critical methods. You can set this macro to inline to reduce the aggressiveness of function inlining, however, this may result in worse performance if the compiler fails to properly inline the routines.