

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


This project is to develop a type system and type checker for verifying the ab- sence of race conditions in imperative code. Type checking is designed to permit creation of data structures and processing of separate elements of data structures without flagging race conditions. Functions must be manually annotated with suf- ficient conditions to prevent races. The type checker verifies these conditions. The system’s ability to check for bugs will be tested on uses of a small library of parallel higher-order functions.
Some computational patterns occur frequently enough to abstract into library func- tions. For example, a task that could be abstracted is to perform a commutative and associative reduction on a list of data. If this task is instantiated with addition as the reduction operator, it becomes a routine to compute the average of a list of numbers. Library functions such as this that take function parameters are called higher-order functions (HOFs). HOFs provide two complementary advantages over roll-your-own parallel code. First, they save programmers from the tedious and error-prone work of writing, customizing, and optimizing ”boilerplate” code that deals with the structure of the task (partitioning and distributing data, identifying the work to be performed by each parallel process, and gathering accumulated values). Second, they enable a more intelligent distribution of parallelization effort. Skilled library designers can write efficient code, and skilled compiler designers can write optimizations involving knowledge about the characteristics of specific library routines. This effort manifests as improved parallel performance each time a user utilizes a library routine. It is normally the responsibility of the programmer using the library to avoid bugs. A programmer’s code is susceptible to concurrency-related errors because the library will invoke the user’s code in parallel. Such errors can be harder to debug than roll-your-own parallel code because a bug may arise from the interaction of the programmer’s code and hidden library code. We can look to function call interfaces for inspiration on how to prevent such bugs. Most programming languages assign types to function parameters and re-
turns. These types are a sort of invariant maintained by the function and its callers that ensures values of one type won’t be misinterpreted as another type. In most languages, there is no analogous enforcement of side effect interfaces.
2 Proposal
This project will use a strongly typed functional language whose side-effect-free component is similar to ML or Haskell. The choice of a strongly typed language is motivated by our desire to use types to reason formally about run-time values. The choice of a functional language enables us to assign types to functions and expres- sions, thereby enabling us to reason formally about the consequences of constructing larger program fragments out of smaller ones. A sketch of the solution follows. A new four-place type constructor is introduced for side-effecting computations. The term (a, b) → (c, d) denotes the type of a computation that reads data a, transforms data b into data d, and returns a value of type c. Predicates are introduced to denote data residing in memory. For example, Array 20 (Array n HInt) ℓ uses predicates Array and HInt to denotes an array of arrays of integers residing at memory location ℓ. Functions are introduced to perform basic side-effecting operations on data structures, including functions that may operate in parallel on all elements of a data structure. The type system is designed to be flexible, permitting new data types to be defined without requiring a redesign of the entire system. A computation’s effect may need to be converted to a less general effect to match a particular execution context. A computation that does not read an object is also a computation that reads the object (and does nothing with its value). A computation that reads an object is also a computation that transforms that object to an identical object. In this way, any computation may be interpreted as having a ”larger” side effect than its actual effect. Computations may only be run in a context that matches their effect. Generally a computation will be assigned a “larger” effect to match its context. When compu- tations execute in sequence, the output state of the first computation must match the input state of the second. When computations execute in parallel, memory transformed by one computation cannot be read or transformed by a simultane- ously executing computation.
3 Methodology
Creating this new type system requires extending the basic type checking algorithm to check the correctness of side effect annotations. Part of the project effort involves deciding on a method of implementing the type system. Possibilities include writing a type checker from scratch, translating type judgments into a logic where they can be automatically proven, or writing the type system inference rules in a meta-logic