shmem-ops-compile-debug

Compiles, runs, and diagnoses SHMEM-based Ascend NPU operators with failure classification.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill shmem-ops-compile-debug-wangwindow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shmem-ops-compile-debug
Source: https://github.com/WangWindow/CANN-BatchMatMulMaxsum/tree/main/.agents/skills/shmem-ops-compile-debug
Command: npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill shmem-ops-compile-debug-wangwindow

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building and running SHMEM-based operators on Ascend NPU hardware involves complex environment setup (CANN toolkit, SHMEM libraries, bootstrap plugins) and failures that are hard to classify. This Skill provides a closed-loop workflow for compiling, smoke-testing, and diagnosing SHMEM operator builds without modifying operator source code. ## Core Features & Use Cases - Dual build modes: Supports independent custom-ops projects and in-tree SHMEM examples, with correct CMake templates and build commands for each. - Failure classification: Categorizes failures as compile, link, launch, runtime, correctness, or environment issues, routing code fixes back to the code-generation skill while self-repairing environment problems. - False-failure detection: Diagnoses the common 'all-zero output but SUCCESS' symptom by checking SHMEM logs for port conflicts and uninitialized memory heaps before touching kernel code. - Use Case: After generating a SHMEM allgather operator, use this Skill to build it with the correct CANN environment, run a 2-PE smoke test, and get a reproducible diagnosis when the golden comparison fails. ## Quick Start Compile and run a smoke test for my SHMEM operator in custom-ops/my_op, then classify any failure that occurs.

Frequently Asked Questions about shmem-ops-compile-debug

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compile a SHMEM operator for Ascend NPU?

Source the user-confirmed CANN set_env.sh, build the SHMEM library with scripts/build.sh, then run cmake on the operator project with -DSHMEM_REPO pointing to the SHMEM source tree. In-tree examples use bash scripts/build.sh -examples instead.

Why does my SHMEM operator output all zeros but still print SUCCESS?

This usually means SHMEM initialization failed silently, often from a TCP store port conflict or uninitialized memory heap. Check the aclshmem logs for 'address in use' or 'Memory Heap Not Initialized', then free the port or randomize IPPORT and SHMEM_UID_SESSION_ID before rerunning.

What is the difference between independent project and in-tree example build modes?

Independent projects live under custom-ops/ and link against the prebuilt SHMEM library with their own CMakeLists.txt. In-tree examples live under shmem/examples/ and reuse repository CMake helper functions, requiring the -examples build flag.

Can this Skill fix compile errors in my operator kernel code?

No. It only diagnoses and classifies compile, link, launch, and correctness failures, then routes the diagnosis back to the code-generation skill for fixes. It directly repairs only runtime and environment issues such as environment variables, PE counts, and port conflicts.

How do I debug SHMEM initialization failures with logs?

Set SHMEM_LOG_LEVEL=DEBUG and SHMEM_LOG_TO_STDOUT=1, then rerun the operator. Inspect the bootstrap and init log stages for errors like port binding failures or mismatched local_mem_size across PEs before investigating kernel code.