已合并
限制预加载aicpuso最大进程数为48 #559
pantong创建于 2月26日
限制预加载aicpuso最大进程数为48 #559
已合并
pantong创建于 2月26日
11 个文件变更+26-38
@@ -440,7 +440,6 @@ else()
440 add_executable(aicpu_scheduler440 add_executable(aicpu_scheduler
441 ${CMAKE_CURRENT_SOURCE_DIR}/execute/main.cpp441 ${CMAKE_CURRENT_SOURCE_DIR}/execute/main.cpp
442 ${CMAKE_CURRENT_SOURCE_DIR}/common/aicpusd_args_parser.cpp442 ${CMAKE_CURRENT_SOURCE_DIR}/common/aicpusd_args_parser.cpp
443- ${CMAKE_CURRENT_SOURCE_DIR}/common/feature_ctrl_common.cpp
444 )443 )
445 444 
446 target_compile_definitions(aicpu_scheduler PRIVATE445 target_compile_definitions(aicpu_scheduler PRIVATE
@@ -41,8 +41,6 @@ public:
41 41 
42 static bool BindCpuOnlyOneDevice();42 static bool BindCpuOnlyOneDevice();
43 43 
44- static bool LoadKernelSo();
45- 
46 static bool IfCheckEventSender();44 static bool IfCheckEventSender();
47 45 
48 static bool IsUseMsqV2();46 static bool IsUseMsqV2();
@@ -105,16 +103,6 @@ public:
105 isSetTsMsgVersion_ = false;103 isSetTsMsgVersion_ = false;
106 }104 }
107 105 
108- static inline void NotNeedBatchLoadSo()
109- {
110- isNeedBatchLoadSo_ = false;
111- }
112- 
113- static inline bool GetNeedBathLoadSo()
114- {
115- return isNeedBatchLoadSo_;
116- }
117- 
118private:106private:
119 FeatureCtrl() = default;107 FeatureCtrl() = default;
120 ~FeatureCtrl() = default;108 ~FeatureCtrl() = default;
@@ -124,7 +112,6 @@ private:
124 FeatureCtrl(FeatureCtrl&&) = delete;112 FeatureCtrl(FeatureCtrl&&) = delete;
125 FeatureCtrl& operator=(FeatureCtrl&&) = delete;113 FeatureCtrl& operator=(FeatureCtrl&&) = delete;
126 114 
127- static bool isNeedBatchLoadSo_;
128 static bool aicpuFeatureBindPidByHal_;115 static bool aicpuFeatureBindPidByHal_;
129 static bool aicpuFeatureDoubleDieProduct_;116 static bool aicpuFeatureDoubleDieProduct_;
130 static bool aicpuFeatureCheckEventSender_;117 static bool aicpuFeatureCheckEventSender_;
@@ -91,11 +91,6 @@ bool FeatureCtrl::BindCpuOnlyOneDevice()
91 return false;91 return false;
92}92}
93 93 
94-bool FeatureCtrl::LoadKernelSo()
95-{
96- return isNeedBatchLoadSo_;
97-}
98- 
99bool FeatureCtrl::IfCheckEventSender()94bool FeatureCtrl::IfCheckEventSender()
100{95{
101 return aicpuFeatureCheckEventSender_;96 return aicpuFeatureCheckEventSender_;
@@ -22,5 +22,4 @@ bool FeatureCtrl::aicpuFeatureSetModelNullData_ = true;
22uint16_t FeatureCtrl::tsMsgVersion_ = 0;22uint16_t FeatureCtrl::tsMsgVersion_ = 0;
23std::atomic<bool> FeatureCtrl::isSetTsMsgVersion_ = false;23std::atomic<bool> FeatureCtrl::isSetTsMsgVersion_ = false;
24bool FeatureCtrl::aicpuFeatureUseMsqV2_ = false;24bool FeatureCtrl::aicpuFeatureUseMsqV2_ = false;
25-bool FeatureCtrl::isNeedBatchLoadSo_ = true;
26}25}
@@ -65,6 +65,8 @@ namespace {
65 // max number of eatch device can split65 // max number of eatch device can split
66 constexpr const uint32_t DEVICE_MAX_SPLIT_NUM = 16U;66 constexpr const uint32_t DEVICE_MAX_SPLIT_NUM = 16U;
67 67 
68+ constexpr uint32_t MAX_AICPU_PROC_NUM = 48U;
69+ 
68 const std::string TSKERNEL_PREFIX = "tsKernel:";70 const std::string TSKERNEL_PREFIX = "tsKernel:";
69}71}
70namespace AicpuSchedule {72namespace AicpuSchedule {
@@ -78,7 +80,8 @@ namespace AicpuSchedule {
78 initFlag_(false),80 initFlag_(false),
79 eventBitMap_(0U),81 eventBitMap_(0U),
80 runMode_(aicpu::AicpuRunMode::THREAD_MODE),82 runMode_(aicpu::AicpuRunMode::THREAD_MODE),
81- aicpuCustSdPid_(-1) {}83+ aicpuCustSdPid_(-1),
84+ isNeedBatchLoadSo_(true) {}
82 85 
83 /**86 /**
84 * @ingroup AicpuScheduleCore87 * @ingroup AicpuScheduleCore
@@ -701,4 +704,18 @@ namespace AicpuSchedule {
701 aicpusd_info("Success to process kernel data exception event.");704 aicpusd_info("Success to process kernel data exception event.");
702 return AICPU_SCHEDULE_OK;705 return AICPU_SCHEDULE_OK;
703 }706 }
707+ 
708+ void AicpuScheduleInterface::SetBatchLoadMode(const uint32_t aicpuProcNum)
709+ {
710+ if (aicpuProcNum >= MAX_AICPU_PROC_NUM) {
711+ isNeedBatchLoadSo_ = false;
712+ aicpusd_run_info("Not need batch load so, aicpuProcNum[%u], max num[%u]",
713+ aicpuProcNum, MAX_AICPU_PROC_NUM);
714+ }
715+ }
716+ 
717+ bool AicpuScheduleInterface::NeedLoadKernelSo() const
718+ {
719+ return isNeedBatchLoadSo_;
720+ }
704}721}
@@ -99,6 +99,8 @@ namespace AicpuSchedule {
99 __attribute__((visibility("default"))) int32_t StopAICPUScheduler(const std::vector<uint32_t> &deviceVec,99 __attribute__((visibility("default"))) int32_t StopAICPUScheduler(const std::vector<uint32_t> &deviceVec,
100 const pid_t hostPid);100 const pid_t hostPid);
101 101 
102+ __attribute__((visibility("default"))) void SetBatchLoadMode(const uint32_t aicpuProcNum);
103+ 
102 int32_t StopAICPUSchedulerWithFlag(const std::vector<uint32_t> &deviceVec, const pid_t hostPid,104 int32_t StopAICPUSchedulerWithFlag(const std::vector<uint32_t> &deviceVec, const pid_t hostPid,
103 bool waitThreadStop);105 bool waitThreadStop);
104 106 
@@ -141,6 +143,8 @@ namespace AicpuSchedule {
141 void SetAicpuSdProcId(const pid_t aicpuSdPid);143 void SetAicpuSdProcId(const pid_t aicpuSdPid);
142 144 
143 int32_t ProcessException(const DataFlowExceptionNotify *const exceptionInfo) const;145 int32_t ProcessException(const DataFlowExceptionNotify *const exceptionInfo) const;
146+ 
147+ bool NeedLoadKernelSo() const;
144 private:148 private:
145 AicpuScheduleInterface();149 AicpuScheduleInterface();
146 150 
@@ -198,6 +202,8 @@ namespace AicpuSchedule {
198 std::map<uint32_t, bool> aicpusdInitFlagMap_;202 std::map<uint32_t, bool> aicpusdInitFlagMap_;
199 203 
200 std::atomic<int32_t> aicpuCustSdPid_;204 std::atomic<int32_t> aicpuCustSdPid_;
205+ 
206+ bool isNeedBatchLoadSo_;
201 };207 };
202}208}
203#endif209#endif
@@ -163,7 +163,7 @@ int32_t ComputeProcess::Start(const std::vector<uint32_t> &deviceVec,
163 }163 }
164 }164 }
165 165 
166- if (FeatureCtrl::LoadKernelSo()) {166+ if (AicpuScheduleInterface::GetInstance().NeedLoadKernelSo()) {
167 LoadKernelSo();167 LoadKernelSo();
168 }168 }
169 169 
@@ -39,7 +39,6 @@
39namespace AicpuSchedule {39namespace AicpuSchedule {
40namespace {40namespace {
41constexpr int32_t SUCCESS_VALUE = 0;41constexpr int32_t SUCCESS_VALUE = 0;
42-constexpr uint32_t MAX_AICPU_PROC_NUM = 48U;
43const std::string ERROR_MSG_INVALID_PARAM = "E39001";42const std::string ERROR_MSG_INVALID_PARAM = "E39001";
44const std::string ERROR_MSG_DRV_ERROR = "E39002";43const std::string ERROR_MSG_DRV_ERROR = "E39002";
45const std::string ERROR_MSG_CGROUP_FAILED = "E30007";44const std::string ERROR_MSG_CGROUP_FAILED = "E30007";
@@ -308,17 +307,6 @@ AicpuSchedMode GetAicpuSchedMode(const uint32_t deviceId, const uint32_t vfId, c
308 307 
309 return schedMode;308 return schedMode;
310}309}
311- 
312-void SetBatchLoadMode(const uint32_t aicpuProcNum)
313-{
314- if (aicpuProcNum > MAX_AICPU_PROC_NUM) {
315- FeatureCtrl::NotNeedBatchLoadSo();
316- aicpusd_run_info("Not need batch load so, aicpuProcNum[%u], max num [%u], load so flag[%d]",
317- aicpuProcNum,
318- MAX_AICPU_PROC_NUM,
319- FeatureCtrl::GetNeedBathLoadSo());
320- }
321-}
322}310}
323}311}
324 312 
@@ -346,7 +334,7 @@ int32_t ComputeProcessMain(int32_t argc, char* argv[])
346 const pid_t pid = startParams.GetHostPid();334 const pid_t pid = startParams.GetHostPid();
347 const uint32_t deviceId = startParams.GetDeviceId();335 const uint32_t deviceId = startParams.GetDeviceId();
348 const uint32_t aicpuProcNum = startParams.GetAicpuProcNum();336 const uint32_t aicpuProcNum = startParams.GetAicpuProcNum();
349- AicpuSchedule::SetBatchLoadMode(aicpuProcNum);337+ AicpuSchedule::AicpuScheduleInterface::GetInstance().SetBatchLoadMode(aicpuProcNum);
350 if (!AicpuSchedule::AddToCgroup(deviceId, vfId)) {338 if (!AicpuSchedule::AddToCgroup(deviceId, vfId)) {
351 AicpuSchedule::ReportErrorMsg(AicpuSchedule::AICPU_SCHEDULE_ERROR_CGROUP_FAILED,339 AicpuSchedule::ReportErrorMsg(AicpuSchedule::AICPU_SCHEDULE_ERROR_CGROUP_FAILED,
352 deviceId, static_cast<uint32_t>(pid), vfId);340 deviceId, static_cast<uint32_t>(pid), vfId);
@@ -6601,7 +6601,6 @@ TEST_F(AICPUScheduleTEST, Start_002) {
6601 std::string ch = "000000000000000000000000000000000000000000000000";6601 std::string ch = "000000000000000000000000000000000000000000000000";
6602 std::vector<uint32_t> deviceVec;6602 std::vector<uint32_t> deviceVec;
6603 deviceVec.push_back(1);6603 deviceVec.push_back(1);
6604- MOCKER_CPP(&FeatureCtrl::LoadKernelSo).stubs().will(returnValue(true));
6605 MOCKER_CPP(&ComputeProcess::StartTdtServer)6604 MOCKER_CPP(&ComputeProcess::StartTdtServer)
6606 .stubs()6605 .stubs()
6607 .will(returnValue(0));6606 .will(returnValue(0));
@@ -5653,7 +5653,6 @@ TEST_F(AICPUScheduleTEST, Start_002) {
5653 MOCKER_CPP(&ComputeProcess::StartTdtServer)5653 MOCKER_CPP(&ComputeProcess::StartTdtServer)
5654 .stubs()5654 .stubs()
5655 .will(returnValue(0));5655 .will(returnValue(0));
5656- MOCKER_CPP(&FeatureCtrl::LoadKernelSo).stubs().will(returnValue(true));;
5657 const AicpuSchedMode schedMode = SCHED_MODE_INTERRUPT;5656 const AicpuSchedMode schedMode = SCHED_MODE_INTERRUPT;
5658 int ret = ComputeProcess::GetInstance().Start(deviceVec, 100, ch, PROFILING_OPEN, 0, aicpu::PROCESS_PCIE_MODE, schedMode);5657 int ret = ComputeProcess::GetInstance().Start(deviceVec, 100, ch, PROFILING_OPEN, 0, aicpu::PROCESS_PCIE_MODE, schedMode);
5659 EXPECT_EQ(ret, AICPU_SCHEDULE_OK);5658 EXPECT_EQ(ret, AICPU_SCHEDULE_OK);
@@ -47,7 +47,6 @@ TEST_F(AICPUScheduleOpenTEST, Check_default_feature) {
47 EXPECT_FALSE(FeatureCtrl::IsNoNeedDumpOpDebugProduct());47 EXPECT_FALSE(FeatureCtrl::IsNoNeedDumpOpDebugProduct());
48 EXPECT_FALSE(FeatureCtrl::IsDoubleDieProduct());48 EXPECT_FALSE(FeatureCtrl::IsDoubleDieProduct());
49 EXPECT_FALSE(FeatureCtrl::BindCpuOnlyOneDevice());49 EXPECT_FALSE(FeatureCtrl::BindCpuOnlyOneDevice());
50- EXPECT_TRUE(FeatureCtrl::LoadKernelSo());
51 EXPECT_FALSE(FeatureCtrl::IfCheckEventSender());50 EXPECT_FALSE(FeatureCtrl::IfCheckEventSender());
52 EXPECT_FALSE(FeatureCtrl::IsUseMsqV2());51 EXPECT_FALSE(FeatureCtrl::IsUseMsqV2());
53 EXPECT_TRUE(FeatureCtrl::ShouldInitDrvThread());52 EXPECT_TRUE(FeatureCtrl::ShouldInitDrvThread());