19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

the meaning of a program; it is simply an aid to enable the implementation to make informed decisions about data<br />

placement.<br />

It may not be possible for an object or a thread to reside in any possible region. <strong>The</strong> execution level of the region<br />

hierarchy is where threads of execution reside, and is generally the bottommost level in the region tree. A thread is<br />

generally associated with some region at the execution level, where that spawned thread will preferentially be run.<br />

<strong>The</strong> programmer can affect the choice of region by using an at expression (Section 32.7) when the thread is created.<br />

A spawned thread may be assigned a region higher in the region hierarchy than the execution level, either because<br />

a higher region was requested or because scheduling decisions permit the thread to run in several possible execution<br />

regions. <strong>The</strong> region to which a thread is assigned may also change over time due to scheduling decisions. <strong>The</strong> region<br />

method for the object associated with a spawned thread returns the region of the associated thread.<br />

<strong>The</strong> memory level of the region hierarchy is where individual reference objects reside; on a machine with nodes<br />

composed of multiple processor cores sharing a single memory, this will not generally be the leaves of the region<br />

hierarchy. Imagine a constructor for a reference object is called by a thread residing in region r , yielding an object o .<br />

Except in very rare circumstances (for example when a local node is out of memory) either r.isLocalTo(o.region) or<br />

(o.region).isLocalTo(r) ought to hold: data is allocated locally to the thread which runs the constructor. For a value<br />

object v being manipulated by a thread residing in region r either (v.region).isLocalTo(r) or r.isLocalTo(v.region)<br />

(value objects always appear to be local).<br />

Note that region is a getter method and can be overridden like any other method. <strong>The</strong> chief example of this is arrays,<br />

which are generally composed from many reference objects; the region method is overridden to return the location of<br />

the array as a whole—the region which contains all of its constituent reference objects.<br />

32.2 Distributed Arrays<br />

Arrays, vectors, and matrices in <strong>Fortress</strong> are assumed to be spread out across the machine. As in Fortran, <strong>Fortress</strong><br />

arrays are complex data structures; simple linear storage is encapsulated by the HeapSequence type, which is used<br />

in the implementation of arrays (see Section 32.7). <strong>The</strong> default distribution of an array is determined by the <strong>Fortress</strong><br />

libraries; in general it depends on the size of the array, and on the size and locality characteristics of the machine<br />

running the program. For advanced users, the distribution library (introduced in Section 32.5) provides a way of<br />

combining and pivoting distributions, or of redistributing two arrays so that their distributions match. Programmers<br />

should create arrays by using an array comprehension (Section 13.29) or an aggregate expression (Section 13.28). <strong>The</strong><br />

operational internals of array comprehensions are described in Section 32.8.<br />

Because the elements of a fortress array may reside in multiple regions of the machine, there is an additional method<br />

a.region(i) which returns the region in which the array element a i resides. An element of an array is always local<br />

to the region in which the array as a whole is contained, so (a.region(i)).isLocalTo(a.region) must always return<br />

true . When an array contains reference objects, the programmer must be careful to distinguish the region in which the<br />

array element a i resides, a.region(i) , from the region in which the object referred to by the array element resides,<br />

a i .region . <strong>The</strong> former describes the region of the array itself; the latter describes the region of the data referred to by<br />

the array. <strong>The</strong>se may differ.<br />

32.3 Abortable Atomicity<br />

<strong>Fortress</strong> provides a user-level abort() function which abandons execution of an atomic expression and rolls back<br />

its changes, requiring the atomic expression to execute again from the beginning. This permits an atomic section to<br />

perform consistency checks as it runs. However, the functionality provided by abort() can be abused; it is possible<br />

to induce deadlock or livelock by creating an atomic section which always fails. Here is a simple example of a<br />

program using abort() which is incorrect because <strong>Fortress</strong> does not guarantee that the two implicit threads (created<br />

216

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!