Automatic Inference of Loop Complexity Through Polynomial Interpolation

Complexity analysis is an important activity for software engineers. Such an analysis can be specially useful in the identification of performance bugs. Although the research community has made significant progress in this field, existing techniques still show limitations. Purely static methods may be imprecise due to their inability to capture the dynamic behaviour of programs. On the other hand, dynamic approaches usually need user intervention and/or are not effective to relate complexity bounds with the symbols in the program code. In this paper, we present a hybrid technique that solves these shortcomings. Our technique uses a numeric method based on polynomial interpolation to precisely determine a complexity function for loops. Statically, we determine: i the inputs of a loop, i.e., the variables that control its iterations; and ii an algebraic equation relating the loops within a function. We then instrument the program to plot a curve relating inputs and number of operations executed. By running the program over different inputs, we generate sufficient points for our interpolator. In the end, the complexity function for each loop is combined using an algebra of our own craft. We have implemented our technique in the LLVM compiler, being able to analyse 99.7i¾?% of all loops available in the Polybench benchmark suite, and most of the loops in Rodinia. These results indicate that our technique is an effective and useful way to find the complexity of loops in high-performance applications.

[1]  Péricles Rafael Oliveira Alves,et al.  A case for a fast trip count predictor , 2015, Inf. Process. Lett..

[2]  Matthias Hauswirth,et al.  Algorithmic profiling , 2012, PLDI.

[3]  Fernando Magno Quintão Pereira,et al.  Compiler support for selective page migration in NUMA architectures , 2014, 2014 23rd International Conference on Parallel Architecture and Compilation (PACT).

[4]  Camil Demetrescu,et al.  Input-Sensitive Profiling , 2012, IEEE Transactions on Software Engineering.

[5]  Susan L. Graham,et al.  gprof: a call graph execution profiler (with retrospective) , 1982 .

[6]  Kevin Skadron,et al.  Rodinia: A benchmark suite for heterogeneous computing , 2009, 2009 IEEE International Symposium on Workload Characterization (IISWC).

[7]  Vikram S. Adve,et al.  LLVM: a compilation framework for lifelong program analysis & transformation , 2004, International Symposium on Code Generation and Optimization, 2004. CGO 2004..

[8]  Susan L. Graham,et al.  Gprof: A call graph execution profiler , 1982, SIGPLAN '82.

[9]  Sumit Gulwani,et al.  Control-flow refinement and progress invariants for bound analysis , 2009, PLDI '09.

[10]  Daniel Le Métayer,et al.  ACE: an automatic complexity evaluator , 1988, TOPL.

[11]  Sumit Gulwani,et al.  A Numerical Abstract Domain Based on Expression Abstraction and Max Operator with Application in Timing Analysis , 2008, CAV.

[12]  Nils Anders Danielsson Lightweight semiformal time complexity analysis for purely functional data structures , 2008, POPL '08.

[13]  Joe D. Warren,et al.  The program dependence graph and its use in optimization , 1987, TOPL.

[14]  Simon Goldsmith,et al.  Measuring empirical computational complexity , 2007, ESEC-FSE '07.

[15]  Ben Wegbreit,et al.  Mechanical program analysis , 1975, CACM.

[16]  Andrew W. Appel,et al.  Modern Compiler Implementation in Java , 1997 .

[17]  Sumit Gulwani,et al.  SPEED: precise and efficient static estimation of program computational complexity , 2009, POPL '09.

[18]  Laure Gonnord,et al.  Using Bounded Model Checking to Focus Fixpoint Iterations , 2011, SAS.

[19]  Nicholas Nethercote,et al.  Valgrind: a framework for heavyweight dynamic binary instrumentation , 2007, PLDI '07.

[20]  Saumya K. Debray,et al.  Cost analysis of logic programs , 1993, TOPL.

[21]  Michael Wolfe,et al.  High performance compilers for parallel computing , 1995 .

[22]  Edsger W. Dijkstra,et al.  A note on two problems in connexion with graphs , 1959, Numerische Mathematik.