Compute Library
 19.08
CPUInfo Class Referencefinal

#include <CPPTypes.h>

Public Member Functions

 CPUInfo ()
 Constructor. More...
 
CPUInfooperator= (const CPUInfo &cpuinfo)=delete
 Disable copy constructor and assignment operator to avoid copying the vector of CPUs each time CPUInfo is initialized once in the IScheduler and ThreadInfo will get a pointer to it. More...
 
 CPUInfo (const CPUInfo &cpuinfo)=delete
 
CPUInfooperator= (const CPUInfo &&cpuinfo)=delete
 
 CPUInfo (const CPUInfo &&cpuinfo)=delete
 
bool has_fp16 () const
 Checks if the cpu model supports fp16. More...
 
bool has_dotprod () const
 Checks if the cpu model supports dot product. More...
 
CPUModel get_cpu_model (unsigned int cpuid) const
 Gets the cpu model for a given cpuid. More...
 
CPUModel get_cpu_model () const
 Gets the current thread's cpu model. More...
 
unsigned int get_L1_cache_size () const
 Gets the L1 cache size. More...
 
unsigned int get_L2_cache_size () const
 Gets the L2 cache size. More...
 
void set_L1_cache_size (unsigned int size)
 Set the L1 cache size. More...
 
void set_L2_cache_size (unsigned int size)
 Set the L2 cache size. More...
 
void set_fp16 (const bool fp16)
 Set fp16 support. More...
 
void set_dotprod (const bool dotprod)
 Set dot product support. More...
 
void set_cpu_model (unsigned int cpuid, CPUModel model)
 Set the cpumodel for a given cpu core. More...
 
void set_cpu_num (unsigned int cpu_count)
 Set max number of cpus. More...
 
unsigned int get_cpu_num () const
 Return the maximum number of CPUs present. More...
 

Detailed Description

Definition at line 105 of file CPPTypes.h.

Constructor & Destructor Documentation

◆ CPUInfo() [1/3]

CPUInfo ( )

Constructor.

Definition at line 102 of file CPPTypes.cpp.

103  : _percpu(1)
104 {
105  // The core library knows nothing about the CPUs so we set only 1 CPU to be generic.
106  // The runtime NESCheduler will initialise this vector with the correct CPU models.
107  // See void detect_cpus_configuration(CPUInfo &cpuinfo) in CPPUtils.h
108  _percpu[0] = CPUModel::GENERIC;
109 }

References arm_compute::GENERIC.

◆ CPUInfo() [2/3]

CPUInfo ( const CPUInfo cpuinfo)
delete

◆ CPUInfo() [3/3]

CPUInfo ( const CPUInfo &&  cpuinfo)
delete

Member Function Documentation

◆ get_cpu_model() [1/2]

CPUModel get_cpu_model ( unsigned int  cpuid) const

Gets the cpu model for a given cpuid.

Parameters
[in]cpuidthe id of the cpu core to be retrieved,
Returns
the CPUModel of the cpuid queiried.

Definition at line 68 of file CPPTypes.cpp.

69 {
70  if(cpuid < _percpu.size())
71  {
72  return _percpu[cpuid];
73  }
74  return CPUModel::GENERIC;
75 }

References arm_compute::GENERIC.

Referenced by main().

◆ get_cpu_model() [2/2]

CPUModel get_cpu_model ( ) const

Gets the current thread's cpu model.

Returns
Current thread's CPUModel

Definition at line 111 of file CPPTypes.cpp.

112 {
113 #if defined(BARE_METAL) || (!defined(__arm__) && !defined(__aarch64__))
114  return get_cpu_model(0);
115 #else /* defined(BARE_METAL) || (!defined(__arm__) && !defined(__aarch64__)) */
116  return get_cpu_model(sched_getcpu());
117 #endif /* defined(BARE_METAL) || (!defined(__arm__) && !defined(__aarch64__)) */
118 }
CPUModel get_cpu_model() const
Gets the current thread's cpu model.
Definition: CPPTypes.cpp:111

◆ get_cpu_num()

unsigned int get_cpu_num ( ) const

Return the maximum number of CPUs present.

Returns
Number of CPUs

Definition at line 54 of file CPPTypes.cpp.

55 {
56  return _percpu.size();
57 }

Referenced by main().

◆ get_L1_cache_size()

unsigned int get_L1_cache_size ( ) const

Gets the L1 cache size.

Returns
the size of the L1 cache

Definition at line 77 of file CPPTypes.cpp.

78 {
79  return _L1_cache_size;
80 }

◆ get_L2_cache_size()

unsigned int get_L2_cache_size ( ) const

Gets the L2 cache size.

Returns
the size of the L1 cache

Definition at line 87 of file CPPTypes.cpp.

88 {
89  return _L2_cache_size;
90 }

◆ has_dotprod()

bool has_dotprod ( ) const

Checks if the cpu model supports dot product.

Returns
true of the cpu supports dot product, false otherwise

Definition at line 63 of file CPPTypes.cpp.

64 {
65  return _dotprod;
66 }

Referenced by main().

◆ has_fp16()

bool has_fp16 ( ) const

Checks if the cpu model supports fp16.

Returns
true of the cpu supports fp16, false otherwise

Definition at line 58 of file CPPTypes.cpp.

59 {
60  return _fp16;
61 }

Referenced by main().

◆ operator=() [1/2]

CPUInfo& operator= ( const CPUInfo cpuinfo)
delete

Disable copy constructor and assignment operator to avoid copying the vector of CPUs each time CPUInfo is initialized once in the IScheduler and ThreadInfo will get a pointer to it.

◆ operator=() [2/2]

CPUInfo& operator= ( const CPUInfo &&  cpuinfo)
delete

◆ set_cpu_model()

void set_cpu_model ( unsigned int  cpuid,
CPUModel  model 
)

Set the cpumodel for a given cpu core.

Parameters
[in]cpuidthe id of the core to be set.
[in]modelthe CPUModel to be set.

Definition at line 45 of file CPPTypes.cpp.

46 {
47  ARM_COMPUTE_ERROR_ON(cpuid >= _percpu.size());
48  if(_percpu.size() > cpuid)
49  {
50  _percpu[cpuid] = model;
51  }
52 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337

References ARM_COMPUTE_ERROR_ON.

Referenced by arm_compute::get_cpu_configuration().

◆ set_cpu_num()

void set_cpu_num ( unsigned int  cpu_count)

Set max number of cpus.

Parameters
[in]cpu_countthe number of CPUs in the system.

Definition at line 97 of file CPPTypes.cpp.

98 {
99  _percpu.resize(cpu_count);
100 }

Referenced by arm_compute::get_cpu_configuration().

◆ set_dotprod()

void set_dotprod ( const bool  dotprod)

Set dot product support.

Parameters
[in]dotprodwhether the cpu supports dot product.

Definition at line 40 of file CPPTypes.cpp.

41 {
42  _dotprod = dotprod;
43 }

Referenced by arm_compute::get_cpu_configuration().

◆ set_fp16()

void set_fp16 ( const bool  fp16)

Set fp16 support.

Parameters
[in]fp16whether the cpu supports fp16.

Definition at line 35 of file CPPTypes.cpp.

36 {
37  _fp16 = fp16;
38 }

Referenced by arm_compute::get_cpu_configuration().

◆ set_L1_cache_size()

void set_L1_cache_size ( unsigned int  size)

Set the L1 cache size.

Parameters
[in]sizethe new size to be set.

Definition at line 82 of file CPPTypes.cpp.

83 {
84  _L1_cache_size = size;
85 }

◆ set_L2_cache_size()

void set_L2_cache_size ( unsigned int  size)

Set the L2 cache size.

Parameters
[in]sizethe new size to be set.

Definition at line 92 of file CPPTypes.cpp.

93 {
94  _L2_cache_size = size;
95 }

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