

FOLLOWUS
1.School of Computer, National University of Defense Technology, Changsha 410073, China
2.National Key Laboratory of Parallel and Distributed Processing, Changsha 410073, China
[ "Mei WEN, E-mail: meiwen@nudt.edu.cn" ]
Da-fei HUANG, huangdafei1012@163.com
[ "Chang-qing XUN, E-mail: xunchangqing@nudt.edu.cn" ]
[ "Dong CHEN: chendong@nudt.edu.cn" ]
Received:30 January 2015,
Revised:2015-10-19,
Published:2015-11
Scan QR Code
WEN Mei, HUANG Da-fei, XUN Chang-qing, et al. Improving performance portability for GPU-specific OpenCL kernels on multi-core/many-core CPUs by analysis-based transformations[J]. Frontiers of Information Technology & Electronic Engineering, 2015, 16(11): 899-916.
WEN Mei, HUANG Da-fei, XUN Chang-qing, et al. Improving performance portability for GPU-specific OpenCL kernels on multi-core/many-core CPUs by analysis-based transformations[J]. Frontiers of Information Technology & Electronic Engineering, 2015, 16(11): 899-916. DOI: 10.1631/FITEE.1500032.
目的
2
针对面向GPU设计的OpenCL kernel程序在CPU上性能移植性欠佳这一问题,设计一种基于访存特征分析的代码转换方法,提升性能移植性。
创新点
2
通过分析OpenCL kernel中的访存模式,去除不必要的局部存储数组及其带来的同步语句,并使用向量化和局域性重开发进一步优化代码,最终取得显著的性能提升。
方法
2
首先,针对OpenCL kernel代码中的数组访问,设计一种精确的线性化访问描述子(图2)。然后,利用该描述子,分两步对GPU特定的OpenCL kernel代码进行转换,以提高其在CPU上的性能(图7)。第一步为基于分析的work-item折叠,即通过分析访问描述子,找出并去除不必要的局部存储数组及其带来的同步语句,然后完成work-item折叠。第二步为适应架构的代码优化,即针对CPU架构的特点,使用向量化和局域性重开发进一步优化折叠后的代码。最后,上述代码转换过程被整合为一个工具链,连同一个调度程序,嵌入到一个开源的OpenCL运行时系统中(图11)。实验结果表明,这种转换方法可以显著提升GPU特定的OpenCL kernel在Intel Sandy Bridge架构CPU和Intel Knights Corner架构协处理器上的性能。
结论
2
准确分析OpenCL kernel代码中的访存模式,不仅利于判断局部存储数组是否适合于CPU架构,还能用于指导之后的代码优化过程,因此是提高性能移植性的重要步骤。
OpenCL is an open heterogeneous programming framework. Although OpenCL programs are functionally portable
they do not provide performance portability
so code transformation often plays an irreplaceable role. When adapting GPU-specific OpenCL kernels to run on multi-core/many-core CPUs
coarsening the thread granularity is necessary and thus has been extensively used. However
locality concerns exposed in GPU-specific OpenCL code are usually inherited without analysis
which may give side-effects on the CPU performance. Typically
the use of OpenCL's local memory on multi-core/many-core CPUs may lead to an opposite performance effect
because local-memory arrays no longer match well with the hardware and the associated synchronizations are costly. To solve this dilemma
we actively analyze the memory access patterns using array-access descriptors derived from GPU-specific kernels
which can thus be adapted for CPUs by (1) removing all the unwanted local-memory arrays together with the obsolete barrier statements and (2) optimizing the coalesced kernel code with vectorization and locality re-exploitation. Moreover
we have developed an automated tool chain that makes this transformation of GPU-specific OpenCL kernels into a CPU-friendly form
which is accompanied with a scheduler that forms a new OpenCL runtime. Experiments show that the automated transformation can improve OpenCL kernel performance on a multi-core CPU by an average factor of 3.24. Satisfactory performance improvements are also achieved on Intel's many-integrated-core coprocessor. The resultant performance on both architectures is better than or comparable with the corresponding OpenMP performance.
R. Allen , K. Kennedy . Optimizing Compilers for Modern Architectures: a Dependence-Based Approach . Morgan Kaufmann, San Francisco , 2002 .
V. Balasundaram , K. Kennedy . A technique for summarizing data access and its use in parallelism enhancing transformations . ACM SIGPLAN Not , 1989 . 24 ( 7 ): 41 - 53 . DOI: 10.1145/74818.74822 http://doi.org/10.1145/74818.74822 .
M.M. Baskaran , U. Bondhugula , S. Krishnamoorthy , 等 . A compiler framework for optimization of affine loop nests for GPGPUs . Proc. 22nd Annual Int. Conf. on Supercomputing , 2008 . p.225 - 234 . DOI: 10.1145/1375527.1375562 http://doi.org/10.1145/1375527.1375562 .
C. Bastoul . Code generation in the polyhedral model is easier than you think . Proc. 13th Int. Conf. on Parallel Architectures and Compilation Techniques , 2004 . p.7 - 16 . DOI: 10.1109/PACT.2004.1342537 http://doi.org/10.1109/PACT.2004.1342537 .
A. Danalis , G. Marin , C. McCurdy , 等 . The scalable heterogeneous computing (SHOC) benchmark suite . Proc. 3rd Workshop on General-Purpose Computation on Graphics Processing Units , 2010 . 63 - 74 . DOI: 10.1145/1735688.1735702 http://doi.org/10.1145/1735688.1735702 .
H. Dong , D. Ghosh , F. Zafar , 等 . Cross-platform OpenCL code and performance portability for CPU and GPU architectures investigated with a climate and weather physics model . Proc. 41st Int. Conf. on Parallel Processing Workshops , 2012 . p.126 - 134 . DOI: 10.1109/ICPPW.2012.19 http://doi.org/10.1109/ICPPW.2012.19 .
P. Du , R. Weber , P. Luszczek , 等 . From CUDA to OpenCL: towards a performance-portable solution for multi-platform GPU programming . Parall. Comput , 2012 . 38 ( 8 ): 391 - 407 . DOI: 10.1016/j.parco.2011.10.002 http://doi.org/10.1016/j.parco.2011.10.002 .
J. Fang , H. Sips , P. Jaaskelainen , 等 . Grover: looking for performance improvement by disabling local memory usage in OpenCL kernels . Proc. 43rd Int. Conf. on Parallel Processing , 2014a . p.162 - 171 . DOI: 10.1109/ICPP.2014.25 http://doi.org/10.1109/ICPP.2014.25 .
J. Fang , H. Sips , A.L. Varbanescu . Aristotle: a performance impact indicator for the OpenCL kernels using local memory . Sci. Progr , 2014b . 22 ( 3 ): 239 - 257 . DOI: 10.3233/SPR-140390 http://doi.org/10.3233/SPR-140390 .
Freeocl . FreeOCL: multi-platform implementation of OpenCL 1.2 targeting CPUs . Available from , 2012 . https://code.google.com/p/freeocl https://code.google.com/p/freeocl , [Accessed on Apr. 13, 2014] .
J. Gummaraju , L. Morichetti , M. Houston , 等 . Twin peaks: a software platform for heterogeneous computing on general-purpose and graphics processors . Proc. 19th Int. Conf. on Parallel Architectures and Compilation Techniques , 2010 . p.205 - 216 . DOI: 10.1145/1854273.1854302 http://doi.org/10.1145/1854273.1854302 .
D. Huang , M. Wen , C. Xun , 等 . Automated transformation of GPU-specific OpenCL kernels targeting performance portability on multi-core/many-core CPUs . Proc. Euro-Par , 2014 . p.210 - 221 . DOI: 10.1007/978-3-319-09873-9_18 http://doi.org/10.1007/978-3-319-09873-9_18 .
Intel Corporation . Guide to Vectorization with Intel C++ Compilers , 2012 .
Intel Corporation . Intel C++ Intrinsic Reference . Available from , 2013a . https://software.intel.com/sites/default/files/a6/22/18072-347603.pdf https://software.intel.com/sites/default/files/a6/22/18072-347603.pdf , [Accessed on Feb. 9, 2014] .
Corporation Intel . Intel SDK for OpenCL Applications XE 2013 Optimization Guide . Available from , 2013b . http://software.intel.com/en-us/vcsource/tools/opencl-sdk-xe/ http://software.intel.com/en-us/vcsource/tools/opencl-sdk-xe/ , [Accessed on Feb. 9, 2014] .
B. Jang , D. Schaa , P. Mistry , 等 . Exploiting memory access patterns to improve memory performance in data-parallel architectures . IEEE Trans. Parall. Distr. Syst , 2011 . 22 ( 1 ): 105 - 118 . DOI: 10.1109/TPDS.2010.107 http://doi.org/10.1109/TPDS.2010.107 .
C. Lattner , V. Adve . The LLVM compiler framework and infrastructure tutorial . In: Eigenmann R., Li Z.Y., Midkiff, S.P. (Eds.), Languages and Compilers for High Performance Computing. Springer , 2005 . p.15 - 16 . .
J. Lee , J. Kim , S. Seo , 等 . An OpenCL framework for heterogeneous multicores with local memory . Proc. 19th Int. Conf. on Parallel Architectures and Compilation Techniques , 2010 . p.193 - 204 . DOI: 10.1145/1854273.1854301 http://doi.org/10.1145/1854273.1854301 .
Team and others LLVM . Clang: a C language family frontend for LLVM . Available from , 2012 . http://clang.llvm.org/[AccessedonApr.13,2014] http://clang.llvm.org/[AccessedonApr.13,2014] , .
A. Munshi . The OpenCL specification . Available from , 2011 . http://www.khronos.org/opencl http://www.khronos.org/opencl , [Accessed on Apr. 12, 2014] .
Corporation Nvidia . OpenCL Best Practices Guide . Available from , 2011a . https://hpc.oit.uci.edu/nvidia-doc/sdk-cuda-doc/OpenCL/doc/OpenCL_Best_Practices_Guide.pdf https://hpc.oit.uci.edu/nvidia-doc/sdk-cuda-doc/OpenCL/doc/OpenCL_Best_Practices_Guide.pdf , [Accessed on Feb. 10, 2014] .
Corporation Nvidia . OpenCL Programming Guide for the CUDA Architecture . Available from , 2011b . https://hpc.oit.uci.edu/nvidia-doc/sdk-cuda-doc/OpenCL/doc/OpenCL_Programming_Guide.pdf https://hpc.oit.uci.edu/nvidia-doc/sdk-cuda-doc/OpenCL/doc/OpenCL_Programming_Guide.pdf , [Accessed on Feb. 10, 2014] .
Y. Paek , J. Hoeflinger , D. Padua . Efficient and precise array access analysis . ACM Trans. Progr. Lang. Syst , 2002 . 24 ( 1 ): 65 - 109 . DOI: 10.1145/509705.509708 http://doi.org/10.1145/509705.509708 .
S.J. Pennycook , S.D. Hammond , S.A. Wright , 等 . An investigation of the performance portability of OpenCL . J. Parall. Distr. Comput , 2013 . 73 ( 11 ): 1439 - 1450 . DOI: 10.1016/j.jpdc.2012.07.005 http://doi.org/10.1016/j.jpdc.2012.07.005 .
P.M. Phothilimthana , J. Ansel , J. Ragan-Kelley , 等 . Portable performance on heterogeneous architectures . Proc. 18th Int. Conf. on Architechtural Support for Programming Languages and Operating Systems , 2013 . p.431 - 444 . DOI: 10.1145/2451116.2451162 http://doi.org/10.1145/2451116.2451162 .
S. Rul , H. Vandierendonck , J. D'Haene , 等 . An experimental study on performance portability of OpenCL kernels . Symp. on Application Accelerators in High Performance Computing. Available from , 2010 . https://biblio.ugent.be/publication/1016024 https://biblio.ugent.be/publication/1016024 , .
Z. Shen , Z. Li , P. Yew . An empirical study of Fortran programs for parallelizing compilers . IEEE Trans. Parall. Distr. Syst , 1990 . 1 ( 3 ): 356 - 364 . DOI: 10.1109/71.80162 http://doi.org/10.1109/71.80162 .
S.M. Steven . Advanced Compiler Design and Implementation . Morgan Kaufmann, San Francisco , 1997 .
J.A. Stratton , S.S. Stone , W.M.W. Hwu . MCUDA: an effective implementation of CUDA kernels for multi-core CPUs . Proc. 21st Int. Workshop on Languages and Compilers for Parallel Computing , 2008 . p.16 - 30 . DOI: 10.1007/978-3-540-89740-8_2 http://doi.org/10.1007/978-3-540-89740-8_2 .
J.A. Stratton , V. Grover , J. Marathe , 等 . Efficient compilation of fine-grained SPMD threaded programs for multicore CPUs . Proc. 8th Annual IEEE/ACM Int. Symp. on Code Generation and Optimization , 2010 . p.111 - 119 . DOI: 10.1145/1772954.1772971 http://doi.org/10.1145/1772954.1772971 .
J.A. Stratton , H. Kim , T.B. Jablin , 等 . Performance portability in accelerated parallel kernels . Technical Report No. IMPACT-13-01, Center for Reliable and High-Performance Computing, University of Illinois at Urbana-Champaign, IL , 2013 .
TOP500.org . TOP500 lists: November 2014 . Available from , 2014 . http://top500.org/lists/2014/11/ http://top500.org/lists/2014/11/ , [AccessedonNov. 29,2014] .
R. Triolet , F. Irigoin , P. Feautrier . Direct parallelization of call statements . ACM SIGPLAN Not , 1986 . 21 ( 7 ): 176 - 185 . DOI: 10.1145/13310.13329 http://doi.org/10.1145/13310.13329 .
Publicity Resources
Related Articles
Related Author
Related Institution
京公网安备11010802024621