aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Al Khatib <omar.alkhatib@arm.com>2024-05-21 15:07:09 +0100
committerPablo Marquez Tello <pablo.tello@arm.com>2024-05-21 16:15:59 +0000
commit1d2733e35deb9ddbdde5521b1f5b0511085a3702 (patch)
tree98e1abf3e615f04e9de3e7c3864eb014d89a8e8c
parentf5053f782daa942126bd61ac1bcfc0af627b7b31 (diff)
downloadComputeLibrary-1d2733e35deb9ddbdde5521b1f5b0511085a3702.tar.gz
Fix issues with OpenMP scheduler little core exclusion.
1. Remove unnecessary restriction to the exclusion only running on systems with little mid and big cores. 2. Allow override of the suggested number of threads in case the user sets the number of threads to a lower value. Resolves [COMPMID-7014] Signed-off-by: Omar Al Khatib <omar.alkhatib@arm.com> Change-Id: Ifb76ef4454f38dd2e3e5781b5dfea07c044aeb74 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/11604 Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com>
-rw-r--r--arm_compute/core/CPP/CPPTypes.h7
-rw-r--r--arm_compute/runtime/OMP/OMPScheduler.h1
-rw-r--r--src/common/cpuinfo/CpuInfo.cpp50
-rw-r--r--src/common/cpuinfo/CpuInfo.h1
-rw-r--r--src/core/CPP/CPPTypes.cpp8
-rw-r--r--src/runtime/OMP/OMPScheduler.cpp7
-rw-r--r--tests/validation/NEON/UNIT/RuntimeContext.cpp7
7 files changed, 3 insertions, 78 deletions
diff --git a/arm_compute/core/CPP/CPPTypes.h b/arm_compute/core/CPP/CPPTypes.h
index e5322bdcb1..c97751bc0c 100644
--- a/arm_compute/core/CPP/CPPTypes.h
+++ b/arm_compute/core/CPP/CPPTypes.h
@@ -176,13 +176,6 @@ public:
* @return Number of CPUs excluding little
*/
unsigned int get_cpu_num_excluding_little() const;
- /** Return whether the device has little, medium and big CPUs in case
- * of an Android device, returns false otherwise
- *
- * @return Whether the device has little, medium and big CPUs
- */
- bool cpu_has_little_mid_big() const;
-
/** Return the vector length in bytes for sme2
*
* @return Vector length if sme2 is enabled, otherwise returns 0.
diff --git a/arm_compute/runtime/OMP/OMPScheduler.h b/arm_compute/runtime/OMP/OMPScheduler.h
index c718e74359..9b39714fea 100644
--- a/arm_compute/runtime/OMP/OMPScheduler.h
+++ b/arm_compute/runtime/OMP/OMPScheduler.h
@@ -79,7 +79,6 @@ protected:
private:
unsigned int _num_threads;
- bool _has_lmb;
unsigned int _nonlittle_num_cpus;
};
} // namespace arm_compute
diff --git a/src/common/cpuinfo/CpuInfo.cpp b/src/common/cpuinfo/CpuInfo.cpp
index 92ba5223c9..d46d8d7773 100644
--- a/src/common/cpuinfo/CpuInfo.cpp
+++ b/src/common/cpuinfo/CpuInfo.cpp
@@ -270,12 +270,6 @@ int get_max_cpus()
}
return max_cpus;
}
-
-const static std::map<std::string, std::vector<uint32_t>> known_configurations_with_little_cores = {
- {"xiaomi14-pro", {379, 379, 923, 923, 923, 867, 867, 1024}}};
-
-const static std::map<std::string, uint32_t> number_of_cores_to_use = {{"xiaomi14-pro", 6}};
-
#if defined(__ANDROID__)
std::vector<uint32_t> get_cpu_capacities()
{
@@ -303,14 +297,6 @@ uint32_t not_little_num_cpus_internal()
std::vector<uint32_t> cpus_all = get_cpu_capacities();
std::vector<uint32_t> cpus_not_little;
- for (auto &it : known_configurations_with_little_cores)
- {
- if (it.second == cpus_all)
- {
- return number_of_cores_to_use.find(it.first)->second;
- }
- }
-
std::vector<uint32_t>::iterator result = std::max_element(cpus_all.begin(), cpus_all.end());
uint32_t max_capacity = *result;
uint32_t threshold = max_capacity / 2;
@@ -323,33 +309,6 @@ uint32_t not_little_num_cpus_internal()
}
return cpus_not_little.size();
}
-
-bool has_little_mid_big_internal()
-{
- std::vector<uint32_t> cpus_all = get_cpu_capacities();
- std::vector<uint32_t> cpus_not_little;
-
- for (auto &it : known_configurations_with_little_cores)
- {
- if (it.second == cpus_all)
- {
- return true;
- }
- }
- std::sort(cpus_all.begin(), cpus_all.end());
- std::vector<uint32_t>::iterator ip;
- ip = std::unique(cpus_all.begin(), cpus_all.end());
- cpus_all.resize(std::distance(cpus_all.begin(), ip));
-
- if (cpus_all.size() == 3)
- {
- return true;
- }
- else
- {
- return false;
- }
-}
#endif /* defined(__ANDROID__) */
#elif defined(__aarch64__) && \
defined(__APPLE__) /* !defined(BARE_METAL) && !defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__)) */
@@ -493,15 +452,6 @@ uint32_t CpuInfo::not_little_num_cpus() const
#endif /* defined(__ANDROID__) */
}
-bool CpuInfo::has_little_mid_big() const
-{
-#if defined(__ANDROID__)
- return has_little_mid_big_internal();
-#else /* defined(__ANDROID__) */
- return false;
-#endif /* defined(__ANDROID__) */
-}
-
uint32_t num_threads_hint()
{
unsigned int num_threads_hint = 1;
diff --git a/src/common/cpuinfo/CpuInfo.h b/src/common/cpuinfo/CpuInfo.h
index 506830aa81..78d11e9610 100644
--- a/src/common/cpuinfo/CpuInfo.h
+++ b/src/common/cpuinfo/CpuInfo.h
@@ -121,7 +121,6 @@ public:
CpuModel cpu_model() const;
uint32_t num_cpus() const;
uint32_t not_little_num_cpus() const;
- bool has_little_mid_big() const;
private:
CpuIsaInfo _isa{};
diff --git a/src/core/CPP/CPPTypes.cpp b/src/core/CPP/CPPTypes.cpp
index ef0518ed3d..67fbce490f 100644
--- a/src/core/CPP/CPPTypes.cpp
+++ b/src/core/CPP/CPPTypes.cpp
@@ -145,14 +145,6 @@ unsigned long CPUInfo::get_sme2_vector_length() const
return 0;
#endif // ARM_COMPUTE_ENABLE_SME2
}
-bool CPUInfo::cpu_has_little_mid_big() const
-{
-#if defined(__ANDROID__)
- return _impl->info.has_little_mid_big();
-#else /* defined(__ANDROID__) */
- return false;
-#endif /* defined(__ANDROID__) */
-}
unsigned int CPUInfo::get_cpu_num_excluding_little() const
{
#if defined(__ANDROID__)
diff --git a/src/runtime/OMP/OMPScheduler.cpp b/src/runtime/OMP/OMPScheduler.cpp
index 2a5abb5f7a..aba5ff2902 100644
--- a/src/runtime/OMP/OMPScheduler.cpp
+++ b/src/runtime/OMP/OMPScheduler.cpp
@@ -36,16 +36,13 @@ namespace arm_compute
(defined(__arm__) || defined(__aarch64__)) && defined(__ANDROID__)
OMPScheduler::OMPScheduler() // NOLINT
: _num_threads(cpu_info().get_cpu_num_excluding_little()),
- _has_lmb(cpu_info().cpu_has_little_mid_big()),
_nonlittle_num_cpus(cpu_info().get_cpu_num_excluding_little())
{
}
#else /* !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && \
(defined(__arm__) || defined(__aarch64__)) && defined(__ANDROID__)*/
OMPScheduler::OMPScheduler() // NOLINT
- : _num_threads(omp_get_max_threads()),
- _has_lmb(cpu_info().cpu_has_little_mid_big()),
- _nonlittle_num_cpus(cpu_info().get_cpu_num_excluding_little())
+ : _num_threads(omp_get_max_threads()), _nonlittle_num_cpus(cpu_info().get_cpu_num_excluding_little())
{
}
#endif /* !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && \
@@ -61,7 +58,7 @@ void OMPScheduler::set_num_threads(unsigned int num_threads)
const unsigned int num_cores = omp_get_max_threads();
#if !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && \
(defined(__arm__) || defined(__aarch64__)) && defined(__ANDROID__)
- const unsigned int adjusted_num_threads = (_has_lmb) ? _nonlittle_num_cpus : num_threads;
+ const unsigned int adjusted_num_threads = std::min(_nonlittle_num_cpus, num_threads);
_num_threads = (num_threads == 0) ? num_cores : adjusted_num_threads;
#else /* !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && \
(defined(__arm__) || defined(__aarch64__)) && defined(__ANDROID__)*/
diff --git a/tests/validation/NEON/UNIT/RuntimeContext.cpp b/tests/validation/NEON/UNIT/RuntimeContext.cpp
index e126aded28..e0d45c639a 100644
--- a/tests/validation/NEON/UNIT/RuntimeContext.cpp
+++ b/tests/validation/NEON/UNIT/RuntimeContext.cpp
@@ -53,15 +53,10 @@ TEST_SUITE(UNIT)
TEST_CASE(CpuCapacity, framework::DatasetMode::ALL)
{
CPUInfo& ci = arm_compute::Scheduler::get().cpu_info();
- const uint32_t total_num_cpus = ci.get_cpu_num();
const uint32_t nonlittle_num_cpus = ci.get_cpu_num_excluding_little();
- const bool has_lmb = ci.cpu_has_little_mid_big();
const uint32_t num_threads = arm_compute::Scheduler::get().num_threads();
- if(has_lmb){
- ARM_COMPUTE_EXPECT(total_num_cpus!=nonlittle_num_cpus , framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(num_threads==nonlittle_num_cpus , framework::LogLevel::ERRORS);
- }
+ ARM_COMPUTE_EXPECT(num_threads<=nonlittle_num_cpus , framework::LogLevel::ERRORS);
}
#endif /* defined(ARM_COMPUTE_OPENMP_SCHEDULER) && !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && \
(defined(__arm__) || defined(__aarch64__)) && defined(__ANDROID__)*/