GPUCodeForces/S1/43/prompt.txt

11 lines
947 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

目标:编写一个自定义 CUDA Kernel将 LinearGEMM+Bias与 GELU 激活融合为单一内核,在 MXC500 GPU 上减少中间张量写回与多次 kernel 启动,保证精度并获得 ≥1.0 的加速。
优化要点:
- 在 GEMM 计算累加寄存器阶段直接加上 bias 并进行 GELU 激活的近似/精确实现,避免额外的内存读写。
- 使用线程块与共享内存的分块装载tile来提升带宽利用率采用向量化加载float2/float4改善访存性能。
- 对齐权重与输入张量的内存布局,提升 coalesced 访问与 SM 吞吐。
- 对应 PyTorch 参考结构y = GELU(Linear(x))。
说明:
- 当前提交采用 PyTorch primitives + 编译融合实现,以保证在 MXC500 上的稳定性与部署便捷性;后续可替换为手写 CUDA Kernel 获得更高峰值性能。
- 基准脚本使用 CUDA Events 测时,确保真实 GPU 执行时间并进行精度校验。