针对现有的将C或Fortran程序映射到通用图形处理单元(GPU)的自动转换工具主要关注将单个循环生成一个独立的GPU内核,从而阻碍了对循环间数据重用的利用的问题,提出一种新的面向GPU的循环合并的代码变换方法,该方法通过循环分块(stripmining)和冗余计算等手段达到消除迭代间数据依赖的目的,并可充分利用GPU片上的共享内存进行线程间数据交换,从而将此类程序高效地映射到GPU上。通过典型程序在GPU上的实验表明,该新方法由于能够减少对全局内存的访问,带来了最多高达1.96倍的加速比。
To solve the problem that current tools for automatical mapping of C or Fortran programs onto a general purpose graphic processing unit (GPU) mainly aim at generating an independent GPU kernel for each individual loop, which hinders the exploitation of inter-loop data reuse, this paper presents a novel GPU-oriented code transforma- tion approach for loop fusion. The approach integrates strip mining and redundant computation to eliminate data de- pendence between iterations, and takes advantage of GPU' s on-chip shared memory to achieve inter-thread data ex- change so as to map this kind of programs onto GPUs effectively. The experiment on various programs demonstrate that the proposed framework can achieve the 1.96-fold speedup because of its reduction of global memory access.