Xped
Loading...
Searching...
No Matches
Macros.hpp
Go to the documentation of this file.
1#ifndef XPED_MACROS_H
2#define XPED_MACROS_H
3
4#include <boost/predef.h>
5#include <string>
6
7// Get infos to the used compiler and version. Taken from Eigen (Macros.h)
8#if BOOST_COMP_CLANG
9const std::string XPED_COMPILER_STR = "clang++";
10#elif BOOST_COMP_INTEL
11const std::string XPED_COMPILER_STR = "icpc";
12#elif BOOST_COMP_GNUC
13const std::string XPED_COMPILER_STR = "g++";
14#elif __INTEL_LLVM_COMPILER
15# define BOOST_COMP_INTEL_LLVM __INTEL_LLVM_COMPILER
16const std::string XPED_COMPILER_STR = "icpx";
17#elif BOOST_COMP_MSVC
18const std::string XPED_COMPILER_STR = "msvc";
19#else
20# ifdef BOOST_COMP_MSVC
21# error "Unsupported compiler"
22# else
23# pragma error "Unsupported compiler."
24# endif
25#endif
26
27#if defined(XPED_USE_MKL)
28const std::string XPED_BLAS_STR = "MKL";
29#elif defined(XPED_USE_BLAS)
30const std::string XPED_BLAS_STR = "OpenBLAS";
31#else
32const std::string XPED_BLAS_STR = "None";
33#endif
34
35// Get supported std of the compiler
36#if defined(__cplusplus)
37# if __cplusplus == 201103L
38# define XPED_CXX11 1
39# elif __cplusplus == 201402L
40# define XPED_CXX14 1
41# elif __cplusplus == 201703L
42# define XPED_CXX17 1
43# elif __cplusplus >= 202002L
44# define XPED_CXX20 1
45# endif
46#endif
47
48#if BOOST_COMP_GNUC
49# if __GNUC__ > 9
50# define XPED_HAS_NTTP 1
51# else
52# define XPED_HAS_NTTP 0
53# endif
54#elif BOOST_COMP_CLANG
55# if __clang_major__ > 11
56# define XPED_HAS_NTTP 1
57# else
58# define XPED_HAS_NTTP 0
59# endif
60#elif BOOST_COMP_INTEL_LLVM
61# if __INTEL_LLVM_COMPILER >= 20210400
62# define XPED_HAS_NTTP 1
63# else
64# define XPED_HAS_NTTP 0
65# endif
66#elif BOOST_COMP_INTEL
67# define XPED_HAS_NTTP 0
68#elif BOOST_COMP_MSVC
69# if _MSC_VER >= 1930
70# define XPED_HAS_NTTP 1
71# else
72# define XPED_HAS_NTTP 0
73# endif
74#endif
75
76#if __has_include("boost/functional/hash.hpp")
77# define XPED_HAS_BOOST_HASH_COMBINE 1
78#endif
79
80#ifndef XPED_EFFICIENCY_MODEL
81# define XPED_TIME_EFFICIENT
82#endif
83
84#ifndef SPDLOG_ACTIVE_LEVEL
85# define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_OFF
86#endif
87
88// clang-format off
89#define XPED_INIT_TREE_CACHE_VARIABLE(VARIABLE_NAME, CACHE_SIZE) \
90namespace Xped {\
91template <std::size_t Rank, typename Symmetry> \
92struct FusionTree; \
93} \
94template <int shift, std::size_t Rank, std::size_t CoRank, typename Symmetry> \
95struct CacheManager \
96{ \
97 typedef Xped::FusionTree<CoRank, Symmetry> CoTree; \
98 typedef Xped::FusionTree<CoRank + shift, Symmetry> NewCoTree; \
99 typedef Xped::FusionTree<Rank, Symmetry> Tree; \
100 typedef Xped::FusionTree<Rank - shift, Symmetry> NewTree; \
101 typedef typename Symmetry::Scalar Scalar; \
102 typedef LRU::Cache<std::tuple<Tree, CoTree, Xped::util::Permutation>, std::unordered_map<std::pair<NewTree, NewCoTree>, Scalar>> CacheType; \
103 CacheManager(std::size_t cache_size) \
104 { \
105 cache = CacheType(cache_size); \
106 cache.monitor(); \
107 } \
108 CacheType cache; \
109}; \
110template <int shift, std::size_t Rank, std::size_t CoRank, typename Symmetry> \
111CacheManager<shift, Rank, CoRank, Symmetry> VARIABLE_NAME(CACHE_SIZE);
112
113// clang-format on
114#ifdef XPED_USE_MPI
115# define XPED_MPI_BARRIER(comm) MPI_Barrier(comm);
116#else
117# define XPED_MPI_BARRIER(comm)
118#endif
119
120#if defined XPED_USE_EIGEN_TENSOR_LIB && defined XPED_USE_EIGEN_MATRIX_LIB && defined XPED_USE_EIGEN_VECTOR_LIB
121# define XPED_CONST const
122#elif defined XPED_USE_ARRAY_TENSOR_LIB && defined XPED_USE_EIGEN_MATRIX_LIB && defined XPED_USE_EIGEN_VECTOR_LIB
123# define XPED_CONST const
124#elif defined XPED_USE_CYCLOPS_TENSOR_LIB && defined XPED_USE_CYCLOPS_MATRIX_LIB && defined XPED_USE_CYCLOPS_VECTOR_LIB
125# define XPED_CONST
126#else
127# error "You specified an invalid combination of plain matrix library, plain tensor library and plain vector library."
128#endif
129
130#endif
const std::string XPED_BLAS_STR
Definition: Macros.hpp:32