Analysis of the performance portability of the SYCL joint_matrix extension
Date
Authors
Journal Title
Journal ISSN
Volume Title
Publisher
Abstract
The growing vendor diversity across the fastest supercomputers in the world introduces significant complexity: It is not trivial to ensure that software performs efficiently across multiple hardware platforms. With the introduction of Tensor Cores, Nvidia added another layer of complexity to be considered. AMD and Intel now offer their own solutions for speeding up matrix multiplications. Often programmed in low-level and vendor-specific code, these specialized units make achieving portable high-performance code even more challenging. The performance improvements by factor two and even factor eight for half-precision compared to native cores are nevertheless a good reason to investigate the performance portability of this matrix hardware further. In the course of this thesis, the performance portability of the oneAPI joint_matrix extension is evaluated. This extension provides a vendor-independent API to program matrix hardware in a portable and efficient manner. Therefore, two benchmarks are implemented using SYCL. First, a matrix multiplication utilizing the joint_matrix extension utilizing multiple mixed-precision combinations are tested. Second, the performance of the joint_matrix for a problem not directly mapping on this specialized hardware is evaluated. Therefore, we extend a classical gravitational N-body simulation to use the joint_matrix extension for the pairwise distance calculation between bodies. The result for the matrix multiplication benchmark assesses the impact of different optimization levels when employing the joint_matrix extension. Furthermore, the effect on performance when allocating memory with malloc_share or malloc_device is measured. We found that optimizing the kernel results in the best performance for the joint_matrix extension, achieving ≈ 50% of the cuBLAS performance on Nvidia GPUs for architectural and application efficiency. For all other vendors, no performance portability can be achieved, either due to a malfunctioning oneAPI joint_matrix implementation for AMD, or due to the limited availability of mixed-precision data types for Intel. Deploying the joint_matrix extension to compute the distances between bodies within the N-body simulation showed that this usage can speed up the computation for medium-sized simulation scenarios. For larger simulation scenarios, the naive approach delivers better results due to the computational overhead employed when using the joint_matrix extension for this type of computation.
Heutzutage findet sich eine große Vielzahl an Herstellern in den weltweit schnellsten Supercomputern. Sicherzustellen, dass unterschiedlichste Software effizient auf mehreren Hardwareplattformen ausführbar ist, ist eine komplexe Aufgabe. Durch die Einführung der Tensor Cores erschwerte Nvidia diese Aufgabe weiter. Heutzutage verwenden auch AMD und Intel ihre eigenen Lösungen, um Matrixmultiplikationen zu beschleunigen. Die hoch spezialisierte Hardware macht es noch schwerer, portablen High-Performance-Code zu schreiben, da sie häufig mit herstellerspezifischem Low-Level Code programmiert werden. Dennoch sind die theoretischen Performance-Steigerungen es wert, die "Performance Portability" dieser Matrixeinheiten genauer zu betrachten. Berechnungen welche Double-Genauigkeit nutzen, können mit Faktor zwei, Berechnung mit BF16-Genauigkeit sogar mit Faktor acht beschleunigt werden, wenn man Tensor Cores verwendet. Im Rahmen dieser Arbeit wird die "Performance Portability" der oneAPI joint_matrix Erweiterung untersucht. Diese Erweiterung stellt eine API bereit, mit welcher man effizient herstellerunabhängigen Code für Matrixeinheiten schreiben kann. Für diese Analyse wurden zwei Benchmarks mit SYCL entwickelt. Der erste nutzt eine Matrixmultiplikation verschiedenster Datentypen, welche "Mixed-precision" für die Berechnung verwenden. Der zweite Benchmark nutzt die joint_matrix Erweiterung für ein Problem, welches sich nicht direkt als Matrixmultiplikation darstellen lässt. Für diese Untersuchung wird eine klassische N-Body-Simulation erweitert. Die Distanzberechnung wird hierbei mithilfe der joint_matrix Erweiterung durchgeführt. Anhand des Matrixmultiplikation-Benchmarks wird untersucht, welchen Einfluss verschiedene Optimierungslevel auf die Performance der joint_matrix Erweiterung haben. Außerdem wird untersucht, welche Bedeutung die Speicherallozierung mittels malloc_shared und malloc_device auf die Performance hat. Die Ergebnisse zeigen, dass es wichtig ist, den Kernel zu optimieren, wenn man die joint_matrix verwendet. Dadurch ist es möglich, ≈ 50% der von cuBLAS gelieferten Leistung zu erreichen. Leider ist es nicht möglich, die "Performance Portability" für Intel und AMD zu ermitteln. Gründe sind unter anderem eine fehlerhafte Implementierung der joint_matrix Erweiterung von oneAPI für AMD, sowie die fehlende Unterstützung für viele Datentypen für Intel. Die Verwendung der joint_matrix Erweiterung für die Distanzberechnung einer N-Body Simulation zeigt, dass es für mittlere Simulationsgrößen möglich ist, die naive Implementierung zu beschleunigen. Für größere Simulationen liefert eine naive Implementierung bessere Ergebnisse. Grund hierfür ist unter anderem zusätzlicher Berechnungsaufwand, wenn man die joint_matrix für die Distanzberechnung verwenden will.