aboutsummaryrefslogtreecommitdiff
path: root/src/core/CPP
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2021-06-09 10:08:27 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-06-15 17:57:39 +0000
commit08302c17cd57356b35d46e17dc8d8f76672da5cf (patch)
tree3fed9bea3586bc140cc953e935f6ed55e8692dac /src/core/CPP
parent450dfb1b4d719d60295bfae56f4c46dcaf044d72 (diff)
downloadComputeLibrary-08302c17cd57356b35d46e17dc8d8f76672da5cf.tar.gz
Add CPU discovery capabilities.
Resolves: COMPMID-4500 Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Change-Id: I008c51934ef813fb1f489b531288c4419e701955 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5799 Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/CPP')
-rw-r--r--src/core/CPP/CPPTypes.cpp92
1 files changed, 27 insertions, 65 deletions
diff --git a/src/core/CPP/CPPTypes.cpp b/src/core/CPP/CPPTypes.cpp
index 0850df29fd..edcb9cb1ba 100644
--- a/src/core/CPP/CPPTypes.cpp
+++ b/src/core/CPP/CPPTypes.cpp
@@ -25,105 +25,67 @@
#include "arm_compute/core/CPP/CPPTypes.h"
#include "arm_compute/core/Error.h"
+#include "src/common/cpuinfo/CpuInfo.h"
-#if !defined(BARE_METAL)
-#include <sched.h>
-#endif /* defined(BARE_METAL) */
-
-using namespace arm_compute;
-
-void CPUInfo::set_fp16(const bool fp16)
+namespace arm_compute
{
- _fp16 = fp16;
-}
-
-void CPUInfo::set_dotprod(const bool dotprod)
+struct CPUInfo::Impl
{
- _dotprod = dotprod;
-}
+ cpuinfo::CpuInfo info{};
+ unsigned int L1_cache_size = 32768;
+ unsigned int L2_cache_size = 262144;
+};
-void CPUInfo::set_sve(const bool sve)
+CPUInfo::CPUInfo()
+ : _impl(std::make_unique<Impl>())
{
- _sve = sve;
+ _impl->info = cpuinfo::CpuInfo::build();
}
-void CPUInfo::set_cpu_model(unsigned int cpuid, CPUModel model)
-{
- ARM_COMPUTE_ERROR_ON(cpuid >= _percpu.size());
- if(_percpu.size() > cpuid)
- {
- _percpu[cpuid] = model;
- }
-}
+CPUInfo::~CPUInfo() = default;
unsigned int CPUInfo::get_cpu_num() const
{
- return _percpu.size();
+ return _impl->info.num_cpus();
}
bool CPUInfo::has_sve() const
{
- return _sve;
+ return _impl->info.has_sve();
}
bool CPUInfo::has_fp16() const
{
- return _fp16;
-}
-
-bool CPUInfo::has_dotprod() const
-{
- return _dotprod;
-}
-
-CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const
-{
- if(cpuid < _percpu.size())
- {
- return _percpu[cpuid];
- }
- return CPUModel::GENERIC;
+ return _impl->info.has_fp16();
}
-unsigned int CPUInfo::get_L1_cache_size() const
+bool CPUInfo::has_bf16() const
{
- return _L1_cache_size;
+ return _impl->info.has_bf16();
}
-void CPUInfo::set_L1_cache_size(unsigned int size)
-{
- _L1_cache_size = size;
-}
-
-unsigned int CPUInfo::get_L2_cache_size() const
+bool CPUInfo::has_dotprod() const
{
- return _L2_cache_size;
+ return _impl->info.has_dotprod();
}
-void CPUInfo::set_L2_cache_size(unsigned int size)
+CPUModel CPUInfo::get_cpu_model() const
{
- _L2_cache_size = size;
+ return _impl->info.cpu_model();
}
-void CPUInfo::set_cpu_num(unsigned int cpu_count)
+CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const
{
- _percpu.resize(cpu_count);
+ return _impl->info.cpu_model(cpuid);
}
-CPUInfo::CPUInfo()
- : _percpu(1)
+unsigned int CPUInfo::get_L1_cache_size() const
{
- // The core library knows nothing about the CPUs so we set only 1 CPU to be generic.
- // The runtime NESCheduler will initialise this vector with the correct CPU models.
- // See void detect_cpus_configuration(CPUInfo &cpuinfo) in CPPUtils.h
- _percpu[0] = CPUModel::GENERIC;
+ return _impl->L1_cache_size;
}
-CPUModel CPUInfo::get_cpu_model() const
+unsigned int CPUInfo::get_L2_cache_size() const
{
-#if defined(BARE_METAL) || defined(__APPLE__) || (!defined(__arm__) && !defined(__aarch64__))
- return get_cpu_model(0);
-#else /* defined(BARE_METAL) || defined(__APPLE__) || (!defined(__arm__) && !defined(__aarch64__)) */
- return get_cpu_model(sched_getcpu());
-#endif /* defined(BARE_METAL) || defined(__APPLE__) || (!defined(__arm__) && !defined(__aarch64__)) */
+ return _impl->L2_cache_size;
}
+} // namespace arm_compute