Ocean
Ocean::Processor Class Reference

This class implements basic functions relating the system processor. More...

Inheritance diagram for Ocean::Processor:

Public Member Functions

unsigned int cores () const
 Returns the number of available processor cores. More...
 
ProcessorInstructions instructions ()
 Returns the supported instruction set of the processor. More...
 
bool forceCores (const unsigned int cores)
 Forces a user defined number of processor cores. More...
 
bool forceInstructions (const ProcessorInstructions instructions)
 Forces a user-defined processor instruction set. More...
 

Static Public Member Functions

static std::string brand ()
 Returns the processor's brand. More...
 
static unsigned int realCores ()
 Returns the number of available processor cores currently detectable. More...
 
static ProcessorInstructions realInstructions ()
 Returns the supported instruction set of the processor. More...
 
static std::string translateInstructions (const ProcessorInstructions instructions)
 Translates a set of processor instructions to a readable string. More...
 
template<bool tIndependentOfBinary>
static ProcessorInstructions bestInstructionGroup (const ProcessorInstructions instructions)
 Returns the best group of instructions value for a set of given processor instructions. More...
 
static bool isLittleEndian ()
 Returns whether the processor/system is using the little endian convention (like e.g., x86) or whether the big endian convention is used. More...
 
template<>
ProcessorInstructions bestInstructionGroup (const ProcessorInstructions instructions)
 
- Static Public Member Functions inherited from Ocean::Singleton< Processor >
static Processorget ()
 Returns a reference to the unique object. More...
 

Private Member Functions

 Processor ()
 Constructs a new processor object. More...
 

Static Private Member Functions

static unsigned int realCoresApple ()
 Returns the number of available processor cores currently detectable. More...
 
static std::string deviceModelAppleIOS ()
 Returns the device name of the Apple iOS device. More...
 
static constexpr ProcessorInstructions invalidProcessorInstructions ()
 Returns invalid processor instructions. More...
 

Private Attributes

unsigned int forcedCores_ = 0u
 Explicitly forced number of processor cores. More...
 
ProcessorInstructions forcedProcessorInstructions_ = invalidProcessorInstructions()
 Explicitly forced CPU instructions. More...
 
ProcessorInstructions processorInstructions_ = invalidProcessorInstructions()
 The real instructions of the processor. More...
 
Lock lock_
 The lock of the processor class. More...
 

Friends

class Singleton< Processor >
 

Additional Inherited Members

- Protected Member Functions inherited from Ocean::Singleton< Processor >
 Singleton ()=default
 Default constructor. More...
 

Detailed Description

This class implements basic functions relating the system processor.

Constructor & Destructor Documentation

◆ Processor()

Ocean::Processor::Processor ( )
private

Constructs a new processor object.

Member Function Documentation

◆ bestInstructionGroup() [1/2]

template<bool tIndependentOfBinary>
ProcessorInstructions Ocean::Processor::bestInstructionGroup ( const ProcessorInstructions  instructions)
inlinestatic

Returns the best group of instructions value for a set of given processor instructions.

The function may return the following groups in the following order: PI_GROUP_AVX_2_SSE_4_1, PI_GROUP_SSE_4_1, PI_GROUP_AVX_2_SSE_2, PI_GROUP_AVX_2, PI_GROUP_SSE_2, PI_GROUP_NEON.

Parameters
instructionsThe set of instructions for which the best group will be returned
Returns
The best group of instructions, PI_NONE if no group is matching
Template Parameters
tIndependentOfBinaryTrue, to return the best group without checking the binaries capabilities; False, to return groups which are supported by the current binary only

◆ bestInstructionGroup() [2/2]

template<>
ProcessorInstructions Ocean::Processor::bestInstructionGroup ( const ProcessorInstructions  instructions)
inlinestatic

◆ brand()

static std::string Ocean::Processor::brand ( )
static

Returns the processor's brand.

Returns
The processor's brand

◆ cores()

unsigned int Ocean::Processor::cores ( ) const
inline

Returns the number of available processor cores.

If an explicit number of processors has been forced by the user, the user defined number will be returned.

Returns
Number of processor cores
See also
realCores(), forceCores().

◆ deviceModelAppleIOS()

static std::string Ocean::Processor::deviceModelAppleIOS ( )
staticprivate

Returns the device name of the Apple iOS device.

Returns
The device name

◆ forceCores()

bool Ocean::Processor::forceCores ( const unsigned int  cores)

Forces a user defined number of processor cores.

The forced number will be returned instead of the real cores using the cores() function.

Parameters
coresNumber of cores to be forced, 0 to remove the previously forced core number
Returns
True, if succeeded
See also
cores().

◆ forceInstructions()

bool Ocean::Processor::forceInstructions ( const ProcessorInstructions  instructions)

Forces a user-defined processor instruction set.

The forced instruction set will be returned instead of the real instruction set using the instructions() function.

Parameters
instructionsThe instruction set to be forced, -1 to remove the previously forced instruction set
Returns
True, if succeeded
See also
instructions().

◆ instructions()

ProcessorInstructions Ocean::Processor::instructions ( )
inline

Returns the supported instruction set of the processor.

If an explicit instruction set has been forced by the user, the user defined instruction set will be returned.

Returns
Instruction set of the processor
See also
realInstructions(), forceInstructions().

◆ invalidProcessorInstructions()

constexpr ProcessorInstructions Ocean::Processor::invalidProcessorInstructions ( )
staticconstexprprivate

Returns invalid processor instructions.

Returns
Invalid instructions

◆ isLittleEndian()

bool Ocean::Processor::isLittleEndian ( )
inlinestatic

Returns whether the processor/system is using the little endian convention (like e.g., x86) or whether the big endian convention is used.

Returns
True, if the little endian convention is used

◆ realCores()

static unsigned int Ocean::Processor::realCores ( )
static

Returns the number of available processor cores currently detectable.

Returns
Number of processor cores
See also
cores().

◆ realCoresApple()

static unsigned int Ocean::Processor::realCoresApple ( )
staticprivate

Returns the number of available processor cores currently detectable.

Returns
Number of processor cores
See also
realCores().

◆ realInstructions()

static ProcessorInstructions Ocean::Processor::realInstructions ( )
static

Returns the supported instruction set of the processor.

Returns
The supported set of instructions
See also
instructions().

◆ translateInstructions()

static std::string Ocean::Processor::translateInstructions ( const ProcessorInstructions  instructions)
static

Translates a set of processor instructions to a readable string.

Parameters
instructionsThe instructions to be translated
Returns
The resulting string containing the instruction names, 'No SIMD Instructions' if no instruction is specified

Friends And Related Function Documentation

◆ Singleton< Processor >

friend class Singleton< Processor >
friend

Field Documentation

◆ forcedCores_

unsigned int Ocean::Processor::forcedCores_ = 0u
private

Explicitly forced number of processor cores.

◆ forcedProcessorInstructions_

ProcessorInstructions Ocean::Processor::forcedProcessorInstructions_ = invalidProcessorInstructions()
private

Explicitly forced CPU instructions.

◆ lock_

Lock Ocean::Processor::lock_
mutableprivate

The lock of the processor class.

◆ processorInstructions_

ProcessorInstructions Ocean::Processor::processorInstructions_ = invalidProcessorInstructions()
private

The real instructions of the processor.


The documentation for this class was generated from the following file: