From feb00bf765f9d7e6b240cc0149aaacec057045ac Mon Sep 17 00:00:00 2001 From: JaneEyreliu <13132063181@163.com> Date: Tue, 14 Nov 2023 11:25:55 +0800 Subject: [PATCH] optimized omp multithreaded execution in phytium D2000 Kylinv10 operating system --- lite/core/device_info.cc | 19 +++++++++++++++++-- tools/codestyle/clang_format.hook | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lite/core/device_info.cc b/lite/core/device_info.cc index 4a70faad063..8ec3494f0a6 100644 --- a/lite/core/device_info.cc +++ b/lite/core/device_info.cc @@ -1081,6 +1081,21 @@ bool DeviceInfo::SetCPUInfoByName() { SetCacheInfo(1, 1, 32 * 1024 * 1024); SetCacheInfo(2, 1, 128 * 1024 * 1024); return true; + } else if (dev_name_.find("Phytium,D2000/8 E8C") != std::string::npos) { + core_num_ = 8; + core_ids_.resize(core_num_); + big_core_ids_.resize(core_num_); + cluster_ids_.resize(core_num_); + for (int i = 0; i < core_num_; ++i) { + core_ids_[i] = i; + big_core_ids_[i] = i; + cluster_ids_[i] = 0; + } + little_core_ids_ = {}; + SetCacheInfo(0, 1, 64 * 1024); + SetCacheInfo(1, 1, 32 * 1024 * 1024); + SetCacheInfo(2, 1, 128 * 1024 * 1024); + return true; } return false; } @@ -1398,7 +1413,7 @@ void DeviceInfo::SetRunMode(lite_api::PowerMode mode, int thread_num) { active_ids_.push_back(0); } #ifdef ARM_WITH_OMP - omp_set_num_threads(active_ids_.size()); + omp_set_num_threads(core_num_); #endif if (mode_ != lite_api::LITE_POWER_NO_BIND) { if (check_cpu_online(active_ids_)) { @@ -1412,7 +1427,7 @@ void DeviceInfo::SetRunMode(lite_api::PowerMode mode, int thread_num) { // only LITE_POWER_NO_BIND is supported in other OS RequestPowerNoBindMode(thread_num); #ifdef ARM_WITH_OMP - omp_set_num_threads(active_ids_.size()); + omp_set_num_threads(core_num_); #endif #endif // LITE_WITH_LINUX //! alloc memory for sgemm in this context diff --git a/tools/codestyle/clang_format.hook b/tools/codestyle/clang_format.hook index 922f2d441ea..55561abff29 100755 --- a/tools/codestyle/clang_format.hook +++ b/tools/codestyle/clang_format.hook @@ -1,7 +1,7 @@ #!/bin/bash set -e -readonly VERSION="3.8" +readonly VERSION="6.0" version=$(clang-format -version)