Concepts of Programming Languages

(Sean Pound) #1

622 Chapter 13 Concurrency


The DISTRIBUTE statement specifies what data are to be distributed and
the kind of distribution that is to be used. Its form is as follows:

!HPF$ DISTRIBUTE (kind) ONTO procs :: identifier_list

In this statement, kind can be either BLOCK or CYCLIC. The identifier list is the
names of the array variables that are to be distributed. A variable that is speci-
fied to be BLOCK distributed is divided into n equal groups, where each group
consists of contiguous collections of array elements evenly distributed over
the memories of all the processors. For example, if an array with 500 elements
named LIST is BLOCK distributed over five processors, the first 100 elements of
LIST will be stored in the memory of the first processor, the second 100 in the
memory of the second processor, and so forth. A CYCLIC distribution specifies
that individual elements of the array are cyclically stored in the memories of the
processors. For example, if LIST is CYCLIC distributed, again over five proces-
sors, the first element of LIST will be stored in the memory of the first proces-
sor, the second element in the memory of the second processor, and so forth.
The form of the ALIGN statement is
ALIGN array1_element WITH array2_element
ALIGN is used to relate the distribution of one array with that of another. For
example,

ALIGN list1(index) WITH list2(index+1)

specifies that the index element of list1 is to be stored in the memory of
the same processor as the index+1 element of list2, for all values of index.
The two array references in an ALIGN appear together in some statement of the
program. Putting them in the same memory (which means the same processor)
ensures that the references to them will be as close as possible.
Consider the following example code segment:

REAL list_1 (1000), list_2 (1000)
INTEGER list_3 (500), list_4 (501)
!HPF$ PROCESSORS proc (10)
!HPF$ DISTRIBUTE (BLOCK) ONTO procs :: list_1, list_2
!HPF$ ALIGN list_3 (index) WITH list_4 (index+1)

...
list_1 (index) = list_2 (index)
list_3 (index) = list_4 (index+1)


In each execution of these assignment statements, the two referenced array
elements will be stored in the memory of the same processor.
The HPF specification statements provide information for the compiler
that it may or may not use to optimize the code it produces. What the compiler
actually does depends on its level of sophistication and the particular architec-
ture of the target machine.
Free download pdf