2#ifndef included_AMP_UtilityMacros
3#define included_AMP_UtilityMacros
8#include "StackTrace/source_location.h"
13[[noreturn]]
void abort(
const std::string &message,
const source_location &source );
31template<std::
size_t N>
32static inline std::string
operator+(
char x[N], std::string_view y )
34 return std::string( x ) + std::string( y );
36template<std::
size_t N>
37static inline std::string
operator+( std::string_view y,
char x[N] )
39 return std::string( x ) + std::string( y );
41static inline std::string
operator+( std::string_view x, std::string_view y )
43 return std::string( x ) + std::string( y );
62#define STATIC_ERROR( MSG ) static_assert( failed_assert_v<TYPE>, MSG )
72#define AMP_ERROR( MSG ) StackTrace::Utilities::abort( MSG, SOURCE_LOCATION_CURRENT() )
80#define AMP_WARNING( MSG ) \
82 AMP::pout << "WARNING: " << MSG << std::endl; \
83 AMP::plog << "WARNING: " << MSG << std::endl; \
84 AMP::pout << " Warning called in " << __FILE__ << " on line " << __LINE__ << std::endl; \
85 AMP::plog << " Warning called in " << __FILE__ << " on line " << __LINE__ << std::endl; \
86 AMP::plog << std::flush; \
96#define AMP_WARN_ONCE( MSG ) \
98 static bool printed = false; \
100 AMP_WARNING( MSG ); \
114#define AMP_ASSERT( EXP ) \
117 StackTrace::Utilities::abort( "Failed assertion: " #EXP, SOURCE_LOCATION_CURRENT() ); \
131#define AMP_INSIST( EXP, MSG ) \
134 StackTrace::Utilities::abort( "Failed insist: " #EXP "\nMessage: " + \
135 std::string( MSG ), \
136 SOURCE_LOCATION_CURRENT() ); \
160#if ( defined( DEBUG ) || defined( _DEBUG ) ) && !defined( NDEBUG )
161 #define AMP_DEBUG_ASSERT( EXP ) AMP_ASSERT( EXP )
162 #define AMP_DEBUG_INSIST( EXP, MSG ) AMP_INSIST( EXP, MSG )
165 #define AMP_DEBUG_ASSERT( EXP ) \
168 #define AMP_DEBUG_INSIST( EXP, MSG ) \
185#ifndef DISABLE_WARNINGS
186 #if defined( _MSC_VER )
187 #define DISABLE_WARNINGS
188 #define ENABLE_WARNINGS
189 #elif defined( __clang__ )
190 #define DISABLE_WARNINGS \
191 _Pragma( "clang diagnostic push" ) \
192 _Pragma( "clang diagnostic ignored \"-Wall\"" ) \
193 _Pragma( "clang diagnostic ignored \"-Wextra\"" ) \
194 _Pragma( "clang diagnostic ignored \"-Wunused-private-field\"" ) \
195 _Pragma( "clang diagnostic ignored \"-Wdeprecated-declarations\"" ) \
196 _Pragma( "clang diagnostic ignored \"-Winteger-overflow\"" ) \
197 _Pragma( "clang diagnostic ignored \"-Winconsistent-missing-override\"" ) \
198 _Pragma( "clang diagnostic ignored \"-Wimplicit-int-float-conversion\"" )
199 #define ENABLE_WARNINGS _Pragma( "clang diagnostic pop" )
200 #elif defined( __INTEL_COMPILER )
201 #if defined ( __INTEL_LLVM_COMPILER )
203 #define DISABLE_WARNINGS \
204 _Pragma( "warning (push)" ) \
205 _Pragma( "clang diagnostic ignored \"-Wunused-lambda-capture\"" )
206 #define ENABLE_WARNINGS _Pragma( "warning(pop)" )
208 #define DISABLE_WARNINGS \
209 _Pragma( "warning (push)" ) \
210 _Pragma( "warning disable 488" ) \
211 _Pragma( "warning disable 1011" ) \
212 _Pragma( "warning disable 61" ) \
213 _Pragma( "warning disable 1478" ) \
214 _Pragma( "warning disable 488" ) \
215 _Pragma( "warning disable 2651" )
216 #define ENABLE_WARNINGS _Pragma( "warning(pop)" )
218 #elif defined( __GNUC__ )
219 #define DISABLE_WARNINGS \
220 _Pragma( "GCC diagnostic push" ) \
221 _Pragma( "GCC diagnostic ignored \"-Wpragmas\"" ) \
222 _Pragma( "GCC diagnostic ignored \"-Wcpp\"" ) \
223 _Pragma( "GCC diagnostic ignored \"-Wall\"" ) \
224 _Pragma( "GCC diagnostic ignored \"-Wextra\"" ) \
225 _Pragma( "GCC diagnostic ignored \"-Wpedantic\"" ) \
226 _Pragma( "GCC diagnostic ignored \"-Wunused-local-typedefs\"" ) \
227 _Pragma( "GCC diagnostic ignored \"-Woverloaded-virtual\"" ) \
228 _Pragma( "GCC diagnostic ignored \"-Wunused-parameter\"" ) \
229 _Pragma( "GCC diagnostic ignored \"-Wdeprecated-copy\"" ) \
230 _Pragma( "GCC diagnostic ignored \"-Wdeprecated-declarations\"" ) \
231 _Pragma( "GCC diagnostic ignored \"-Wvirtual-move-assign\"" ) \
232 _Pragma( "GCC diagnostic ignored \"-Wunused-function\"" ) \
233 _Pragma( "GCC diagnostic ignored \"-Woverflow\"" ) \
234 _Pragma( "GCC diagnostic ignored \"-Wunused-variable\"" ) \
235 _Pragma( "GCC diagnostic ignored \"-Wignored-qualifiers\"" ) \
236 _Pragma( "GCC diagnostic ignored \"-Wenum-compare\"" ) \
237 _Pragma( "GCC diagnostic ignored \"-Wsign-compare\"" ) \
238 _Pragma( "GCC diagnostic ignored \"-Wterminate\"" ) \
239 _Pragma( "GCC diagnostic ignored \"-Wimplicit-fallthrough\"" ) \
240 _Pragma( "GCC diagnostic ignored \"-Wmaybe-uninitialized\"" ) \
241 _Pragma( "GCC diagnostic ignored \"-Winaccessible-base\"" ) \
242 _Pragma( "GCC diagnostic ignored \"-Wclass-memaccess\"" ) \
243 _Pragma( "GCC diagnostic ignored \"-Wcast-function-type\"" ) \
244 _Pragma( "GCC diagnostic ignored \"-Waggressive-loop-optimizations\"" )
245 #define ENABLE_WARNINGS _Pragma( "GCC diagnostic pop" )
247 #define DISABLE_WARNINGS
248 #define ENABLE_WARNINGS
constexpr bool failed_assert_v
Array< TYPE, FUN, Allocator > operator+(const Array< TYPE, FUN, Allocator > &a, const Array< TYPE, FUN, Allocator > &b)
void abort(const std::string &message, const source_location &source)