arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2305.01867cs.DC
收藏

使用PyCUDA的实践:重构光线-曲面相交算法的现有实现

An experience with PyCUDA: Refactoring an existing implementation of a ray-surface intersection algorithm

Raymond Leung

AI总结:

本文作为CUDA光线-曲面相交算法GPU实现研究的续作,基于原有CUDA代码完成PyCUDA版本重构,分享迁移关键改动、自定义数据结构实现、潜在陷阱及无需CUDA-GDB的Python调试策略,为PyCUDA初学者提供实操参考。

摘要:

本文是《基于CUDA的光线-曲面相交算法GPU实现》(arXiv:2209.02878)[1]的续作,核心研究对象为PyCUDA——一种在计算统一设备架构(CUDA)框架下,通过Python脚本实现GPU运行时代码生成的方案。本文配套GitHub上发布的开源代码,该代码提供了基于GPU的线段-曲面三角形相交测试的PyCUDA实现,研究目标是向PyCUDA初学者分享相关学习经验。我们以文献[1]中的现有CUDA代码和基础为起点,记录了为实现向PyCUDA的迁移所做的关键改动。由于光线-曲面相交测试的CUDA源码同时包含主机端与设备端代码,且使用多个核函数,这些笔记为使用PyCUDA的实际体验提供了详实的示例与真实场景视角。文中深入探讨了二进制基数树等自定义数据结构,并指出了一些可能的陷阱。案例研究提出了一种调试策略,无需CUDA-GDB调试器,即可使用标准Python工具检查设备内存中的复杂C语言结构。

英文摘要:

This article is a sequel to "GPU implementation of a ray-surface intersection algorithm in CUDA" (arXiv:2209.02878) [1]. Its main focus is PyCUDA which represents a Python scripting approach to GPU run-time code generation in the Compute Unified Device Architecture (CUDA) framework. It accompanies the open-source code distributed in GitHub which provides a PyCUDA implementation of a GPU-based line-segment, surface-triangle intersection test. The objective is to share a PyCUDA learning experience with people who are new to PyCUDA. Using the existing CUDA code and foundation from [1] as the starting point, we document the key changes made to facilitate a transition to PyCUDA. As the CUDA source for the ray-surface intersection test contains both host and device code and uses multiple kernel functions, these notes offer a substantive example and real-world perspective of what it is like to utilize PyCUDA. It delves into custom data structures such as binary radix tree and highlights some possible pitfalls. The case studies present a debugging strategy which may be used to examine complex C structures in device memory using standard Python tools without the CUDA-GDB debugger.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑