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>
diff --git a/src/core/CPP/CPPTypes.cpp b/src/core/CPP/CPPTypes.cpp
index 0850df2..edcb9cb 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;
+struct CPUInfo::Impl
+{
+    cpuinfo::CpuInfo info{};
+    unsigned int     L1_cache_size = 32768;
+    unsigned int     L2_cache_size = 262144;
+};
+
+CPUInfo::CPUInfo()
+    : _impl(std::make_unique<Impl>())
+{
+    _impl->info = cpuinfo::CpuInfo::build();
 }
 
-void CPUInfo::set_dotprod(const bool dotprod)
-{
-    _dotprod = dotprod;
-}
-
-void CPUInfo::set_sve(const bool sve)
-{
-    _sve = sve;
-}
-
-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;
+    return _impl->info.has_fp16();
+}
+
+bool CPUInfo::has_bf16() const
+{
+    return _impl->info.has_bf16();
 }
 
 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;
-}
-
-unsigned int CPUInfo::get_L1_cache_size() const
-{
-    return _L1_cache_size;
-}
-
-void CPUInfo::set_L1_cache_size(unsigned int size)
-{
-    _L1_cache_size = size;
-}
-
-unsigned int CPUInfo::get_L2_cache_size() const
-{
-    return _L2_cache_size;
-}
-
-void CPUInfo::set_L2_cache_size(unsigned int size)
-{
-    _L2_cache_size = size;
-}
-
-void CPUInfo::set_cpu_num(unsigned int cpu_count)
-{
-    _percpu.resize(cpu_count);
-}
-
-CPUInfo::CPUInfo()
-    : _percpu(1)
-{
-    // 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->info.has_dotprod();
 }
 
 CPUModel CPUInfo::get_cpu_model() 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->info.cpu_model();
 }
+
+CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const
+{
+    return _impl->info.cpu_model(cpuid);
+}
+
+unsigned int CPUInfo::get_L1_cache_size() const
+{
+    return _impl->L1_cache_size;
+}
+
+unsigned int CPUInfo::get_L2_cache_size() const
+{
+    return _impl->L2_cache_size;
+}
+} // namespace arm_compute
diff --git a/src/core/cpu/kernels/assembly/arm_gemm.hpp b/src/core/cpu/kernels/assembly/arm_gemm.hpp
index 624e9e9..81e355d 100644
--- a/src/core/cpu/kernels/assembly/arm_gemm.hpp
+++ b/src/core/cpu/kernels/assembly/arm_gemm.hpp
@@ -25,6 +25,7 @@
 
 #include <cstring>
 #include <memory>
+#include <vector>
 
 #include "arm_gemm_local.hpp"
 #include "gemm_common.hpp"