Dynare++: use portable C++11 primitive for detecting the number of logical processors

time-shift
Sébastien Villemot 2019-04-01 15:10:37 +02:00
parent 7e46d8267c
commit a6ff8495cd
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 5 additions and 14 deletions

View File

@ -7,6 +7,7 @@
#include <cmath> #include <cmath>
#include <ctime> #include <ctime>
#include <limits> #include <limits>
#include <thread>
#ifndef _WIN32 #ifndef _WIN32
# include <sys/time.h> // For getrusage() # include <sys/time.h> // For getrusage()
@ -72,16 +73,6 @@ SystemResources::availablePhysicalPages()
#endif #endif
} }
long
SystemResources::onlineProcessors()
{
#ifndef _WIN32
return sysconf(_SC_NPROCESSORS_ONLN);
#else
return -1; // FIXME
#endif
}
long long
SystemResources::availableMemory() SystemResources::availableMemory()
{ {
@ -226,11 +217,12 @@ Journal::printHeader()
utsname info; utsname info;
uname(&info); uname(&info);
*this << info.sysname << " " << info.release << " " << info.version << " " *this << info.sysname << " " << info.release << " " << info.version << " "
<< info.machine << ", processors online: " << SystemResources::onlineProcessors(); << info.machine;
#else #else
*this << "(not implemented for MinGW)"; *this << "Windows";
#endif #endif
*this << "\n\nStart time: "; *this << ", processors online: " << std::thread::hardware_concurrency()
<< "\n\nStart time: ";
std::time_t t = std::time(nullptr); std::time_t t = std::time(nullptr);
*this << std::put_time(std::localtime(&t), "%c %Z") *this << std::put_time(std::localtime(&t), "%c %Z")
<< "\n\n" << "\n\n"

View File

@ -23,7 +23,6 @@ struct SystemResources
static long pageSize(); static long pageSize();
static long physicalPages(); static long physicalPages();
static long availablePhysicalPages(); static long availablePhysicalPages();
static long onlineProcessors();
static long availableMemory(); static long availableMemory();
double load_avg; double load_avg;