APPy: Annotated Parallelism for Python on GPUs

Tong Zhou, J. Shirako, Vivek Sarkar
{"title":"APPy: Annotated Parallelism for Python on GPUs","authors":"Tong Zhou, J. Shirako, Vivek Sarkar","doi":"10.1145/3640537.3641575","DOIUrl":null,"url":null,"abstract":"GPUs are increasingly being used used to speed up Python applications in the scientific computing and machine learning domains. Currently, the two common approaches to leveraging GPU acceleration in Python are 1) create a custom native GPU kernel, and import it as a function that can be called from Python; 2) use libraries such as CuPy, which provides pre-defined GPU-implementation-backed tensor operators. The first approach is very flexible but requires tremendous manual effort to create a correct and high performance GPU kernel. While the second approach dramatically improves productivity, it is limited in its generality, as many applications cannot be expressed purely using CuPy’s pre-defined tensor operators. Additionally, redundant memory access can often occur between adjacent tensor operators due to the materialization of intermediate results. In this work, we present APPy (Annotated Parallelism for Python), which enables users to parallelize generic Python loops and tensor expressions for execution on GPUs by adding simple compiler directives (annotations) to Python code. Empirical evaluation on 20 scientific computing kernels from the literature on a server with an AMD Ryzen 7 5800X 8-Core CPU and an NVIDIA RTX 3090 GPU demonstrates that with simple pragmas APPy is able to generate more efficient GPU code and achieves significant geometric mean speedup relative to CuPy (30 × on average), and to three state-of-the-art Python compilers, Numba (8.3 × on average), DaCe-GPU (3.1 × on average) and JAX-GPU (18.8 × on average). CCS","PeriodicalId":147184,"journal":{"name":"International Conference on Compiler Construction","volume":"54 8","pages":"113-125"},"PeriodicalIF":0.0000,"publicationDate":"2024-02-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"International Conference on Compiler Construction","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3640537.3641575","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

GPUs are increasingly being used used to speed up Python applications in the scientific computing and machine learning domains. Currently, the two common approaches to leveraging GPU acceleration in Python are 1) create a custom native GPU kernel, and import it as a function that can be called from Python; 2) use libraries such as CuPy, which provides pre-defined GPU-implementation-backed tensor operators. The first approach is very flexible but requires tremendous manual effort to create a correct and high performance GPU kernel. While the second approach dramatically improves productivity, it is limited in its generality, as many applications cannot be expressed purely using CuPy’s pre-defined tensor operators. Additionally, redundant memory access can often occur between adjacent tensor operators due to the materialization of intermediate results. In this work, we present APPy (Annotated Parallelism for Python), which enables users to parallelize generic Python loops and tensor expressions for execution on GPUs by adding simple compiler directives (annotations) to Python code. Empirical evaluation on 20 scientific computing kernels from the literature on a server with an AMD Ryzen 7 5800X 8-Core CPU and an NVIDIA RTX 3090 GPU demonstrates that with simple pragmas APPy is able to generate more efficient GPU code and achieves significant geometric mean speedup relative to CuPy (30 × on average), and to three state-of-the-art Python compilers, Numba (8.3 × on average), DaCe-GPU (3.1 × on average) and JAX-GPU (18.8 × on average). CCS
APPy:GPU 上 Python 的注释并行性
在科学计算和机器学习领域,GPU 被越来越多地用于加速 Python 应用程序。目前,在 Python 中利用 GPU 加速的两种常见方法是:1)创建自定义的本地 GPU 内核,并将其导入为可从 Python 调用的函数;2)使用 CuPy 等库,这些库提供了预定义的 GPU 实现支持的张量运算符。第一种方法非常灵活,但要创建一个正确且高性能的 GPU 内核,需要大量的手动操作。第二种方法虽然能显著提高工作效率,但通用性有限,因为许多应用无法纯粹使用 CuPy 的预定义张量运算符来表达。此外,由于中间结果的具体化,相邻张量算子之间经常会出现冗余内存访问。在这项工作中,我们提出了APPy(Annotated Parallelism for Python),通过在Python代码中添加简单的编译器指令(注释),用户就能对通用Python循环和张量表达式进行并行化处理,以便在GPU上执行。在一台配备 AMD Ryzen 7 5800X 8 核 CPU 和 NVIDIA RTX 3090 GPU 的服务器上,对文献中的 20 个科学计算内核进行的实证评估表明,通过简单的注解,APPy 能够生成更高效的 GPU 代码,与 CuPy(平均 30 倍)和三种最先进的 Python 编译器 Numba(平均 8.3 倍)、DaCe-GPU(平均 3.1 倍)和 JAX-GPU(平均 18.8 倍)。CCS
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信