00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _CH_SYSTEM_H_
00012 #define _CH_SYSTEM_H_
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <cstring>
00023
00024 #include "CH_config.H"
00025 #include "BaseNamespaceHeader.H"
00026
00027 namespace CHSystem
00028 {
00029
00030 int fileExists(const char *const a_filename);
00031
00032
00033 int memalign(void **a_memptr, size_t a_alignment, size_t a_size);
00034
00035
00036
00037
00038
00039
00040
00041
00042 inline int popcnt(unsigned i)
00043 {
00044 #if CHDEF_SYSTEM_POPCNT_METHOD == 1
00045 int ret;
00046 __asm__ ("popcnt %1, %0" : "=r" (ret) : "r" (i));
00047 return ret;
00048 #else
00049
00050 i = i - ((i >> 1) & 0x55555555);
00051 i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
00052 return (((i + (i >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
00053 #endif
00054 }
00055 }
00056
00057
00058 #define BOOST_PP_STRINGIZE_(expr) #expr
00059 #define BOOST_PP_STRINGIZE(expr) BOOST_PP_STRINGIZE_(expr)
00060
00061
00062 #define BOOST_PRAGMA(args) _Pragma(BOOST_PP_STRINGIZE(args))
00063 #if defined(__INTEL_COMPILER)
00064 #define BOOST_BUILTIN_ASSUME(expr) \
00065 __assume(expr) \
00066
00067 #define BOOST_BUILTIN_ASSUME_ALIGNED(ptr, align) \
00068 __assume_aligned(ptr, align) \
00069
00070 #elif defined(__clang__)
00071 #define BOOST_BUILTIN_ASSUME(expr) \
00072 __builtin_assume(expr) \
00073
00074 #define BOOST_BUILTIN_ASSUME_ALIGNED(ptr, align) \
00075 { \
00076 ptr = reinterpret_cast<decltype(ptr)>( \
00077 __builtin_assume_aligned(ptr, align) \
00078 ); \
00079 } \
00080
00081 #else // GCC
00082 #define BOOST_BUILTIN_ASSUME(expr) \
00083 do { if (!(expr)) __builtin_unreachable(); } while (0) \
00084
00085 #define BOOST_BUILTIN_ASSUME_ALIGNED(ptr, align) \
00086 { \
00087 ptr = reinterpret_cast<decltype(ptr)>( \
00088 __builtin_assume_aligned(ptr, align) \
00089 ); \
00090 } \
00091
00092 #endif
00093 #if defined(__INTEL_COMPILER)
00094 #define BOOST_DEMAND_VECTORIZATION \
00095 BOOST_PRAGMA(simd) \
00096
00097 #elif defined(__clang__)
00098 #define BOOST_DEMAND_VECTORIZATION \
00099 BOOST_PRAGMA(clang loop vectorize(enable) interleave(enable)) \
00100
00101 #else
00102 #define BOOST_DEMAND_VECTORIZATION \
00103 BOOST_PRAGMA(GCC ivdep) \
00104
00105 #endif
00106
00107 #include "BaseNamespaceFooter.H"
00108 #endif