已合并
[v2.9.0][feature][bugfix]support IPC 64k and HDK xx.xx.xx.b version #41876
Dring创建于 7月16日
[v2.9.0][feature][bugfix]support IPC 64k and HDK xx.xx.xx.b version #41876
已合并
共 3 个文件变更+35-14
| @@ -42,7 +42,7 @@ class Test_ipc_event(TestCase): | |||
| 42 | b = a.to('npu:1', non_blocking=True) | 42 | b = a.to('npu:1', non_blocking=True) |
| 43 | self.assertEqual(a.cpu(), b.cpu()) | 43 | self.assertEqual(a.cpu(), b.cpu()) |
| 44 | 44 | ||
| 45 | - @SupportedDevices(['Ascend910B']) | 45 | + @SupportedDevices(['Ascend910B', 'Ascend910C']) |
| 46 | def test_ipc_event_pickle(self): | 46 | def test_ipc_event_pickle(self): |
| 47 | if skip_ipc_event_case: | 47 | if skip_ipc_event_case: |
| 48 | return | 48 | return |
| @@ -60,7 +60,7 @@ class Test_ipc_event(TestCase): | |||
| 60 | ev.wait() | 60 | ev.wait() |
| 61 | ev.synchronize() | 61 | ev.synchronize() |
| 62 | 62 | ||
| 63 | - @SupportedDevices(['Ascend910B']) | 63 | + @SupportedDevices(['Ascend910B', 'Ascend910C']) |
| 64 | def test_ipc_event_1(self): | 64 | def test_ipc_event_1(self): |
| 65 | if skip_ipc_event_case: | 65 | if skip_ipc_event_case: |
| 66 | return | 66 | return |
| @@ -94,7 +94,7 @@ class Test_ipc_event(TestCase): | |||
| 94 | q2.put('x') | 94 | q2.put('x') |
| 95 | assert q1.get() == 'y' | 95 | assert q1.get() == 'y' |
| 96 | 96 | ||
| 97 | - @SupportedDevices(['Ascend910B']) | 97 | + @SupportedDevices(['Ascend910B', 'Ascend910C']) |
| 98 | def test_ipc_event_2(self): | 98 | def test_ipc_event_2(self): |
| 99 | if skip_ipc_event_case: | 99 | if skip_ipc_event_case: |
| 100 | return | 100 | return |
| @@ -120,7 +120,7 @@ class Test_ipc_event(TestCase): | |||
| 120 | p.join() | 120 | p.join() |
| 121 | 121 | ||
| 122 | 122 | ||
| 123 | - @SupportedDevices(['Ascend910B']) | 123 | + @SupportedDevices(['Ascend910B', 'Ascend910C']) |
| 124 | def test_event_handle_multi_npu(self): | 124 | def test_event_handle_multi_npu(self): |
| 125 | if skip_ipc_event_case: | 125 | if skip_ipc_event_case: |
| 126 | return | 126 | return |
| @@ -152,7 +152,7 @@ class Test_ipc_event(TestCase): | |||
| 152 | c2p.put(1) # notify synchronization is done in child | 152 | c2p.put(1) # notify synchronization is done in child |
| 153 | p2c.get() # wait for parent to finish before destructing child event | 153 | p2c.get() # wait for parent to finish before destructing child event |
| 154 | 154 | ||
| 155 | - @SupportedDevices(['Ascend910B']) | 155 | + @SupportedDevices(['Ascend910B', 'Ascend910C']) |
| 156 | def test_event_handle_importer(self): | 156 | def test_event_handle_importer(self): |
| 157 | if skip_ipc_event_case: | 157 | if skip_ipc_event_case: |
| 158 | return | 158 | return |
| @@ -189,7 +189,7 @@ class Test_ipc_event(TestCase): | |||
| 189 | # destructing e1 | 189 | # destructing e1 |
| 190 | p2c.get() | 190 | p2c.get() |
| 191 | 191 | ||
| 192 | - @SupportedDevices(['Ascend910B']) | 192 | + @SupportedDevices(['Ascend910B', 'Ascend910C']) |
| 193 | def test_event_handle_exporter(self): | 193 | def test_event_handle_exporter(self): |
| 194 | if skip_ipc_event_case: | 194 | if skip_ipc_event_case: |
| 195 | return | 195 | return |
| @@ -424,6 +424,16 @@ int64_t DriverVersionToNum(std::string versionStr) | |||
| 424 | bVersion = 1; | 424 | bVersion = 1; |
| 425 | } | 425 | } |
| 426 | } | 426 | } |
| 427 | + if (!parsed && isDigits(tokens[index2]) && StartsWith(tokens[index3], "b") && !StartsWith(tokens[index3], "beta") && tokens[index3].length() > validLength1) { | ||
| 428 | + std::string buildNumStr = tokens[index3].substr(1); // eg: 26.1.0.b083, strip the "b" prefix | ||
| 429 | + int64_t buildNum = ExtractNumFromStr(buildNumStr); | ||
| 430 | + if (buildNum != -1) { | ||
| 431 | + patch = buildNum; | ||
| 432 | + parsed = true; | ||
| 433 | + } else { | ||
| 434 | + patch = 0; | ||
| 435 | + } | ||
| 436 | + } | ||
| 427 | } | 437 | } |
| 428 | 438 | ||
| 429 | if (!parsed) { | 439 | if (!parsed) { |
| @@ -385,14 +385,25 @@ bool IsSupportIpcEvent(bool ignore_error) | |||
| 385 | { | 385 | { |
| 386 | static string dbg_msg = ""; | 386 | static string dbg_msg = ""; |
| 387 | const static bool is_support = []() -> bool { | 387 | const static bool is_support = []() -> bool { |
| 388 | - constexpr long supported_page_size = 4096; | 388 | + const std::string kMinDriverVersionForNon4KPage = "26.0.RC1"; |
| 389 | - long size = sysconf(_SC_PAGE_SIZE); | 389 | + bool skip_page_size_check = IsGteDriverVersion(kMinDriverVersionForNon4KPage); |
| 390 | - if (size != supported_page_size) { | 390 | + |
| 391 | - dbg_msg = "IPC Event is not support because IPC event requires page size " + | 391 | + // Record page-size context once; appended to later failure/success messages so the |
| 392 | - std::to_string(supported_page_size) + | 392 | + // "skipped 4K check" context is not lost when a downstream check overwrites dbg_msg. |
| 393 | - " but current page size is " + std::to_string(size) + | 393 | + if (!skip_page_size_check) { |
| 394 | - ", which is not supported by the current HDK(driver)."; | 394 | + constexpr long supported_page_size = 4096; |
| 395 | - return false; | 395 | + long size = sysconf(_SC_PAGE_SIZE); |
| 396 | + if (size != supported_page_size) { | ||
| 397 | + dbg_msg = "IPC Event is not support because IPC event requires page size " + | ||
| 398 | + std::to_string(supported_page_size) + | ||
| 399 | + " but current page size is " + std::to_string(size) + | ||
| 400 | + ", which is not supported by the current HDK(driver)."; | ||
| 401 | + return false; | ||
| 402 | + } | ||
| 403 | + } else { | ||
| 404 | + long size = sysconf(_SC_PAGE_SIZE); | ||
| 405 | + ASCEND_LOGD("skip page size check (driver >= %s, current page size is %ld)", | ||
| 406 | + kMinDriverVersionForNon4KPage.c_str(), size); | ||
| 396 | } | 407 | } |
| 397 | 408 | ||
| 398 | if (!IsExistCreateEventExWithFlag()) { | 409 | if (!IsExistCreateEventExWithFlag()) { |
🟡 Medium Priority
新增的 b-build 解析分支(第 427-436 行)在匹配 "X.Y.release.bN" 格式时只提取了
patch = buildNum,但没有从tokens[index2]提取release值。该分支前置条件isDigits(tokens[index2])已经确保第 3 个 token 是纯数字,但未调用release = ExtractNumFromStr(tokens[index2])。导致问题:
release保持初始值 -1,计算时(release+1) * 10000 = 0。对于 "26.1.0.b083" 和 "26.1.5.b083",两者得到相同的数值(仅patch部分不同),release 号 5 被完全忽略。影响范围:如果驱动版本存在跨 release 号的 b-build(如 26.1.0.b083 和 26.1.5.b083),
IsGteDriverVersion的比较结果会出错——它将无法区分这两个版本。对比同文件中其他 4-token 分支(第 383-391 行纯数字分支),该分支正确调用了
release = ExtractNumFromStr(tokens[index2])。但需注意:如果提取 release 会引入一个问题——在公式中
(release+1)*10000会使 b-build 版本值超过正式发布版(formal release)。如需保持 b-build < formal 的排序,可能需要调整公式或将 b-build 的 release 贡献改为其他编码方式。当前代码未提取 release 可能是刻意的设计权衡,但至少应加注释说明。建议:至少添加注释说明 release 有意保持 -1 以保证 b-build < formal release 的排序顺序。若需支持不同 release 号的 b-build 版本比较,需重新设计公式中 b-build 的贡献方式,使其不覆盖 release 项。