Hpc code reviewer
Skill SamyakJhaveri/loam/seed/_research/skills/hpc-code-reviewer
Copier template that bootstraps AI-agent-optimized project setups: layered context routing, curated skills, and an enforced validation gate — synced across projects.
npx -y skills add SamyakJhaveri/loam --skill hpc-code-reviewerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Code review checklist for parallel code correctness in CUDA, OpenMP, and OpenCL. Use when reviewing LLM-generated parallel code translations, when auditing benchmark source code for correctness issues, when writing the paper's 'common failure modes' section, or when a translated kernel has a subtle VERIFY_FAIL that needs root cause analysis. Covers data races, memory model violations, synchronization bugs, numerical precision issues, and API-specific pitfalls.
SKILL.md
4.5 KB, 955 tokens by cl100k_base, as published. Nobody here has run it
HPC Code Reviewer
Structured code review for parallel code correctness. Targets CUDA, OpenMP, and OpenCL code — both human-written benchmark sources and LLM-generated translations.
Trigger: /hpc-code-reviewer or when reviewing parallel code for correctness.
When to use
- Diagnosing VERIFY_FAIL in eval results (subtle correctness bugs)
- Reviewing LLM-generated translations for common parallel programming errors
- Auditing benchmark source code before adding to spec corpus
- Writing paper analysis of failure mode taxonomy
Review Checklist
1. Data Races
CUDA:
- Multiple threads writing to same global memory location without atomics
- Shared memory accessed without
__syncthreads()between write and read phases - Warp-divergent code accessing shared memory (bank conflicts are perf, not correctness)
OpenMP:
- Shared variable written inside
parallel forwithoutreduction,atomic, orcritical - Loop-carried dependency without proper
orderedor serialization -
firstprivate/lastprivatemisuse — variable scope incorrect
OpenCL:
- Local memory (
__local) accessed withoutbarrier(CLK_LOCAL_MEM_FENCE) - Global memory written by multiple work-items without atomic functions
- Missing
mem_fence()between global reads and local writes
2. Memory Model Violations
- CUDA: Reading from
__shared__before all threads in block have written (missing__syncthreads()) - OpenMP: Assuming memory visibility without
flush(implicit in most constructs, but explicit when usingomp_lock_t) - OpenCL: Mixing
CLK_LOCAL_MEM_FENCEandCLK_GLOBAL_MEM_FENCEincorrectly - Cross-API: Assuming same memory ordering guarantees across APIs
3. Synchronization Bugs
- Barrier inside conditional branch (undefined behavior in OpenMP and OpenCL)
- Missing barrier between producer-consumer phases in multi-pass algorithms
- Deadlock from nested critical sections or mismatched lock/unlock
- Over-synchronization (correct but kills performance — note but don't flag as bug)
4. Numerical Precision
- Reduction order difference producing different FP results (inherent — not a bug)
- Missing
volatileon shared accumulator when order matters -
floatvsdoublemismatch between source and translation - Fused multiply-add (
fma) vs separate multiply+add producing different results
5. API-Specific Pitfalls
CUDA:
-
texture<>usage (removed in CUDA 12 — use texture objects) - Deprecated memory management (
cudaMallocHostvscudaHostAlloc) - Kernel launch with 0 threads in any dimension
OpenMP:
-
num_threads()clause that silently reduces parallelism -
schedule(static)whendynamicis needed for load balance -
collapse(2)on non-rectangular loops
OpenCL:
- Kernel-only translation missing host-side buffer creation and enqueue
- Work-group size not evenly dividing global size
- Missing
clFinish()/clFlush()before reading results
6. Translation-Specific Issues
- Leftover source-API identifiers that don't exist in target API
- Control flow restructuring that changes algorithm semantics
- Off-by-one errors from index mapping (CUDA 0-based thread ID → OpenMP loop bounds)
- Missing initialization of variables that the source API zero-initializes
Severity Classification
| Severity | Meaning | Example |
|---|---|---|
| P0: Correctness | Wrong results or crash | Data race on output array |
| P1: Portability | Works on some configs, fails on others | Hardcoded warp size (32) |
| P2: Performance | Correct but unnecessarily slow | Critical section around entire loop body |
| P3: Style | Correct but hard to maintain | Preserved CUDA naming in OpenMP code |
Output Format
For each issue found, report:
[P<severity>] <category> — <one-line description>
File: <path>:<line>
Evidence: <relevant code snippet>
Fix: <what the correct code should look like>