Graphics Processing Units (GPU) offer tremendous computational power by following a throughput oriented computing paradigm where many thousand computational units operate in parallel. Programming this massively parallel hardware is challenging. Programmers must correctly and efficiently coordinate thousands of threads and their accesses to various shared memory spaces. Existing mainstream GPU programming languages, such as CUDA and OpenCL, are based on C/C++ inheriting their fundamentally unsafe ways to access memory via raw pointers. This facilitates easy to make, but hard to detect bugs such as data races and deadlocks. In this paper, we present Descend: a safe GPU systems programming language. In the spirit of Rust, Descend's type system enforces safe CPU and GPU memory management by tracking Ownership and Lifetimes. Descend introduces a new holistic GPU programming model where computations are hierarchically scheduled over the GPU's execution resources: grid, blocks, and threads. Descend's extended Borrow checking ensures that execution resources safely access memory regions without introducing data races. For this, we introduced views describing safe parallel access patterns of memory regions. We discuss the memory safety guarantees offered by Descend's type system and evaluate our implementation of Descend using a number of benchmarks, showing that no significant runtime overhead is introduced compared to manually written CUDA programs lacking Descend's safety guarantees.
翻译:图形处理单元(GPU)通过采用面向吞吐量的计算范式,使数千个计算单元并行运行,从而提供强大的计算能力。编程这种大规模并行硬件极具挑战性。程序员必须正确且高效地协调数千个线程及其对各种共享内存空间的访问。现有的主流GPU编程语言(如CUDA和OpenCL)基于C/C++,继承了其通过原始指针访问内存的根本性不安全方式。这导致易产生但难检测的bug,例如数据竞争和死锁。本文提出Descend:一种安全的GPU系统编程语言。秉承Rust的设计理念,Descend的类型系统通过追踪所有权(Ownership)和生命周期(Lifetimes)来强制执行安全的CPU与GPU内存管理。Descend引入了一种全新的整体式GPU编程模型,其中计算层次化地在GPU的执行资源(网格、块和线程)上进行调度。Descend扩展的借用检查(Borrow checking)确保执行资源安全地访问内存区域而不引入数据竞争。为此,我们引入了视图(views)来描述内存区域的安全并行访问模式。我们讨论了Descend类型系统提供的内存安全性保证,并通过多项基准测试评估了Descend的实现,结果表明,与缺乏Descend安全性保证的手动编写的CUDA程序相比,Descend未引入显著的运行时开销。