改善 MACA 运行时错误信息#17
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves MACA error logging messages in src/runtime/maca/maca_common.h by making them more descriptive and casting error codes to integers. It also adds a test script tests/scripts/check_maca_error_messages.py to verify the presence of the new error messages and the absence of stale wording. The reviewer recommended wrapping the multi-statement macros in do { ... } while (0) instead of plain curly braces to prevent potential compilation issues in certain contexts.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| #define MACA_CALL(func) \ | ||
| { \ | ||
| mcError_t e = (func); \ | ||
| ICHECK(e == mcSuccess) << "MACA runtime call failed: " #func " returned " << static_cast<int>(e) \ | ||
| << " (" << mcGetErrorString(e) << ")"; \ | ||
| } |
There was a problem hiding this comment.
使用单纯的大括号 { ... } 定义多语句宏在某些上下文中(例如没有大括号的 if-else 分支)可能会导致编译错误。推荐使用标准的 do { ... } while (0) 结构来包裹宏定义,以确保宏在所有使用场景下都能安全展开。
建议对 MACA_CALL 进行如下修改,同时建议对 MACA_DRIVER_CALL 也进行类似的修改。
| #define MACA_CALL(func) \ | |
| { \ | |
| mcError_t e = (func); \ | |
| ICHECK(e == mcSuccess) << "MACA runtime call failed: " #func " returned " << static_cast<int>(e) \ | |
| << " (" << mcGetErrorString(e) << ")"; \ | |
| } | |
| #define MACA_CALL(func) \ | |
| do { \ | |
| mcError_t e = (func); \ | |
| ICHECK(e == mcSuccess) << "MACA runtime call failed: " #func " returned " << static_cast<int>(e) \ | |
| << " (" << mcGetErrorString(e) << ")"; \ | |
| } while (0) |
该 PR 改善 mcTVM 在 MACA 运行时初始化失败时的错误提示,将缺少库、路径错误和设备不可见等情况以更明确的信息返回。
这个修改面向沐曦 GPU 适配场景中比较容易影响开发、构建或验证稳定性的环节,把原来需要人工排查的问题前移到工具链、运行前检查或基准脚本中处理。实现上保持对现有默认行为的兼容,只在检测到明确配置、输入或环境异常时给出更直接的诊断,避免引入额外运行依赖,也方便维护者独立审阅该分支。
已在沐曦算力环境中完成对应分支验证,验证记录包含真实运行日志、命令输出和失败路径检查,本地归档目录为:E:/Documents/muxi/测试报告/mcTVM_new_toolchain_validation_20260608。提交分支:
mengz/clarify-maca-runtime-errors,目标仓库:MetaX-MACA/mcTVM。