11 #ifndef MCL_MCLTYPES_H
12 #define MCL_MCLTYPES_H
15 #define PI 3.141592653589793238462643383279502884197169399375105820974944
18 #define ASSERT(arg) assert(arg)
19 #define ASSERT_WITH_MESSAGE(condition, message) ASSERT(condition && message)
20 #define AVOID_UNUSED_WARNING(arg) (void)(arg);
30 #define MCL_ENV64BIT 1
32 #define MCL_ENV32BIT 1
35 #if __x86_64__ || __ppc64__
36 #define MCL_ENV64BIT 1
38 #define MCL_ENV32BIT 1
44 #define MCL_ENVWINDOWS 1
46 #define MCL_ENVAPPLE 1
47 #elif __arm__ || __aarch64__ // Since this elif comes second, priority is given to APPLE descriptor
50 #define MCL_ENVOTHER 1
54 #define MCL_APPLE_ACCELERATE 1
56 #define MCL_NEON_ACCELERATE 1
58 #define MCL_AVX_ACCELERATE 1
60 #define MCL_NO_ACCELERATE 1
64 #define MCL_APPLE_ACCELERATE_MMA 0
66 #define MCL_MAX_VLA_LENGTH 16384
69 #define MCL_STACK_ALLOCATE(type, variable, size) type* variable = (type*)alloca((size)*sizeof(type));
71 #define MCL_STACK_ALLOCATE(type, variable, size) type variable[(size)];
80 #define MCL_DATA_TYPE_DOUBLE 1
82 #if MCL_DATA_TYPE_DOUBLE
91 typedef unsigned long long UInt;
92 typedef long long Int;
93 #else // If it is 32 bits or unknown then...
94 typedef unsigned long UInt;
108 #if defined(MCL_ENVWINDOWS)
109 if (! system_has_been_polled_) {
111 __cpuid(cpu_info, 0);
112 if (cpu_info[0] >= 1) {
113 __cpuidex(cpu_info, 1, 0);
114 if ((cpu_info[2] & (1 << 28)) != 0) {
115 avx_supported_ =
true;
118 system_has_been_polled_ =
true;
122 return avx_supported_;
126 bool avx_supported_ =
false;
127 bool system_has_been_polled_ =
false;
147 std::cerr<<output<<std::endl;
151 std::cerr<<output<<std::endl;
155 if (output_type_ ==
kNone) {
return; }
157 const size_t SIZE = snprintf( NULL, 0,
"%s", format);
160 output.resize(SIZE+1);
161 snprintf( &(output[0]), SIZE+1,
"%s", format);
163 if (output_type_ ==
kCerr) {
164 std::cerr<<output<<std::endl;
166 log_string_.append(
"\n");
167 log_string_.append(format);
171 template<
typename... argv >
173 if (output_type_ ==
kNone) {
return; }
175 const size_t SIZE = snprintf( NULL, 0, format, args... );
178 output.resize(SIZE+1);
179 snprintf( &(output[0]), SIZE+1, format, args... );
181 if (output_type_ ==
kCerr) {
182 std::cerr<<output<<std::endl;
184 log_string_.append(
"\n");
185 log_string_.append(format);
190 output_type_ = output_type;
194 log_output_file_ = log_output_file;
198 Logger() : output_type_(
kCerr), log_output_file_(
"err.log") {}
200 if (log_string_.length() > 0) {
201 std::cerr<<
"Writing logger out to "<<log_output_file_<<std::endl;
202 std::ofstream output_stream(log_output_file_);
203 output_stream<<log_string_;
204 output_stream.close();
208 Logger(
const Logger&) =
delete;
209 const Logger& operator= (
const Logger&) =
delete;
213 std::string log_string_;
214 std::string log_output_file_;