Matrix Science header

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: /vol/cvsroot/parser/examples/test_cxx/config_procs.cpp,v $ #
#     $Author: davidc $                                                      #
#       $Date: 2005/01/19 15:17:53 $                                         #
#   $Revision: 1.2 $                                                         #
# $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

*/

Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:50