diff options
Diffstat (limited to 'src/core/CPP/CPPTypes.cpp')
-rw-r--r-- | src/core/CPP/CPPTypes.cpp | 114 |
1 files changed, 67 insertions, 47 deletions
diff --git a/src/core/CPP/CPPTypes.cpp b/src/core/CPP/CPPTypes.cpp index 139e106ca6..9980db42f3 100644 --- a/src/core/CPP/CPPTypes.cpp +++ b/src/core/CPP/CPPTypes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021 Arm Limited. + * Copyright (c) 2018-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -26,93 +26,113 @@ #include "arm_compute/core/Error.h" -#if !defined(BARE_METAL) -#include <sched.h> -#endif /* defined(BARE_METAL) */ +#include "src/common/cpuinfo/CpuInfo.h" +#include "src/common/cpuinfo/CpuIsaInfo.h" -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; +}; -void CPUInfo::set_dotprod(const bool dotprod) +CPUInfo &CPUInfo::get() { - _dotprod = dotprod; + static CPUInfo _cpuinfo; + return _cpuinfo; } -void CPUInfo::set_cpu_model(unsigned int cpuid, CPUModel model) +CPUInfo::CPUInfo() : _impl(std::make_unique<Impl>()) { - ARM_COMPUTE_ERROR_ON(cpuid >= _percpu.size()); - if(_percpu.size() > cpuid) - { - _percpu[cpuid] = model; - } + _impl->info = cpuinfo::CpuInfo::build(); } +CPUInfo::~CPUInfo() = default; + unsigned int CPUInfo::get_cpu_num() const { - return _percpu.size(); + return _impl->info.num_cpus(); } + 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_svebf16() const +{ + return _impl->info.has_svebf16(); } bool CPUInfo::has_dotprod() const { - return _dotprod; + return _impl->info.has_dotprod(); } -CPUModel CPUInfo::get_cpu_model(unsigned int cpuid) const +bool CPUInfo::has_svef32mm() const { - if(cpuid < _percpu.size()) - { - return _percpu[cpuid]; - } - return CPUModel::GENERIC; + return _impl->info.has_svef32mm(); } -unsigned int CPUInfo::get_L1_cache_size() const +bool CPUInfo::has_i8mm() const { - return _L1_cache_size; + return _impl->info.has_i8mm(); } -void CPUInfo::set_L1_cache_size(unsigned int size) +bool CPUInfo::has_svei8mm() const { - _L1_cache_size = size; + return _impl->info.has_svei8mm(); } -unsigned int CPUInfo::get_L2_cache_size() const +bool CPUInfo::has_sve() const { - return _L2_cache_size; + return _impl->info.has_sve(); } -void CPUInfo::set_L2_cache_size(unsigned int size) +bool CPUInfo::has_sve2() const { - _L2_cache_size = size; + return _impl->info.has_sve2(); } -void CPUInfo::set_cpu_num(unsigned int cpu_count) +bool CPUInfo::has_sme() const { - _percpu.resize(cpu_count); + return _impl->info.has_sme(); } -CPUInfo::CPUInfo() - : _percpu(1) +bool CPUInfo::has_sme2() 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->info.has_sme2(); } 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); +} + +cpuinfo::CpuIsaInfo CPUInfo::get_isa() const +{ + return _impl->info.isa(); +} + +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 |