已合并
为OptionalInfos的底层对象加锁保护 #1553
为OptionalInfos的底层对象加锁保护 #1553
已合并
jiang-mingming01创建于 4月14日
7 个文件变更+44-28
@@ -843,7 +843,7 @@ uint32_t PlatformInfoManager::AssemblePlatformInfoVector(std::map<std::string, s
843 843 
844void PlatformInfoManager::FillupFixPipeInfo(PlatFormInfos &platform_infos) {844void PlatformInfoManager::FillupFixPipeInfo(PlatFormInfos &platform_infos) {
845 std::string is_support_fixpipe_str;845 std::string is_support_fixpipe_str;
846- if (!platform_infos.GetPlatformRes("AICoreSpec", "support_fixpipe", is_support_fixpipe_str) ||846+ if (!platform_infos.GetPlatformResWithLock("AICoreSpec", "support_fixpipe", is_support_fixpipe_str) ||
847 !static_cast<bool>(std::atoi(is_support_fixpipe_str.c_str()))) {847 !static_cast<bool>(std::atoi(is_support_fixpipe_str.c_str()))) {
848 return;848 return;
849 }849 }
@@ -959,6 +959,7 @@ __attribute__((visibility("default"))) uint32_t PlatformInfoManager::GetPlatform
959 if (realSocVersion == SOC_VERSION_ASCEND910) {959 if (realSocVersion == SOC_VERSION_ASCEND910) {
960 realSocVersion = SOC_VERSION_ASCEND910A;960 realSocVersion = SOC_VERSION_ASCEND910A;
961 }961 }
962+ std::lock_guard<std::mutex> lock_guard(pc_lock_);
962 auto iter = platform_info_map_.find(realSocVersion);963 auto iter = platform_info_map_.find(realSocVersion);
963 if (iter == platform_info_map_.end()) {964 if (iter == platform_info_map_.end()) {
964 PF_LOGE("Cannot find platform_info by SoCVersion %s.", realSocVersion.c_str());965 PF_LOGE("Cannot find platform_info by SoCVersion %s.", realSocVersion.c_str());
@@ -1001,6 +1002,7 @@ __attribute__((visibility("default"))) uint32_t PlatformInfoManager::GetPlatform
1001 if (realSocVersion == SOC_VERSION_ASCEND910) {1002 if (realSocVersion == SOC_VERSION_ASCEND910) {
1002 realSocVersion = SOC_VERSION_ASCEND910A;1003 realSocVersion = SOC_VERSION_ASCEND910A;
1003 }1004 }
1005+ std::lock_guard<std::mutex> lock_guard(pc_lock_);
1004 auto iter = platform_infos_map_.find(realSocVersion);1006 auto iter = platform_infos_map_.find(realSocVersion);
1005 if (iter == platform_infos_map_.end()) {1007 if (iter == platform_infos_map_.end()) {
1006 PF_LOGE("Cannot find platform_info by SoCVersion %s.", realSocVersion.c_str());1008 PF_LOGE("Cannot find platform_info by SoCVersion %s.", realSocVersion.c_str());
@@ -1008,7 +1010,6 @@ __attribute__((visibility("default"))) uint32_t PlatformInfoManager::GetPlatform
1008 }1010 }
1009 platform_info = iter->second;1011 platform_info = iter->second;
1010 opti_compilation_info = opti_compilation_infos_;1012 opti_compilation_info = opti_compilation_infos_;
1011- std::lock_guard<std::mutex> lock_guard(pc_lock_);
1012 opti_compilation_info.SetFixPipeDtypeMap(platform_info.GetFixPipeDtypeMap());1013 opti_compilation_info.SetFixPipeDtypeMap(platform_info.GetFixPipeDtypeMap());
1013 return PLATFORM_SUCCESS;1014 return PLATFORM_SUCCESS;
1014}1015}
@@ -33,6 +33,7 @@ using ProtoBufStringMapMap = ascend_private::protobuf::Map<ProtoBufString, Proto
33PlatFormInfosImplPtr g_platformInfosImplInstance;33PlatFormInfosImplPtr g_platformInfosImplInstance;
34 34 
35bool PlatFormInfos::Init() {35bool PlatFormInfos::Init() {
36+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
36 platform_infos_impl_ = make_shared<PlatFormInfosImpl>();37 platform_infos_impl_ = make_shared<PlatFormInfosImpl>();
37 if (platform_infos_impl_ == nullptr) {38 if (platform_infos_impl_ == nullptr) {
38 return false;39 return false;
@@ -74,6 +75,7 @@ static void GetMapMapInfoFromProtoBuf(ProtoBufStringMapMap *protoMap,
74#endif75#endif
75 76 
76map<string, vector<string>> PlatFormInfos::GetAICoreIntrinsicDtype() {77map<string, vector<string>> PlatFormInfos::GetAICoreIntrinsicDtype() {
78+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
77 if (platform_infos_impl_ == nullptr) {79 if (platform_infos_impl_ == nullptr) {
78 return map<string, vector<string>>();80 return map<string, vector<string>>();
79 }81 }
@@ -81,6 +83,7 @@ map<string, vector<string>> PlatFormInfos::GetAICoreIntrinsicDtype() {
81}83}
82 84 
83map<string, vector<string>> PlatFormInfos::GetVectorCoreIntrinsicDtype() {85map<string, vector<string>> PlatFormInfos::GetVectorCoreIntrinsicDtype() {
86+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
84 if (platform_infos_impl_ == nullptr) {87 if (platform_infos_impl_ == nullptr) {
85 return map<string, vector<string>>();88 return map<string, vector<string>>();
86 }89 }
@@ -95,7 +98,7 @@ bool PlatFormInfos::GetPlatformRes(const string &label, const string &key, strin
95}98}
96 99 
97bool PlatFormInfos::GetPlatformResWithLock(const string &label, const string &key, string &val) {100bool PlatFormInfos::GetPlatformResWithLock(const string &label, const string &key, string &val) {
98- std::lock_guard<std::mutex> lock_guard(plt_mutex);101+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
99 if (platform_infos_impl_ == nullptr) {102 if (platform_infos_impl_ == nullptr) {
100 return true;103 return true;
101 }104 }
@@ -110,7 +113,7 @@ bool PlatFormInfos::GetPlatformRes(const std::string &label, std::map<std::strin
110}113}
111 114 
112bool PlatFormInfos::GetPlatformResWithLock(const std::string &label, std::map<std::string, std::string> &res) {115bool PlatFormInfos::GetPlatformResWithLock(const std::string &label, std::map<std::string, std::string> &res) {
113- std::lock_guard<std::mutex> lock_guard(plt_mutex);116+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
114 if (platform_infos_impl_ == nullptr) {117 if (platform_infos_impl_ == nullptr) {
115 return true;118 return true;
116 }119 }
@@ -118,7 +121,7 @@ bool PlatFormInfos::GetPlatformResWithLock(const std::string &label, std::map<st
118}121}
119 122 
120bool PlatFormInfos::GetPlatformResWithLock(std::map<std::string, std::map<std::string, std::string>> &res) {123bool PlatFormInfos::GetPlatformResWithLock(std::map<std::string, std::map<std::string, std::string>> &res) {
121- std::lock_guard<std::mutex> lock_guard(plt_mutex);124+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
122 if (platform_infos_impl_ == nullptr) {125 if (platform_infos_impl_ == nullptr) {
123 return true;126 return true;
124 }127 }
@@ -126,6 +129,7 @@ bool PlatFormInfos::GetPlatformResWithLock(std::map<std::string, std::map<std::s
126}129}
127 130 
128void PlatFormInfos::SetAICoreIntrinsicDtype(map<string, vector<string>> &intrinsic_dtypes) {131void PlatFormInfos::SetAICoreIntrinsicDtype(map<string, vector<string>> &intrinsic_dtypes) {
132+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
129 if (platform_infos_impl_ == nullptr) {133 if (platform_infos_impl_ == nullptr) {
130 return;134 return;
131 }135 }
@@ -133,6 +137,7 @@ void PlatFormInfos::SetAICoreIntrinsicDtype(map<string, vector<string>> &intrins
133}137}
134 138 
135void PlatFormInfos::SetVectorCoreIntrinsicDtype(map<string, vector<string>> &intrinsic_dtypes) {139void PlatFormInfos::SetVectorCoreIntrinsicDtype(map<string, vector<string>> &intrinsic_dtypes) {
140+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
136 if (platform_infos_impl_ == nullptr) {141 if (platform_infos_impl_ == nullptr) {
137 return;142 return;
138 }143 }
@@ -140,6 +145,7 @@ void PlatFormInfos::SetVectorCoreIntrinsicDtype(map<string, vector<string>> &int
140}145}
141 146 
142void PlatFormInfos::SetFixPipeDtypeMap(const std::map<std::string, std::vector<std::string>> &fixpipe_dtype_map) {147void PlatFormInfos::SetFixPipeDtypeMap(const std::map<std::string, std::vector<std::string>> &fixpipe_dtype_map) {
148+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
143 if (platform_infos_impl_ == nullptr) {149 if (platform_infos_impl_ == nullptr) {
144 return;150 return;
145 }151 }
@@ -163,7 +169,7 @@ void PlatFormInfos::SetCoreNumByCoreType(const std::string &core_type) {
163 core_type_str = "ai_core_cnt";169 core_type_str = "ai_core_cnt";
164 }170 }
165 171 
166- std::lock_guard<std::mutex> lock_guard(plt_mutex);172+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
167 try {173 try {
168 (void)GetPlatformRes("SoCInfo", core_type_str, core_num_str);174 (void)GetPlatformRes("SoCInfo", core_type_str, core_num_str);
169 core_num_ = core_num_str.empty() ? 0 : std::stoi(core_num_str.c_str());175 core_num_ = core_num_str.empty() ? 0 : std::stoi(core_num_str.c_str());
@@ -181,19 +187,19 @@ void PlatFormInfos::SetCoreNumByCoreType(const std::string &core_type) {
181}187}
182 188 
183void PlatFormInfos::SetCoreNum(const uint32_t &core_num) {189void PlatFormInfos::SetCoreNum(const uint32_t &core_num) {
184- std::lock_guard<std::mutex> lock_guard(plt_mutex);190+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
185 PF_LOGD("Set PlatFormInfos::core_num_ to %u.", core_num);191 PF_LOGD("Set PlatFormInfos::core_num_ to %u.", core_num);
186 core_num_ = core_num;192 core_num_ = core_num;
187}193}
188 194 
189uint32_t PlatFormInfos::GetCoreNum() const {195uint32_t PlatFormInfos::GetCoreNum() const {
190- std::lock_guard<std::mutex> lock_guard(plt_mutex);196+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
191 PF_LOGD("Get PlatformInfos::core_num_=[%u].", core_num_);197 PF_LOGD("Get PlatformInfos::core_num_=[%u].", core_num_);
192 return core_num_;198 return core_num_;
193}199}
194 200 
195uint32_t PlatFormInfos::GetCoreNumWithLock() const {201uint32_t PlatFormInfos::GetCoreNumWithLock() const {
196- std::lock_guard<std::mutex> lock_guard(plt_mutex);202+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
197 PF_LOGD("Get PlatformInfos::core_num_=[%u].", core_num_);203 PF_LOGD("Get PlatformInfos::core_num_=[%u].", core_num_);
198 return core_num_;204 return core_num_;
199}205}
@@ -208,7 +214,7 @@ uint32_t PlatFormInfos::GetCoreNumByType(const std::string &core_type)
208 core_type_str = "ai_core_cnt";214 core_type_str = "ai_core_cnt";
209 }215 }
210 216 
211- std::lock_guard<std::mutex> lock_guard(plt_mutex);217+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
212 std::string core_num_str;218 std::string core_num_str;
213 uint32_t core_num = 0;219 uint32_t core_num = 0;
214 try {220 try {
@@ -268,6 +274,7 @@ void PlatFormInfos:: GetLocalMemBw(const LocalMemType &mem_type, uint64_t &bw_si
268}274}
269 275 
270std::map<std::string, std::vector<std::string>> PlatFormInfos::GetFixPipeDtypeMap() {276std::map<std::string, std::vector<std::string>> PlatFormInfos::GetFixPipeDtypeMap() {
277+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
271 if (platform_infos_impl_ == nullptr) {278 if (platform_infos_impl_ == nullptr) {
272 return map<string, vector<string>>();279 return map<string, vector<string>>();
273 }280 }
@@ -282,7 +289,7 @@ void PlatFormInfos::SetPlatformRes(const std::string &label, std::map<std::strin
282}289}
283 290 
284void PlatFormInfos::SetPlatformResWithLock(const std::string &label, std::map<std::string, std::string> &res) {291void PlatFormInfos::SetPlatformResWithLock(const std::string &label, std::map<std::string, std::string> &res) {
285- std::lock_guard<std::mutex> lock_guard(plt_mutex);292+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
286 if (platform_infos_impl_ == nullptr) {293 if (platform_infos_impl_ == nullptr) {
287 return;294 return;
288 }295 }
@@ -290,7 +297,7 @@ void PlatFormInfos::SetPlatformResWithLock(const std::string &label, std::map<st
290}297}
291 298 
292bool PlatFormInfos::InitByInstance() {299bool PlatFormInfos::InitByInstance() {
293- std::lock_guard<std::mutex> lock_guard(plt_mutex);300+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
294 if (platform_infos_impl_ != nullptr) {301 if (platform_infos_impl_ != nullptr) {
295 return true;302 return true;
296 }303 }
@@ -375,6 +382,7 @@ bool PlatFormInfos::LoadFromBuffer(const char *bufPtr, const size_t bufLen) {
375 GetMapMapInfoFromProtoBuf(platformDefInfos.mutable_platform_res_map(), platformResMap);382 GetMapMapInfoFromProtoBuf(platformDefInfos.mutable_platform_res_map(), platformResMap);
376 GetVecMapInfoFromProtoBuf(platformDefInfos.mutable_fixpipe_dtype_map(), fixPipeDtypeMap);383 GetVecMapInfoFromProtoBuf(platformDefInfos.mutable_fixpipe_dtype_map(), fixPipeDtypeMap);
377 384 
385+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
378 platform_infos_impl_->SetAICoreIntrinsicDtype(aiCoreInstrinsicDtypesMap);386 platform_infos_impl_->SetAICoreIntrinsicDtype(aiCoreInstrinsicDtypesMap);
379 platform_infos_impl_->SetVectorCoreIntrinsicDtype(aiVectorInstrinsicDtypesMap);387 platform_infos_impl_->SetVectorCoreIntrinsicDtype(aiVectorInstrinsicDtypesMap);
380 for (auto iter = platformResMap.begin(); iter != platformResMap.end(); ++iter) {388 for (auto iter = platformResMap.begin(); iter != platformResMap.end(); ++iter) {
@@ -387,6 +395,7 @@ bool PlatFormInfos::LoadFromBuffer(const char *bufPtr, const size_t bufLen) {
387}395}
388 396 
389bool OptionalInfos::Init() {397bool OptionalInfos::Init() {
398+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
390 optional_infos_impl_ = make_shared<OptionalInfosImpl>();399 optional_infos_impl_ = make_shared<OptionalInfosImpl>();
391 if (optional_infos_impl_ == nullptr) {400 if (optional_infos_impl_ == nullptr) {
392 return false;401 return false;
@@ -395,6 +404,7 @@ bool OptionalInfos::Init() {
395}404}
396 405 
397string OptionalInfos::GetSocVersion() {406string OptionalInfos::GetSocVersion() {
407+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
398 if (optional_infos_impl_ == nullptr) {408 if (optional_infos_impl_ == nullptr) {
399 return "";409 return "";
400 }410 }
@@ -402,6 +412,7 @@ string OptionalInfos::GetSocVersion() {
402}412}
403 413 
404string OptionalInfos::GetCoreType() {414string OptionalInfos::GetCoreType() {
415+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
405 if (optional_infos_impl_ == nullptr) {416 if (optional_infos_impl_ == nullptr) {
406 return "";417 return "";
407 }418 }
@@ -409,6 +420,7 @@ string OptionalInfos::GetCoreType() {
409}420}
410 421 
411uint32_t OptionalInfos::GetAICoreNum() {422uint32_t OptionalInfos::GetAICoreNum() {
423+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
412 if (optional_infos_impl_ == nullptr) {424 if (optional_infos_impl_ == nullptr) {
413 return 0;425 return 0;
414 }426 }
@@ -416,6 +428,7 @@ uint32_t OptionalInfos::GetAICoreNum() {
416}428}
417 429 
418string OptionalInfos::GetL1FusionFlag() {430string OptionalInfos::GetL1FusionFlag() {
431+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
419 if (optional_infos_impl_ == nullptr) {432 if (optional_infos_impl_ == nullptr) {
420 return "";433 return "";
421 }434 }
@@ -423,6 +436,7 @@ string OptionalInfos::GetL1FusionFlag() {
423}436}
424 437 
425void OptionalInfos::SetFixPipeDtypeMap(const std::map<std::string, std::vector<std::string>> &fixpipe_dtype_map) {438void OptionalInfos::SetFixPipeDtypeMap(const std::map<std::string, std::vector<std::string>> &fixpipe_dtype_map) {
439+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
426 if (optional_infos_impl_ == nullptr) {440 if (optional_infos_impl_ == nullptr) {
427 return;441 return;
428 }442 }
@@ -430,12 +444,14 @@ void OptionalInfos::SetFixPipeDtypeMap(const std::map<std::string, std::vector<s
430}444}
431 445 
432std::map<std::string, std::vector<std::string>> OptionalInfos::GetFixPipeDtypeMap() {446std::map<std::string, std::vector<std::string>> OptionalInfos::GetFixPipeDtypeMap() {
447+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
433 if (optional_infos_impl_ == nullptr) {448 if (optional_infos_impl_ == nullptr) {
434 return std::map<std::string, std::vector<std::string>>();449 return std::map<std::string, std::vector<std::string>>();
435 }450 }
436 return optional_infos_impl_->GetFixPipeDtypeMap();451 return optional_infos_impl_->GetFixPipeDtypeMap();
437}452}
438void OptionalInfos::SetSocVersion(string soc_version) {453void OptionalInfos::SetSocVersion(string soc_version) {
454+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
439 if (optional_infos_impl_ == nullptr) {455 if (optional_infos_impl_ == nullptr) {
440 return;456 return;
441 }457 }
@@ -443,7 +459,7 @@ void OptionalInfos::SetSocVersion(string soc_version) {
443}459}
444 460 
445void OptionalInfos::SetSocVersionWithLock(string soc_version) {461void OptionalInfos::SetSocVersionWithLock(string soc_version) {
446- std::lock_guard<std::mutex> lock_guard(plt_mutex);462+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
447 if (optional_infos_impl_ == nullptr) {463 if (optional_infos_impl_ == nullptr) {
448 return;464 return;
449 }465 }
@@ -451,6 +467,7 @@ void OptionalInfos::SetSocVersionWithLock(string soc_version) {
451}467}
452 468 
453void OptionalInfos::SetCoreType(string core_type) {469void OptionalInfos::SetCoreType(string core_type) {
470+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
454 if (optional_infos_impl_ == nullptr) {471 if (optional_infos_impl_ == nullptr) {
455 return;472 return;
456 }473 }
@@ -458,6 +475,7 @@ void OptionalInfos::SetCoreType(string core_type) {
458}475}
459 476 
460void OptionalInfos::SetAICoreNum(uint32_t ai_core_num) {477void OptionalInfos::SetAICoreNum(uint32_t ai_core_num) {
478+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
461 if (optional_infos_impl_ == nullptr) {479 if (optional_infos_impl_ == nullptr) {
462 return;480 return;
463 }481 }
@@ -465,6 +483,7 @@ void OptionalInfos::SetAICoreNum(uint32_t ai_core_num) {
465}483}
466 484 
467void OptionalInfos::SetL1FusionFlag(string l1_fusion_flag) {485void OptionalInfos::SetL1FusionFlag(string l1_fusion_flag) {
486+ std::lock_guard<std::mutex> lock_guard(opt_info_mutex);
468 if (optional_infos_impl_ == nullptr) {487 if (optional_infos_impl_ == nullptr) {
469 return;488 return;
470 }489 }
@@ -102,12 +102,10 @@ void OptionalInfosImpl::SetSocVersion(std::string soc_version) { soc_version_ =
102 102 
103void OptionalInfosImpl::SetFixPipeDtypeMap(103void OptionalInfosImpl::SetFixPipeDtypeMap(
104 const std::map<std::string, std::vector<std::string>>& fixpipe_dtype_map) {104 const std::map<std::string, std::vector<std::string>>& fixpipe_dtype_map) {
105- std::lock_guard<std::mutex> lock(mtx_);
106 fixpipe_dtype_map_ = fixpipe_dtype_map;105 fixpipe_dtype_map_ = fixpipe_dtype_map;
107}106}
108 107 
109std::map<std::string, std::vector<std::string>> OptionalInfosImpl::GetFixPipeDtypeMap() {108std::map<std::string, std::vector<std::string>> OptionalInfosImpl::GetFixPipeDtypeMap() {
110- std::lock_guard<std::mutex> lock(mtx_);
111 return fixpipe_dtype_map_;109 return fixpipe_dtype_map_;
112}110}
113 111 
@@ -15,7 +15,6 @@
15#include <string>15#include <string>
16#include <vector>16#include <vector>
17#include <memory>17#include <memory>
18-#include <mutex>
19#include "platform/platform_infos_def.h"18#include "platform/platform_infos_def.h"
20 19 
21namespace fe {20namespace fe {
@@ -56,8 +55,6 @@ class OptionalInfosImpl {
56 void SetAICoreNum(uint32_t ai_core_num);55 void SetAICoreNum(uint32_t ai_core_num);
57 void SetL1FusionFlag(std::string l1_fusion_flag);56 void SetL1FusionFlag(std::string l1_fusion_flag);
58 private:57 private:
59- std::mutex mtx_;
60- 
61 std::string soc_version_;58 std::string soc_version_;
62 std::string core_type_;59 std::string core_type_;
63 uint32_t ai_core_num_{0};60 uint32_t ai_core_num_{0};
@@ -12,7 +12,8 @@
12#include "platform_infos_impl.h"12#include "platform_infos_impl.h"
13 13 
14namespace fe {14namespace fe {
15-std::mutex plt_mutex;15+std::mutex plt_info_mutex;
16+std::mutex opt_info_mutex;
16 17 
17PlatformInfosUtils::PlatformInfosUtils()18PlatformInfosUtils::PlatformInfosUtils()
18{}19{}
@@ -26,7 +27,7 @@ PlatformInfosUtils &PlatformInfosUtils::GetInstance() {
26}27}
27 28 
28void PlatformInfosUtils::Clone(PlatFormInfos &dest_platform_infos, const PlatFormInfos &platform_infos) const {29void PlatformInfosUtils::Clone(PlatFormInfos &dest_platform_infos, const PlatFormInfos &platform_infos) const {
29- std::lock_guard<std::mutex> lock_guard(plt_mutex);30+ std::lock_guard<std::mutex> lock_guard(plt_info_mutex);
30 PF_LOGD("Using platFormInfos Clone function.");31 PF_LOGD("Using platFormInfos Clone function.");
31 if(&dest_platform_infos != &platform_infos) {32 if(&dest_platform_infos != &platform_infos) {
32 dest_platform_infos.core_num_ = platform_infos.core_num_;33 dest_platform_infos.core_num_ = platform_infos.core_num_;
@@ -18,7 +18,8 @@
18#include "platform_log.h"18#include "platform_log.h"
19 19 
20namespace fe {20namespace fe {
21-extern std::mutex plt_mutex;21+extern std::mutex plt_info_mutex;
22+extern std::mutex opt_info_mutex;
22const std::string PLATFORM_RELATIVE_PATH = "data/platform_config";23const std::string PLATFORM_RELATIVE_PATH = "data/platform_config";
23 24 
24class PlatformInfosUtils {25class PlatformInfosUtils {
@@ -230,15 +230,14 @@ int32_t PlatformManagerV2::GetPlatformInfos(const std::string &soc_version, fe::
230 if (realSocVersion == SOC_VERSION_ASCEND910) {230 if (realSocVersion == SOC_VERSION_ASCEND910) {
231 realSocVersion = SOC_VERSION_ASCEND910A;231 realSocVersion = SOC_VERSION_ASCEND910A;
232 }232 }
233- {233+ 
234- std::lock_guard<std::mutex> lock_guard(soc_lock_);234+ std::lock_guard<std::mutex> lock_guard(soc_lock_);
235- if (soc_file_status_.count(realSocVersion) == 0) {235+ if (soc_file_status_.count(realSocVersion) == 0) {
236- if (InitPlatformInfos(realSocVersion) != PLATFORM_SUCCESS) {236+ if (InitPlatformInfos(realSocVersion) != PLATFORM_SUCCESS) {
237- return PLATFORM_ERROR_PARSE_FILE_FAILED;237+ return PLATFORM_ERROR_PARSE_FILE_FAILED;
238- }
239 }238 }
240- soc_file_status_[realSocVersion] = true;
241 }239 }
240+ soc_file_status_[realSocVersion] = true;
242 auto iter = platform_infos_map_.find(realSocVersion);241 auto iter = platform_infos_map_.find(realSocVersion);
243 if (iter == platform_infos_map_.end()) {242 if (iter == platform_infos_map_.end()) {
244 PF_LOGE("Cannot find platform_info by SoCVersion %s.", realSocVersion.c_str());243 PF_LOGE("Cannot find platform_info by SoCVersion %s.", realSocVersion.c_str());