ソース情報
- リポジトリ
- ZhangXin8069/PyQCU
- ソースの最終更新活動
- 2026年8月24日 17:59
- 検出された SKILL.md の言語
- 英語
- スター
- 3
- フォーク
- 0
インストール方法
デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。
ソースファイルを確認
インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。
メニュー
デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。
インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/ZhangXin8069/PyQCU --skill cudaコマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
PyQCU 性能基准 skill:覆盖 examples/benchmark 的通用基准,以及 dev87 strict MultiGrid 对 QUDA 的可复现公平计时与显存口径。
pyqcu.cuda 目录的完整生成 skill:C++ CUDA 后端(libqcu.so)的 Cython 桥接包;含 strict QUDA-style MultiGrid、params/argv/set_ptrs 参数协议与显存生命周期约束。
cpp/cuda/qcu/include 目录的完整生成 skill:26 个模板化 CUDA 头文件(内核内联),define.h 须镜像 pyqcu/cuda/define.py。
SKILL.md を表示中
| name | cuda |
| description | cpp/cuda 目录的完整生成 skill:CUDA 后端容器目录,真实现位于 qcu/。 |
CUDA backend container directory. The actual implementation lives in qcu/.
This directory exists to mirror the multi-backend structure (cann/, dtk/, maca/) and may contain shared CUDA utilities or a top-level CMakeLists.txt in the future.
The content of each subdirectory below was produced with Claude Code assistance. Per repo convention, the complete skill that generates that content is reproduced verbatim below (source: the subdirectory's own CLAUDE.md), so the full knowledge is available directly at this level.
qcu/ (source: qcu/CLAUDE.md)Primary C++ CUDA backend for PyQCU. Hand-tuned CUDA kernels with MPI halo exchange for Wilson/Clover Dirac operators, BiStabCG/CG solvers, multigrid, and gauge field generation.
source ./env.sh # CUDA toolkit paths, MPI, etc.
bash ./make.sh # symlinks CMakeLists-nv.txt → CMakeLists.txt, then cmake + make
Output: libqcu.so — dynamically linked library loaded by the Cython bridge.
include/ — 26 header files (templated C++ with CUDA kernels inline)
├── define.h — Parameter index constants (must mirror pyqcu/cuda/define.py)
├── lattice_complex.h — Complex number arithmetic (operator*= was fixed for overwrite bug)
├── lattice_set.h — Lattice geometry, grid layout, site indexing
├── lattice_cuda.h — CUDA utility functions (stream management, etc.)
├── lattice_mpi.h — MPI halo exchange helpers (blocking Sendrecv)
├── qcu.h — Top-level include aggregator
├── dslash.h — Dslash dispatch
├── wilson_dslash.h — Wilson dslash kernel
├── clover_dslash.h — Clover dslash entry
├── lattice_wilson_dslash.h — Wilson dslash implementation
├── lattice_clover_dslash.h — Clover dslash implementation
├── bistabcg.h — BiCGStab algorithm (GPU kernels)
├── cg.h — Conjugate gradient algorithm
├── lattice_wilson_bistabcg.h — Wilson BiStabCG solver
├── lattice_wilson_cg.h — Wilson CG solver
├── lattice_clover_bistabcg.h — Clover BiStabCG solver
├── multigrid.h — MG restrict/prolong/coarse-dslash
├── lattice_multigrid.h — MG implementation
├── lattice_clover_multigrid.h — Clover multigrid solver (~1100 lines)
├── laplacian.h / lattice_laplacian.h — Laplacian operator
└── gauss_gauge.h — Gaussian gauge field generation
src/ — .cu files that #include the headers and instantiate kernels
python/
└── pyqcu.h — C API declarations (extern "C"); must match pyqcu/cuda/qcu/qcu.pxd
Parameters are passed from Python as flat arrays. Index constants in include/define.h must stay in sync with pyqcu/cuda/define.py:
params (int32[54]): lattice dims, grid sizes, data types, iteration counts, plan selection, MG level configsargv (float[7]): mass, atol, sigma, MG tolerancesset_ptrs (int64[100]): scratch buffer pointers_SET_PLAN_ (params[16]) selects the kernel plan:
-2 = Laplacian, -1 = Gauss gauge, 0 = Wilson dslash, 1 = BiStabCG/CG, 2 = Clover dslashmain (strm): dslash operations (fine_dslash_op / coarse_dslash_op)
_a_: dot(r_tilde,r) → give_1beta → give_p → give_s → give_r
_b_: give_1rho_prev → give_x_o
_c_: dot(t,s), convergence-check dot(r,r)
_d_: dot(r_tilde,v) → give_1alpha → dot(t,t) → give_1omega
device_vals — no host→device scalar memcpy inside iteration loops_send_tmp_ scratch for dot products — cublasDot → scratch slot 7 → MPI_Allreduce → copy to target (never write cublasDot directly to target)mpi_real_type<T>() template — dispatches MPI_FLOAT/MPI_DOUBLE per template typerun_mpi uses blocking MPI_Sendrecv — no MPI_Wait needed (only run_mpi_non_block requires it)_BLOCK_SIZE_ in define.h: use 8/16 for testing small lattices, 128 for NVIDIA production, 256 for AMD DCU production.
The content of each subdirectory below was produced with Claude Code assistance. Per repo convention, the complete skill that generates that content is reproduced verbatim below (source: the subdirectory's own CLAUDE.md), so the full knowledge is available directly at this level.
include/ (source: include/CLAUDE.md)C++ header files for the CUDA backend. 26 templated headers containing CUDA kernel implementations (kernels are inline in headers).
| Header | Purpose |
|---|---|
define.h | Parameter index constants, block size — must mirror pyqcu/cuda/define.py |
lattice_complex.h | Complex number arithmetic on GPU |
lattice_set.h | Lattice geometry, grid layout, site indexing (use ceiling division for grid dims) |
lattice_cuda.h | CUDA stream management, device utilities |
lattice_mpi.h | MPI halo exchange (blocking MPI_Sendrecv) |
qcu.h | Top-level include aggregator |
dslash.h | Dslash dispatch (Wilson vs Clover) |
wilson_dslash.h | Wilson dslash kernel |
clover_dslash.h | Clover dslash dispatch |
lattice_wilson_dslash.h | Wilson dslash implementation |
lattice_clover_dslash.h | Clover dslash implementation |
bistabcg.h / cg.h | BiCGStab and CG algorithm kernels |
lattice_wilson_bistabcg.h / lattice_wilson_cg.h | Wilson solver wrappers |
lattice_clover_bistabcg.h | Clover BiStabCG solver |
lattice_clover_multigrid.h | Clover multigrid V-cycle (~1100 lines, 5-stream architecture) |
lattice_multigrid.h / multigrid.h | Multigrid restrict/prolong/coarse-dslash |
laplacian.h / lattice_laplacian.h | Laplacian operator |
gauss_gauge.h | Gaussian gauge field generation |
Headers correspond to .cu source files in ../src/ that #include them and instantiate the templates.
src/ (source: src/CLAUDE.md)CUDA kernel source files. Each .cu file #includes the corresponding header from ../include/ and provides template instantiations and kernel launch wrappers.
| File | Purpose |
|---|---|
apply_init.cu / apply_end.cu | Memory allocation/free lifecycle |
apply_dslash.cu | Dslash dispatch (Wilson or Clover based on plan) |
wilson_dslash.cu | Wilson dslash kernel |
clover_dslash_single.cu / clover_dslash_multi.cu / clover_dslash_comm.cu | Clover dslash: single-GPU, multi-GPU, halo exchange |
apply_wilson_bistabcg.cu / apply_wilson_bistabcg_dslash.cu | Wilson BiStabCG solver + its dslash |
apply_wilson_cg.cu / apply_wilson_cg_dslash.cu | Wilson CG solver + its dslash |
apply_clover_bistabcg.cu / apply_clover_bistabcg_dslash.cu | Clover BiStabCG solver + its dslash |
apply_multigrid.cu | MG restrict/prolong/coarse-dslash |
apply_clover_multigrid.cu | Clover multigrid solver entry (C API bridge) |
lattice_mpi.cu | MPI halo exchange helpers |
lattice_cuda.cu | CUDA utility functions |
python/ (source: python/CLAUDE.md)Python-facing C API declarations. This is the interface boundary between the C++ CUDA backend and the Python Cython bridge.
| File | Purpose |
|---|---|
pyqcu.h | C API header — 22 extern "C" functions taking raw pointers as long long |
This header must stay in exact sync with pyqcu/cuda/qcu/qcu.pxd (the Cython declaration file). Any mismatch causes silent memory corruption.
All functions take three parameter arrays:
set_ptrs (int64[100]): scratch buffer pointers managed by C++ runtimeparams (int32[54]): lattice dims, grid sizes, data types, iteration counts, plan selectionargv (float64[7]): mass, atol, sigma, MG tolerancesC++→Python data pointers are cast to long long from tensor.contiguous().data_ptr().
logs/ (source: logs/CLAUDE.md)Runtime output directory for the C++ CUDA backend (cpp/cuda/qcu). Holds generated log files produced by building, testing, and benchmarking the C++ backend.
Currently empty. Logs written here may include:
bash ./make.sh (compiler messages, linker output)examples/qcu/conftest.clover.multigrid.py)cpp/cuda/qcu/logs/ is not tracked in git.logs/ directory (see logs/CLAUDE.md for its file patterns). Only backend-local artifacts belong here.