An Empirical Study of Computation-Intensive Loops for Identifying and Classifying Loop Kernels Masatomo Hashimoto Masaaki Terai Toshiyuki Maeda Kazuo Minami
ICPE2017

•  Performance engineering of scientific applications — Identifying source code region (loops) that we should optimize — Estimating expected performance of the loops to set the goal of performance tuning • Classifying loops according to expected performance •  Empirical study of 1020 real applications – How many loops should we optimize? — What efficiency can we expect from the loops?
ICPE2017
2

• Simulate real-world phenomenal •  Massively parallel •  Running on supercomputers – E.g. the K computer ሎ⁵‰ •  11.28 PFLOPS peak performance •  705,024 SPARC64 2GHz cores (864 racks) •  1.41 PiB memory (2GiB/core) •  10GiBx2 bandwidth interconnect •  Written in Fortran, C++, ... ©Fujitsu & RIKEN AICS
ICPE2017

•  Essential for scientific progress — More efficiency, more scientific results •  Simulated time/resolution, accuracy of model •  Requires human intervention — Identifying loops to be tuned • Computational kernel — Changing compiler opts and/or transforming loops
ICPE2017

•  (Nested) loop(s) in a subprogram — Array references + floating-point operations • E.g.

ICPE2017

•  Apps are programmed by scientists and tuned by performance engineers — Comprehending scientists' code is painful •  Identification of algorithms and kernels •  Combinatorial explosion of search space – Compiler options •  E.g. GCC has 100 performance related options — Loop transformations and their parameters •  E.g. unrolling, blocking, fusion, fission, ...
ICPE2017

•  Predicting good loop transformation — Studied in our previous work for given computational kernels [MSR2015] • Classification of loops — Kernel or non-kernel — Six kernel classes (groups of similar kernels) •  For estimating target performance/efficiency — Similar kernel, similar efficiency
ICPE2017
7

ICPE2017

•  Selected 175,963 loops from 1020 Fortran applications on GitHub – Use of OpenMP, MPI, and/or OpenACC •  Manually classified 100 loops that are randomly sampled from the loops – By experienced performance engineers •  Code comprehension assistance •  Statistically estimated distribution of classes over the 175K loops •  Created predictive models based on the manual classification results
ICPE2017

• Fortran parser
— Standards: F77, F90, F95, F2003, F2008 –  Vendor-specific extensions/directives •  Fujitsu, GNU, IBM, Intel, PGI, OpenMP, OpenACC – Out-of-order parsing •  No need to hook build process •   Outline view of call-tree – With code metrics • Topic analysis of source code . Source code viewer • Available at https://github.com/ebt-hpc/cca
|CPE2017
10

Kernel NonKernel
ICPE2017

ICPE2017

•  Constructing predictive model
— Feature vector of loop → kernel class (or non-kernel) •  Machine learning algo.: SVC (Support Vector Classification) •  Feature vector: static loop metrics — E.g. num of calls, num of indirect array refs • Training data set: manual classification result (100 samples) •  Predicting whether a loop is a kernel or not – Classification accuracy: 0.81 (20-fold cross validation) •  Predicting whether a kernel is M5 or not – Classification accuracy: 0.94 (20-fold cross validation)
ICPE2017
13

• Performance tuning of scientific applications —  Essential and demanding • Learning from performance tuning experts —  Classification of loop kernels into six classes •   Estimating target performance/efficiency . Estimating distribution of kernel classes —  175K loops from 1K Fortran applications on GitHub •  70-85% are kernels •   35-55% are M5 kernels (stencil, <15% expected efficiency) • Correlation between static loop features and kernel classes —  Machine learning (SVC) + training set (100 sampled loops) • Classification accuracy 0.81 (Is given loop a kernel or not?) • Classification accuracy 0.94 (Is given kernel M5 or not?)
ICPE2017
14

■ Raw results of the experiments口https://github.com/ebt-hpc/icpe2017 ■ Outlines of 1020 applications口https://ngse.riken.jp/outline ■  Our tool (CCA/EBT)口https://github.com/ebt-hpc/cca
ICPE2017
15