Reflective Parallel Programming Extensible and High-Level Control of Runtime, Compiler, and Application Interaction
Nicholas D. Matsakis, Thomas R. Gross · 2011
Thread support in most languages is opaque and lowlevel. Primitives like wait and signal do not allow users to determine the relative ordering of statements in different threads in advance. In this paper, we extend the reflection and metaprogramming facilities of object-oriented languages to cover parallel program schedules. The user can then access objects representing the extant threads or other parallel tasks. These objects can be used to modify or query happens before relations, locks, and other highlevel scheduling information. These high-level models enable users to design their own parallel abstractions, visualizers, safety checks, and other tools in ways that are not possible today. We discuss one implementation of this technique, the intervals library, and show how the presence of a firstclass, queryable program schedule allows us to support a flexible data race protection scheme. The scheme supports both static and dynamic checks and also permits users to define their own “pluggable ” safety checks based on the reflective model of the program schedule. 1