User-Directed GPU Kernel Fusion of Parallel Skeletons Using Metaprogramming

  • João Antonio Soares UFPel
  • André Rauber Du Bois UFPel
  • Gerson Geraldo H. Cavalheiro UFPel

Resumo


Kernel fusion is an important optimization for GPU programs, as it reduces intermediate memory traffic and kernel launch overhead in producer-consumer computations. However, automatic fusion is difficult to integrate into high-level GPU frameworks, especially when kernels are generated dynamically. This paper presents a user-directed runtime kernel fusion mechanism for PolyHok, an Elixir-embedded DSL for GPU programming based on data-parallel skeletons. Programmers explicitly delimit candidate skeleton pipelines, while an Elixir macro performs source-to-source transformations that compose the corresponding computations and generate fused GPU kernels. The implementation does not require changes to the GPU compiler or to the Elixir runtime. An experimental evaluation with synthetic and application-level benchmarks indicates that the proposed mechanism can reduce intermediate memory traffic and improve performance in memory-bound workloads.

Palavras-chave: Kernel Fusion, Metaprogramming, GPU Programming

Referências

Martín Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S. Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, et al. 2016. TensorFlow: Large-Scale Machine Learning on Heterogeneous Distributed Systems. arXiv:1603.04467 [cs.DC]

Aksel Alpay and Vincent Heuveline. 2020. SYCL beyond OpenCL: The architecture, current state and future direction of hipSYCL. In Proceedings of the International Workshop on OpenCL (Munich, Germany) (IWOCL ’20). Association for Computing Machinery, New York, NY, USA, Article 8, 1 pages. DOI: 10.1145/3388333.3388658

Oscar Amoros, Albert Andaluz, Johnny Nunez, and Antonio J. Pena. 2025. The Fused Kernel Library: A C++ API to Develop Highly-Efficient GPU Libraries. arXiv:2508.07071 [cs.DC] [link]

Christian Andreetta, Vivien Bégot, Jost Berthold, Martin Elsman, Fritz Henglein, Troels Henriksen, Maj-Britt Nordfang, and Cosmin E. Oancea. 2016. FinPar: A Parallel Financial Benchmark. ACM Trans. Archit. Code Optim. 13, 2, Article 18 (June 2016), 27 pages. DOI: 10.1145/2898354

Richard S. Bird. 1989. Algebraic identities for program calculation. Comput. J. 32, 2 (1989), 122–126.

André Du Bois, Tiago Perlin, Frederico Antunes, and Gerson Cavalheiro. 2024. Hok: Higher-Order GPU kernels in Elixir. In Anais do XXVIII Simpósio Brasileiro de Linguagens de Programação (Curitiba/PR). SBC, Porto Alegre, RS, Brasil, 71–80. DOI: 10.5753/sblp.2024.3690

James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, et al. 2021. JAX: Autograd and XLA. arXiv:ascl:2111.002

Manuel M.T. Chakravarty, Gabriele Keller, Sean Lee, Trevor L. McDonell, and Vinod Grover. 2011. Accelerating Haskell array codes with multicore GPUs. In Proceedings of the SixthWorkshop on Declarative Aspects of Multicore Programming (Austin, Texas, USA) (DAMP ’11). Association for Computing Machinery, New York, NY, USA, 3–14. DOI: 10.1145/1926354.1926358

Shuai Che, Jeremy W. Sheaffer, Michael Boyer, Lukasz G. Szafaryn, Liang Wang, and Kevin Skadron. 2010. A characterization of the Rodinia benchmark suite with comparison to contemporary CMP workloads. In Proceedings of the IEEE International Symposium on Workload Characterization (IISWC’10) (IISWC ’10). IEEE Computer Society, USA, 1–11. DOI: 10.1109/IISWC.2010.5650274

André Rauber Du Bois and Gerson Cavalheiro. 2026. Polymorphic Higher-Order GPU Kernels. In Euro-Par 2025: Parallel Processing, Wolfgang E. Nagel, Diana Goehringer, and Pedro C. Diniz (Eds.). Springer Nature Switzerland, Cham, 100–113.

André Rauber Du Bois and Gerson Geraldo H. Cavalheiro. 2025. GPotion: Embedding GPU programming in Elixir. Journal of Computer Languages 83 (2025), 101323. DOI: 10.1016/j.cola.2025.101323

Jiří Filipovič, Matúš Madzin, Jan Fousek, and Luděk Matyska. 2015. Optimizing CUDA code by kernel fusion: application on BLAS. The Journal of Supercomputing 71, 10 (2015), 3934–3957.

Jan Fousek, Jiři Filipovič, and Matuš Madzin. 2011. Automatic fusions of CUDAGPU kernels for parallel map. SIGARCH Comput. Archit. News 39, 4 (Dec. 2011), 98–99. DOI: 10.1145/2082156.2082183

Mark Harris et al. 2007. Optimizing parallel reduction in CUDA. Nvidia developer technology 2, 4 (2007), 70.

Troels Henriksen and Cosmin Eugen Oancea. 2013. A T2 graph-reduction approach to fusion. In Proceedings of the 2nd ACM SIGPLANWorkshop on Functional High-Performance Computing (Boston, Massachusetts, USA) (FHPC ’13). Association for Computing Machinery, New York, NY, USA, 47–58. DOI: 10.1145/2502323.2502328

Troels Henriksen and Cosmin Eugen Oancea. 2013. A T2 graph-reduction approach to fusion. In Proceedings of the 2nd ACM SIGPLANWorkshop on Functional High-Performance Computing (Boston, Massachusetts, USA) (FHPC ’13). Association for Computing Machinery, New York, NY, USA, 47–58. DOI: 10.1145/2502323.2502328

Pieter Hijma, Stijn Heldens, Alessio Sclocco, Ben Van Werkhoven, and Henri E Bal. 2023. Optimization techniques for GPU programming. Comput. Surveys 55, 11 (2023), 1–81.

Ao Li, Bojian Zheng, Gennady Pekhimenko, and Fan Long. 2020. Automatic Horizontal Fusion for GPU Kernels. arXiv:2007.01277 [cs] DOI: 10.48550/arXiv.2007.01277

Richard Membarth, Oliver Reiche, Frank Hannig, Jürgen Teich, Mario Körner, and Wieland Eckert. 2016. HIPAcc: A Domain-Specific Language and Compiler for Image Processing. IEEE Transactions on Parallel and Distributed Systems 27, 1 (Jan 2016), 210–224. DOI: 10.1109/TPDS.2015.2394802

John Nickolls, Ian Buck, Michael Garland, and Kevin Skadron. 2008. Scalable parallel programming with cuda: Is cuda the parallel programming model that application developers have been waiting for? Queue 6, 2 (2008), 40–53.

Víctor Pérez, Lukas Sommer, Victor Lomüller, Kumudha Narasimhan, and Mehdi Goli. 2023. User-driven Online Kernel Fusion for SYCL. ACM Trans. Archit. Code Optim. 20, 2, Article 21 (March 2023), 25 pages. DOI: 10.1145/3571284

Victor Podlozhnyuk. 2007. Black-Scholes Option Pricing. Technical Report. NVIDIA Corporation. [link] NVIDIA CUDA SDK Documentation.

Shigeyuki Sato and Hideya Iwasaki. 2009. A Skeletal Parallel Framework with Fusion Optimizer for GPGPU Programming. In Proceedings of the 7th Asian Symposium on Programming Languages and Systems (Seoul, Korea) (APLAS ’09). Springer-Verlag, Berlin, Heidelberg, 79–94. DOI: 10.1007/978-3-642-10672-9_8

Savvas Sioutas, Sander Stuijk, Twan Basten, Henk Corporaal, and Lou Somers. 2020. Schedule synthesis for halide pipelines on gpus. ACM Transactions on Architecture and Code Optimization (TACO) 17, 3 (2020), 1–25.

Philippe Tillet, H. T. Kung, and David Cox. 2019. Triton: an intermediate language and compiler for tiled neural network computations. In Proceedings of the 3rd ACM SIGPLAN International Workshop on Machine Learning and Programming Languages (Phoenix, AZ, USA) (MAPL 2019). Association for Computing Machinery, New York, NY, USA, 10–19. DOI: 10.1145/3315508.3329973

Guibin Wang, YiSong Lin, and Wei Yi. 2010. Kernel Fusion: An Effective Method for Better Power Efficiency on Multithreaded GPU. In Proceedings of the 2010 IEEE/ACM Int’l Conference on Green Computing and Communications & Int’l Conference on Cyber, Physical and Social Computing (GREENCOM-CPSCOM ’10). IEEE Computer Society, USA, 344–350. DOI: 10.1109/GreenCom-CPSCom.2010.102

Samuel Williams, Andrew Waterman, and David Patterson. 2009. Roofline: an insightful visual performance model for multicore architectures. Commun. ACM 52, 4 (April 2009), 65–76. DOI: 10.1145/1498765.1498785

Chenchen Zhang, Hao Luo, and Chao Yang. 2025. Leonid: Exploring Automated Kernel Fusion in Performance-Portable Programming Models for Scientific Computation. Technical Report. Peking University.
Publicado
08/09/2026
SOARES, João Antonio; DU BOIS, André Rauber; CAVALHEIRO, Gerson Geraldo H.. User-Directed GPU Kernel Fusion of Parallel Skeletons Using Metaprogramming. In: SIMPÓSIO BRASILEIRO DE LINGUAGENS DE PROGRAMAÇÃO (SBLP), 30. , 2026, São Paulo/SP. Anais [...]. Porto Alegre: Sociedade Brasileira de Computação, 2026 . p. 107-115. DOI: https://doi.org/10.5753/sblp.2026.28579.