11/* This file is part of the FASTOR library. {{{
2- Copyright (c) 2016 Roman Poya
2+ Copyright (c) 2020 Roman Poya
33
44Permission is hereby granted, free of charge, to any person obtaining a copy
55of this software and associated documentation files (the "Software"), to deal
@@ -74,11 +74,17 @@ SOFTWARE.
7474#endif
7575// ------------------------------------------------------------------------------------------------//
7676
77+
78+ // Aliasing
79+ // ------------------------------------------------------------------------------------------------//
7780#ifndef FASTOR_NO_ALIAS
7881#define FASTOR_NO_ALIAS 0
7982#endif
83+ // ------------------------------------------------------------------------------------------------//
8084
81- // this changes the behaviour of all expression templates (apart from views)
85+
86+ // Macros used throughout Fastor
87+ // ------------------------------------------------------------------------------------------------//
8288// #define FASTOR_COPY_EXPR
8389// #define FASTOR_DONT_VECTORISE
8490// #define FASTOR_DONT_PERFORM_OP_MIN
@@ -101,11 +107,14 @@ SOFTWARE.
101107#define FASTOR_BLAS_SWITCH_MATRIX_SIZE 16
102108#endif
103109
104-
110+ // FASTOR_NIL
111+ // ------------------------------------------------------------------------------------------------//
105112#define FASTOR_NIL 0
106113// ------------------------------------------------------------------------------------------------//
107114
108115
116+ // Bit sizes
117+ // ------------------------------------------------------------------------------------------------//
109118#define FASTOR_AVX512_BITSIZE 512
110119#define FASTOR_AVX_BITSIZE 256
111120#define FASTOR_SSE_BITSIZE 128
@@ -114,6 +123,7 @@ SOFTWARE.
114123#ifndef FASTOR_SCALAR_BITSIZE
115124#define FASTOR_SCALAR_BITSIZE FASTOR_DOUBLE_BITSIZE
116125#endif
126+ // ------------------------------------------------------------------------------------------------//
117127
118128
119129// Alignment
@@ -144,46 +154,38 @@ SOFTWARE.
144154
145155#define FASTOR_ISALIGNED (POINTER, BYTE_COUNT ) \
146156 (((uintptr_t )(const void *)(POINTER)) % (BYTE_COUNT) == 0 )
157+ // ------------------------------------------------------------------------------------------------//
147158
148159
149- // Asserts and warnings
160+ // Assertions
150161// ------------------------------------------------------------------------------------------------//
151162namespace Fastor {
152-
153- // Strong assert under debug and release
163+ // Strong unconditional assert
154164FASTOR_INLINE void FASTOR_EXIT_ASSERT (bool cond, const std::string &msg=" " ) {
155165 if (cond==false ) {
156166 throw std::runtime_error (msg);
157167 }
158168}
159169
160- #if !FASTOR_ENABLE_RUNTIME_CHECKS
161- // Standard assert - by default only turned on under debug
162- #ifndef NDEBUG
163- #define FASTOR_ASSERT (COND, MESSAGE ) assert (COND && MESSAGE)
170+ #if !defined(NDEBUG) || FASTOR_ENABLE_RUNTIME_CHECKS
171+ #define FASTOR_ASSERT (COND, MESSAGE ) FASTOR_EXIT_ASSERT(COND, MESSAGE)
164172#else
165173#define FASTOR_ASSERT (COND, MESSAGE )
166174#endif
167- #else
168- // Otherwise if asked by the user turned on unconditionally
169- #define FASTOR_ASSERT (COND, MESSAGE ) FASTOR_EXIT_ASSERT(COND, MESSAGE)
170- #endif
171175
176+ // Warn
172177FASTOR_INLINE void FASTOR_WARN (bool cond, const std::string &x) {
173- if (cond==true ) {
174- return ;
175- }
176- else {
178+ if (cond==false ) {
177179 std::cout << x << std::endl;
178180 }
179181}
180-
181182} // end of namespace Fastor
182-
183- #define FASTOR_TOSTRING_ (X ) #X
184- #define FASTOR_TOSTRING (X ) FASTOR_TOSTRING_(X)
183+ // ------------------------------------------------------------------------------------------------//
185184
186185
186+ // Warnings
187+ // ------------------------------------------------------------------------------------------------//
188+ // Static warn
187189#ifndef FASTOR_NO_STATIC_WARNING
188190#if defined(__GNUC__)
189191 #define FASTOR_DEPRECATE (foo, msg ) foo __attribute__ ((deprecated(msg)))
@@ -215,13 +217,24 @@ struct FASTOR_CAT(static_warning,__LINE__) { \
215217
216218} // end of namespace Fastor
217219#endif // FASTOR_NO_STATIC_WARNING
220+ // ------------------------------------------------------------------------------------------------//
218221
219222
223+ // Token to string
224+ // ------------------------------------------------------------------------------------------------//
225+ #define FASTOR_TOSTRING_ (X ) #X
226+ #define FASTOR_TOSTRING (X ) FASTOR_TOSTRING_(X)
227+ // ------------------------------------------------------------------------------------------------//
228+
220229// asm comment
230+ // ------------------------------------------------------------------------------------------------//
221231#define FASTOR_ASM (STR ) asm (STR ::)
232+ // ------------------------------------------------------------------------------------------------//
222233
234+ // unused
235+ // ------------------------------------------------------------------------------------------------//
223236namespace Fastor {
224- // clobber
237+ // clobber
225238template <typename T> void unused (T &&x) {
226239#ifndef _WIN32
227240 asm (" " ::" m" (x));
@@ -230,7 +243,6 @@ template <typename T> void unused(T &&x) {
230243template <typename T, typename ... U> void unused (T&& x, U&& ...y) { unused (x); unused (y...); }
231244} // end of namespace Fastor
232245// ------------------------------------------------------------------------------------------------//
233- // ------------------------------------------------------------------------------------------------//
234246
235247
236248// SIMD round-down
@@ -275,7 +287,6 @@ constexpr int NoDepthFirst = -201;
275287constexpr double PRECI_TOL = 1e-14 ;
276288
277289}
278-
279290// ------------------------------------------------------------------------------------------------//
280291
281292#endif // FASTOR_MACROS_H
0 commit comments