一键导入
paracodex-cuda-omp-step1
ParaCodex prompt for cuda omp step1 step.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
ParaCodex prompt for cuda omp step1 step.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | paracodex-cuda-omp-step1 |
| description | ParaCodex prompt for cuda omp step1 step. |
Directory: {kernel_dir}/
Files: {file_listing}
Reference: {kernel_dir}/analysis.md
Required:
OMP_TARGET_OFFLOAD=MANDATORY for all runstarget teams loop first for OpenMP 5+ GPU offload, but keep or switch to target teams distribute parallel for when it better matches the original CUDA structure or produces better device code on this compiler/runtime.cudaMalloc, cudaMemcpy, kernel<<<>>>)IMPORTANT: YOU MAY MODIFY THE MAKEFILE TO ADD ANYTHING YOU NEED TO RUN THE CODE.
Structural Goal: Recover or improve on the original CUDA hot-path structure. Do not preserve a weak literal translation if a fused or flattened OpenMP offload unit will perform better.
Save backup of {file_listing}.
# Baseline cuda output is in baseline_output.txt in {kernel_dir}/
Walk through IN ORDER, stop at first match:
RULE 1: Type B (Sparse/CSR)? → STRATEGY A/C
RULE 2: Type C1 (Iterative Solvers)? → STRATEGY C
RULE 3: Type C2 (Multigrid)? → STRATEGY A
RULE 4: Multiple independent kernels? → STRATEGY B
RULE 5: Otherwise → STRATEGY A
MANDATORY: Create data_plan.md in {kernel_dir} using the template in references/output.md.
FIRST: Understand CUDA memory model and map to OMP:
cudaMalloc → omp_target_alloc OR target data map(alloc)cudaMemcpy H→D → map(to) OR omp_target_memcpycudaMemcpy D→H → map(from) OR omp_target_memcpytarget teams loop with is_device_ptrPattern Recognition: See references/examples.md.
Analyze ALL arrays and kernels in timed region.
system_info_summary.txt; push to the largest short-run, memory-safe input that should load the GPU meaningfully on this device.Use data_plan.md as implementation guide.
Reference: references/examples.md (Migration Pattern & Syntax Limitations).
cudaMalloc/cudaFree.cudaMemcpy.<<<grid, block>>>. Use OpenMP pragmas.__global__ void functions to standard C void functions.#pragma omp target teams loop is_device_ptr(...) inside the function.references/examples.md.data_plan.md.nowait on independent target regions to allow async dispatch; synchronize with #pragma omp taskwait only where results are needed:
#pragma omp target teams loop nowait depend(out: d_a[0:N])
for (int i = 0; i < N; i++) { ... }
#pragma omp taskwait // wait before D→H transfer
blockIdx/threadIdx with loop iterators.if (idx < N) guards (handled by loop bounds).atomicAdd → #pragma omp atomic update__syncthreads() → Split kernel OR remove if not critical.data.arr BAD). Extract to double *d_arr = data.arr FIRST (See references/examples.md).<RUN_ARGS>, <PROGRAM_NAME>, <SOURCE_FILES>, etc.) with real values.Makefile.nvc supports a plain make -f Makefile.nvc run with no ad hoc variable overrides.{clean_cmd_str}
{build_cmd_str}
timeout 300 {run_cmd_str} > gpu_output.txt 2>&1
diff baseline_output.txt gpu_output.txt
{clean_cmd_str}
{nsys_profile_cmd} > {profile_log_path} 2>&1
# Fallback: {nsys_profile_fallback_cmd} > {profile_log_path} 2>&1
grep -E "cuda_gpu_kern|CUDA GPU Kernel|GPU activities" {profile_log_path} | head -10
make -f Makefile.nvc run succeeds as the final run check.{nsys_profile_cmd} > {profile_log_path} 2>&1 produces GPU kernel information in the log.ParaCodex baseline skill: translate serial / parallel code to GPU-offloaded target API, optimize, compile, and run — all in a single session.
ParaCodex prompt for cuda to hip analysis step.
ParaCodex prompt for cuda to hip step1 (implementation) step.
ParaCodex prompt for cuda to hip step2 (optimization) step.
ParaCodex prompt for cuda ocl analysis step.
ParaCodex prompt for cuda ocl step1 step.