Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
config_procs.cpp

Determine computer processor information.

/*
##############################################################################
# file: config_procs.cpp #
# 'msparser' toolkit example code #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998-2005 Matrix Science Limited All Rights Reserved. #
# #
##############################################################################
# $Source: parser/examples/test_cxx/config_procs.cpp $ #
# $Author: villek@matrixscience.com $ #
# $Date: 2018-07-30 16:23:53 +0100 $ #
# $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $ #
# $NoKeywords:: $ #
##############################################################################
*/
#include "msparser.hpp"
#include <iostream>
// All the classes are part of the matrix_science namespace
using namespace matrix_science;
int main(int argc, char * argv[])
{
// Don't check for Linux hyperthreading, assume 4 cpu license
ms_processors cpus(false, 1);
if ( !cpus.isValid() )
{
std::cout << "There are errors. Cannot continue. The last error description:" << std::endl;
std::cout << cpus.getLastErrorString() << std::endl;
return 1;
}
std::cout << "Number of CPUS available on the system: " << cpus.getNumOnSystem() << std::endl;
return 0;
}
/*
will give the output, for instance:
# config_procs
Number of CPUS available on the system: 2
*/
std::string getLastErrorString() const
Return the error description of the last error that occurred.
Definition: ms_errors.cpp:1488
bool isValid() const
Call this function to determine if there have been any errors.
Definition: ms_errors.cpp:1472
This class is designed to retrieve current CPU configuration on the computer and set affinity.
Definition: ms_processors.hpp:50
int getNumOnSystem() const
Returns the number of logical CPUs installed in the system.
Definition: ms_processors.cpp:69