39 #if defined( _WIN32 ) || defined( _WIN64 ) 45 # include <sys/ioctl.h> 53 #ifdef GENESIS_PTHREADS 64 #if defined( DEBUG ) && defined( NDEBUG ) 65 static_assert(
false,
"Cannot compile with both DEBUG and NDEBUG flags set." );
68 #if ! defined( DEBUG ) && ! defined( NDEBUG ) 69 static_assert(
false,
"Cannot compile with neiher DEBUG nor NDEBUG flag set." );
78 random_seed( std::chrono::system_clock::now().time_since_epoch().count() );
88 for (
size_t i = 0; i < command_line_.size(); ++i) {
89 std::string a = command_line_[i];
90 ret += (i==0 ?
"" :
" ") + a;
98 command_line_.clear();
99 for (
int i = 0; i < argc; i++) {
100 command_line_.push_back(argv[i]);
111 #ifdef GENESIS_PTHREADS 112 number = std::thread::hardware_concurrency();
120 number_of_threads_ = number;
122 #if defined( GENESIS_OPENMP ) 125 omp_set_num_threads( number );
137 __cpuid_count( 1, 0, info[0], info[1], info[2], info[3] );
140 return (
bool) (info[3] & (0x1 << 28));
148 #if defined( GENESIS_OPENMP ) 153 return omp_get_max_threads();
158 #if defined( GENESIS_PTHREADS ) 163 auto const lcores = std::thread::hardware_concurrency();
165 return lcores / threads_per_core;
182 random_engine_.seed( seed );
192 #if defined( _WIN32 ) || defined( _WIN64 ) 193 return _isatty( _fileno( stdin ));
195 return isatty( fileno( stdin ));
201 #if defined( _WIN32 ) || defined( _WIN64 ) 202 return _isatty( _fileno( stdout ));
204 return isatty( fileno( stdout ));
210 #if defined( _WIN32 ) || defined( _WIN64 ) 211 return _isatty( _fileno( stderr ));
213 return isatty( fileno( stderr ));
219 #if defined( _WIN32 ) || defined( _WIN64 ) 221 CONSOLE_SCREEN_BUFFER_INFO csbi;
223 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
224 cols = csbi.srWindow.Right - csbi.srWindow.Left + 1;
225 rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
226 return { cols, rows };
231 ioctl( STDOUT_FILENO, TIOCGWINSZ, &w );
232 return { w.ws_col, w.ws_row };
263 #elif defined( NDEBUG ) 272 static const uint16_t e = 0x1000;
273 return 0 == *
reinterpret_cast< uint8_t const*
>( &e );
278 static const uint16_t e = 0x0001;
279 return 0 == *
reinterpret_cast< uint8_t const*
>( &e );
288 #elif defined __linux__ 290 #elif defined __APPLE__ 292 #elif defined __unix__ 301 #if defined(__clang__) 303 #elif defined(__ICC) || defined(__INTEL_COMPILER) 305 #elif defined(__GNUC__) || defined(__GNUG__) 307 #elif defined(__HP_cc) || defined(__HP_aCC) 309 #elif defined(__IBMCPP__) 311 #elif defined(_MSC_VER) 315 #elif defined(__SUNPRO_CC) 324 #if defined(__clang__) 325 return __clang_version__;
326 #elif defined(__ICC) || defined(__INTEL_COMPILER) 327 return __INTEL_COMPILER;
328 #elif defined(__GNUC__) || defined(__GNUG__) 333 #elif defined(__HP_cc) || defined(__HP_aCC) 335 #elif defined(__IBMCPP__) 337 #elif defined(_MSC_VER) 341 #elif defined(__SUNPRO_CC) 359 return std::string( __DATE__
" " __TIME__ );
364 #ifdef GENESIS_PTHREADS 373 #ifdef GENESIS_OPENMP 405 res +=
"Compile Time Options\n";
406 res +=
"=============================================\n\n";
407 res +=
"Platform: " +
platform() +
"\n";
411 res +=
"Endianness: " + std::string(
is_little_endian() ?
"little endian" :
"big endian" ) +
"\n";
412 res +=
"Using Pthreads: " + std::string(
using_pthreads() ?
"true" :
"false" ) +
"\n";
413 res +=
"Using OpenMP: " + std::string(
using_openmp() ?
"true" :
"false" ) +
"\n";
420 res +=
"Run Time Options\n";
421 res +=
"=============================================\n\n";
423 res +=
"Command line: " + ( cli_str.size() > 0 ? cli_str :
"(not available)" ) +
"\n";
unsigned long random_seed() const
Returns the random seed that was used to initialize the engine.
std::vector< std::string > command_line() const
Returns an array of strings containing the program's command line arguments.
static std::string cpp_version()
Return the CPP version that was used to compile genesis.
unsigned int guess_number_of_threads(bool use_openmp=true) const
Try to guess the number of hardware threads of the current system.
std::string info_run_time() const
Return a list of run time options.
static bool stderr_is_terminal()
Return true iff the standard error stream is a terminal, and false if not, i.e., if it is a file or a...
static bool using_zlib()
Return whether the binary was compiled using zlib.
static bool stdout_is_terminal()
Return true iff the standard output stream is a terminal, and false if not, i.e., if it is a file or ...
static std::string compiler_version()
Return the compiler version that was used to compile genesis.
static std::string platform()
Return the platform under which genesis was compiled.
static std::string compiler_family()
Return the compiler family (name) that was used to compile genesis.
static bool is_debug()
Return whether the binary was compiled with build type DEBUG.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
static std::pair< int, int > terminal_size()
Return the width and height of the terminal that is used to run the program, in number of columns and...
std::string info_compile_time() const
Return a list of compile time options.
bool hyperthreads_enabled() const
Try to get whether hyperthreads are enabled in the current system.
static bool using_openmp()
Return whether the binary was compiled using OpenMP.
static std::string compile_date_time()
Return the date and time when genesis was compiled.
unsigned int number_of_threads() const
Returns the number of threads.
static bool is_release()
Return whether the binary was compiled with build type RELEASE.
std::string command_line_string() const
Returns a string containing the program's command line arguments.
static bool stdin_is_terminal()
Return true iff the standard input stream is a terminal, and false if not, i.e., if it is a file or a...
static std::string build_type()
Return the build type that was used to compile the binary, i.e., "debug" or "release".
static bool is_big_endian()
Return whether the system uses big endian memory.
std::shared_ptr< BaseOutputTarget > to_string(std::string &target_string)
Obtain an output target for writing to a string.
std::string info() const
Return a list with compile time and run time options with their values.
static bool is_little_endian()
Return whether the system uses little endian memory.
static bool using_pthreads()
Return whether the binary was compiled using Pthreads.
Some stuff that is totally not imporatant, but nice.
std::string genesis_header()
Return the header for genesis.