Ascend/msagent / skills/operator/mssanitizer-basic-usage
mssanitizer-basic-usage
Verified昇腾AscendC算子异常检测工具(msSanitizer)。检测内存越界、内存泄漏、数据竞争、未初始化读取、同步异常等缺陷。触发关键词:mssanitizer、sanitizer、检测工具、内存检测、竞争检测、初始化检测、同步检测
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 24.7 KB |
| evals/evals.json | config | 6.8 KB |
| references/alarms.md | markdown | 29.6 KB |
| references/official_workflow.md | markdown | 25.1 KB |
| references/sample_initcheck/CMakeLists.txt | markdown | 1.2 KB |
| references/sample_initcheck/README.md | markdown | 4.8 KB |
| references/sample_initcheck/initcheck.asc | other | 2.3 KB |
| references/sample_memcheck/CMakeLists.txt | markdown | 1.2 KB |
| references/sample_memcheck/README.md | markdown | 4.9 KB |
| references/sample_memcheck/memcheck.asc | other | 2.4 KB |
| references/sample_racecheck/CMakeLists.txt | markdown | 1.2 KB |
| references/sample_racecheck/README.md | markdown | 6.6 KB |
| references/sample_racecheck/racecheck.asc | other | 2.5 KB |
| references/sample_synccheck/CMakeLists.txt | markdown | 1.2 KB |
| references/sample_synccheck/README.md | markdown | 4.1 KB |
| references/sample_synccheck/synccheck.asc | other | 2.8 KB |
| scripts/parse_mssanitizer_report.py | script | 19.0 KB |
| scripts/run_mssanitizer.py | script | 12.3 KB |
references/sample_synccheck/synccheck.asc
View on GitHub/**
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
/* !
* \file synccheck.asc
* \brief 算子同步检测样例,演示 mssanitizer 对算子同步异常的检测和定位
*/
#include "acl/acl.h"
#include "kernel_operator.h"
class DataMover {
public:
__aicore__ inline DataMover() = default;
__aicore__ inline void Init(GM_ADDR src, GM_ADDR dst)
{
srcGlobal.SetGlobalBuffer((__gm__ uint8_t*)src, bufSize);
dstGlobal.SetGlobalBuffer((__gm__ uint8_t*)dst, bufSize);
}
__aicore__ inline void Process()
{
AscendC::LocalMemAllocator<AscendC::Hardware::UB> ubAlloc;
AscendC::LocalTensor<uint8_t> localBuf = ubAlloc.Alloc<uint8_t, bufSize>();
// 从 Global Memory 搬运到 Local Memory
AscendC::DataCopy(localBuf, srcGlobal, bufSize);
// 孤立 SetFlag,缺少对应 WaitFlag,触发同步异常
AscendC::SetFlag<AscendC::HardEvent::V_MTE2>(EVENT_ID0);
// 从 Local Memory 搬运回 Global Memory
AscendC::DataCopy(dstGlobal, localBuf, bufSize);
}
private:
constexpr static uint32_t bufSize = 256;
AscendC::GlobalTensor<uint8_t> srcGlobal;
AscendC::GlobalTensor<uint8_t> dstGlobal;
};
__global__ __vector__ void copy_demo(GM_ADDR src, GM_ADDR dst)
{
AscendC::InitSocState();
DataMover op;
op.Init(src, dst);
op.Process();
}
int32_t main(int32_t argc, char* argv[])
{
constexpr uint32_t bufSize = 256;
size_t bufBytes = bufSize * sizeof(uint8_t);
aclInit(nullptr);
int32_t deviceId = 0;
aclrtSetDevice(deviceId);
aclrtStream stream = nullptr;
aclrtCreateStream(&stream);
uint8_t* devSrc = nullptr;
uint8_t* devDst = nullptr;
aclrtMalloc((void**)&devSrc, bufBytes, ACL_MEM_MALLOC_HUGE_FIRST);
aclrtMalloc((void**)&devDst, bufBytes, ACL_MEM_MALLOC_HUGE_FIRST);
// 初始化源缓冲区,避免未初始化读取(initcheck)干扰 synccheck 检测结果
aclrtMemset(devSrc, bufBytes, 0, bufBytes);
copy_demo<<<1, nullptr, stream>>>(devSrc, devDst);
aclrtSynchronizeStream(stream);
aclrtFree(devSrc);
aclrtFree(devDst);
aclrtDestroyStream(stream);
aclrtResetDevice(deviceId);
aclFinalize();
return 0;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |