Skip to content

改善 MACA 运行时错误信息#17

Open
ghangz wants to merge 1 commit into
MetaX-MACA:mainfrom
ghangz:mengz/clarify-maca-runtime-errors
Open

改善 MACA 运行时错误信息#17
ghangz wants to merge 1 commit into
MetaX-MACA:mainfrom
ghangz:mengz/clarify-maca-runtime-errors

Conversation

@ghangz

@ghangz ghangz commented Jun 8, 2026

Copy link
Copy Markdown

该 PR 改善 mcTVM 在 MACA 运行时初始化失败时的错误提示,将缺少库、路径错误和设备不可见等情况以更明确的信息返回。

这个修改面向沐曦 GPU 适配场景中比较容易影响开发、构建或验证稳定性的环节,把原来需要人工排查的问题前移到工具链、运行前检查或基准脚本中处理。实现上保持对现有默认行为的兼容,只在检测到明确配置、输入或环境异常时给出更直接的诊断,避免引入额外运行依赖,也方便维护者独立审阅该分支。

已在沐曦算力环境中完成对应分支验证,验证记录包含真实运行日志、命令输出和失败路径检查,本地归档目录为:E:/Documents/muxi/测试报告/mcTVM_new_toolchain_validation_20260608。提交分支:mengz/clarify-maca-runtime-errors,目标仓库:MetaX-MACA/mcTVM

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +47 to 52
#define MACA_CALL(func) \
{ \
mcError_t e = (func); \
ICHECK(e == mcSuccess) << "MACA runtime call failed: " #func " returned " << static_cast<int>(e) \
<< " (" << mcGetErrorString(e) << ")"; \
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

使用单纯的大括号 { ... } 定义多语句宏在某些上下文中(例如没有大括号的 if-else 分支)可能会导致编译错误。推荐使用标准的 do { ... } while (0) 结构来包裹宏定义,以确保宏在所有使用场景下都能安全展开。

建议对 MACA_CALL 进行如下修改,同时建议对 MACA_DRIVER_CALL 也进行类似的修改。

Suggested change
#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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant