AutoTuneTMP: Auto-Tuning in C++ With Runtime Template Metaprogramming

David Pfander, Malte Brunn, Dirk Pflüger · 2018

Careful tuning of code is crucial to obtain near-optimal runtime performance on the hardware at hand. How-ever, current hardware platforms pose plenty of challenges: multiple levels of cache, many cores and increasingly wider vector units render manual tuning time-consuming and cumbersome. Thus, algorithms have to be able to automatically tune themselves to the underlying hardware platform to maximize performance and to ensure performance portability. In this work, we present AutoTuneTMP, a novel C++-based auto-tuning library. Its unique strength is to combine template metaprogramming and just-in-time (JIT) compilation so that templates can be instantiated at runtime. We use this runtime metaprogramming approach to provide an extensible set of parameterized template-based optimizations and data structures for writing tunable kernels. Together with convenience functionality for parameter tuning, this lightweight approach can be used to implement algorithms with near-optimal and portable performance. We demonstrate the applicability, usefulness and performance of AutoTuneTMP at the example of matrix multiplication. It is well-suited as a demonstrator, being a well-known compute kernel and exhibiting a rather large set of (nine) tunable parameters to be optimized. With simple search algorithms, AutoTuneTMP is able to automatically achieve up to 90% of the peak performance on a Xeon Silver 4116 processor and up to 34% on a Xeon Phi 7210. Starting from an already parallelized and vectorized baseline, we obtained a speedup of up to 3.1x on the Xeon Silver platform and up to 6.7x on the Xeon Phi platform.

Read the paper · More papers on PaperTik