一句话:提出静态分析工具,在 CUDA kernel 调用点判定实参无别名后克隆 kernel,并自动为其参数添加 restrict 关键字。
C/C++ 等语言中的指针别名会阻碍编译器优化。尽管别名分析已有多年研究,其结果仍不够精确,因此 C99 引入 restrict 关键字让程序员声明非别名关系;但标注完全依赖人工,繁琐且易错,C 语言也不会检查 restrict 是否被误用。本文针对 CUDA 提出一个静态分析工具:首先定位实际参数之间不存在别名的 CUDA kernel 调用点;随后克隆这些调用点所调用的 kernel;接着在克隆体内执行别名分析,为可判定为非别名的参数加上 restrict 限定;最后在可能的情况下把原始调用替换为对优化后克隆体的调用。该工具旨在免除人工 restrict 标注,并借助编译器优化提升性能。摘要未给出实验评估数据。
Many procedural languages, such as C and C++, have pointers. Pointers are powerful and convenient, but pointer aliasing still hinders compiler optimizations, despite several years of research on pointer aliasing analysis. Because alias analysis is a difficult task and results are not always accurate, the ISO C standard 99 has added a keyword, named restrict to allow the programmer to specify non−aliasing as an aid to the compiler′s optimizer and to thereby possibly improve performance. The task of annotating pointers with the restrict keyword is still left to the programmer. This task is, in general, tedious and prone to errors especially since the C does not perform any verification to ensure that restrict keyword is not misplaced. In this paper we present a static analysis tool that (i) finds CUDA kernels call sites in which actual parameters do not alias; (ii) clones the kernels called at such sites; (iii) after performing an alias analysis in these kernels, adds the restrict keyword to their arguments; and (iv) replaces the original kernel call by a call to the optimized clone whenever possible.
DOI 原文 ·
@inproceedings{paperbot4724,
title = {Towards automatic restrictification of CUDA kernel arguments},
author = {Rokiatou Diarra},
booktitle = {ASE},
year = {2018},
doi = {10.1145/3238147.3241533}
}