Efficient array update analysis of strict functional languages
暂无分享,去创建一个
The usefulness of functional programming languages for large scale software development has been limited by the array update problem: Since there is no notion of state in these languages, modifying an array at a single index requires creating a new copy of the entire array, which leads to unacceptable performance degradation.
An array update can, however, be implemented in constant time without copying if there are no future uses of the old array.
This thesis presents the first practical interprocedural update analysis algorithm for strict first-order functional languages with arrays of scalars. The analysis runs in polynomial time, and in linear time for typical programs. All previous algorithms of this kind require exponential time in the worst case. The algorithm does not assume any fixed evaluation order but derives a good order that maximizes opportunities for destructive (non-copying) updating. The simplicity of the algorithm also makes it adaptable to separate compilation.
This thesis also describes a parallel functional language with new operations on arrays for expressing divide and conquer algorithms, and presents an extension of the basic algorithm for that language. The analysis has polynomial time complexity even for parallel evaluation, and is the first practical algorithm for interprocedural update analysis of parallel functional programs. The analysis is so effective that it removes all copying in parallel functional programs for many scientific applications including gaussian elimination with and without partial pivoting, LU, Cholesky and QR factorizations, and multigrid and relaxation algorithms for solving partial differential equations numerically. In cases where a copy cannot be eliminated, the compiler can advise the user about the source of the problem.
The thesis describes a new update operation for specifying a collection of up-dates on an array, which subsumes monolithic arrays as provided by most functional languages. It also considers the problem of non-flat or nested but non-recursive arrays and some of the difficulties introduced by non-flatness, and presents an extension of the algorithm for non-flat arrays.
Another contribution of the thesis is the implementation of a compiler for the proposed parallel functional language, and a runtime system for a shared memory multiprocessor. It describes the compiler and the runtime system and presents some preliminary performance results of the implementation on a Sequent Symmetry, a bus-based shared memory multiprocessor.
The thesis considers the implications of these algorithms for language design, and argues that programmers will be able to write efficient programs by relying on update optimization.