一键导入
port-to-opencl
Porting Fortran/C++→PyOpenCL — OpenCLBase, kernel caching, persistent buffers, GPU performance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Porting Fortran/C++→PyOpenCL — OpenCLBase, kernel caching, persistent buffers, GPU performance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Before writing new code — search existing implementations, topical audits, READMEs, file-header caveats
After implementing — update file headers, README, topical audits; note duplication
Navigate and debug OrbitalWar / SpaceCraft — design, truss sim, combat, radiosity, orbits; hub to docs and tests
Diagnostic plots/visualizations — shared utilities, output paths, plot style conventions
Dedicated documentation work — OKF format, topical audits, extract-overview and inline-doc workflows
Writing new code — inventory-first, module-vs-script placement, no-new-files, STOP triggers for duplication
| name | port-to-opencl |
| description | Porting Fortran/C++→PyOpenCL — OpenCLBase, kernel caching, persistent buffers, GPU performance |
| trigger | {"glob":["**/*.cl","**/fortran/**/*","**/cpp/**/*.cpp","**/cpp/**/*.h","**/pyBall/OCL/**/*"]} |
Always start with PyOpenCL before CUDA. Benefits:
.cl files, reload instantlyGPU is always single-precision (float32). Use %f instead of %g, avoid double for numerical speed.
Inherit from pyBall/OCL/OpenCLBase.py for efficient GPU resource management:
Kernel caching: Compile once during __init__, cache in self.prg. Skip recompilation on subsequent calls.
if not self.load_program(rel_path="../../cpp/common_resources/cl/FitREQ.cl", base_path=base_path):
exit(1)
Build option caching: If your GUI toggles compile-time flags (collision on/off, debug prints on/off, dynamics vs relaxation), cache the last-used build flags tuple and only recompile when flags actually change. Do not recreate the program object on every checkbox click — multi-second freezes mask real bugs and make interactive debugging impossible.
Persistent buffer management: Allocate once, reuse across calls. Use try_make_buffers() which checks size and only reallocates if needed.
buffs = {"input": sz, "output": sz}
self.try_make_buffers(buffs, suffix="_buff") # stored in self.buffer_dict
bTryAllocate guards: Guard buffer allocation with if bTryAllocate: to skip dict creation and allocation in hot paths.
def my_kernel(self, data, bTryAllocate=True):
if bTryAllocate:
buffs = {"input": sz, "output": sz}
self.try_make_buffers(buffs, suffix="_buff")
self.toGPU_(self.input_buff, data)
self.prg.my_kernel(self.queue, gs, ls, self.input_buff, self.output_buff)
return self.fromGPU_(self.output_buff)
First call: allocates buffers. Subsequent calls with same sizes: skips allocation.
Workflow: Setup references → Scan microtests → Structural integrity → Block-level parity → Dense reassembly → End-to-end term → Debug drill (bisect).