19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 32<br />

Parallelism and Locality<br />

<strong>Fortress</strong> is designed to make parallel programming as simple and as painless as possible. This chapter describes the<br />

internals of <strong>Fortress</strong> parallelism designed for use by authors of library code (such as distributions, generators, and<br />

arrays). We adopt a multi-tiered approach to parallelism:<br />

• At the highest level, we provide libraries which allocate locality-aware distributed arrays (Section 32.2) and<br />

implicitly parallel constructs such as tuples and loops. Synchronization is accomplished through the use of<br />

atomic sections (Section 13.23). More complex synchronization makes use of abortable atomicity, described in<br />

Section 32.3.<br />

• <strong>The</strong>re is an extensive library of distributions, which permits the programmer to specify locality and data distribution<br />

explicitly (Section 32.5).<br />

• Immediately below that, the at expression requests that a computation take place in a particular region of the<br />

machine (Section 32.7). We also provide a mechanism to terminate a spawned thread early (Section 32.6).<br />

• Finally, there are mechanisms for constructing new generators via recursive subdivision into tree structures<br />

with individual elements at the leaves. Section 32.8 explains how iterative constructs such as for loops and<br />

comprehensions are desugared into calls to methods of trait Generator, and how new instances of this trait may<br />

be defined.<br />

We begin by describing the abstraction of regions, which <strong>Fortress</strong> uses to describe the machine on which a program is<br />

run.<br />

32.1 Regions<br />

Every thread and every object in <strong>Fortress</strong>, and every element of a <strong>Fortress</strong> array, has an associated region. <strong>The</strong> region<br />

in which an object o resides can be obtained by calling o.region . Regions abstractly describe the structure of the<br />

machine on which a <strong>Fortress</strong> program is running. <strong>The</strong>y are organized hierarchically to form a tree, the region hierarchy,<br />

reflecting in an abstract way the degree of locality which those regions share. <strong>The</strong> different levels of this tree reflect<br />

underlying machine structure, such as execution engines within a CPU, memory shared by a group of processors, or<br />

resources distributed across the entire machine. Objects which reside in regions near the leaves of the tree are local<br />

entities; those which reside at higher levels of the region tree are logically spread out. <strong>The</strong> method call r.isLocalTo(s)<br />

returns true if r is contained within the region tree rooted at s .<br />

It is important to understand that regions and the structures (such as distributions, Section 32.5) built on top of them<br />

exist purely for performance purposes. <strong>The</strong> placement of a thread or an object does not have any semantic effect on<br />

215

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

Saved successfully!

Ooh no, something went wrong!