cuda-omp-translatorlisted
Install: claude install-skill SamyakJhaveri/loam
# CUDA ↔ OpenMP Translation Guide
Reference for evaluating LLM-generated translations between CUDA and OpenMP. Organized by
pattern category — each section describes the source construct, the correct target construct,
and the failure modes LLMs commonly produce.
**Trigger:** `/cuda-omp-translator` or when reviewing CUDA↔OMP eval results.
## When to use
- Reviewing why an LLM translation got BUILD_FAIL or VERIFY_FAIL
- Writing paper sections about translation difficulty or pattern analysis
- Comparing translation quality across models for specific construct types
- Creating new benchmark specs for CUDA/OpenMP kernel pairs
## Core Translation Patterns
### 1. Kernel Launch → Parallel Region
**CUDA:**
```c
__global__ void kernel(float *data, int n) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < n) data[tid] = data[tid] * 2.0f;
}
// Launch: kernel<<<grid, block>>>(d_data, n);
```
**OpenMP equivalent:**
```c
#pragma omp parallel for
for (int tid = 0; tid < n; tid++) {
data[tid] = data[tid] * 2.0f;
}
```
**Common LLM failures:**
- Preserving `blockIdx`/`threadIdx` arithmetic instead of using loop index
- Missing `parallel for` — writing just `#pragma omp parallel` without work distribution
- Adding unnecessary `num_threads()` clause that limits parallelism
### 2. Device Memory → Stack/Heap Allocation
**CUDA:** `cudaMalloc`, `cudaMemcpy` (host↔device transfers)
**OpenMP:** Direct pointer use (shared memory space)
**Common LLM failures:**
- Leavin