Parallel Programming Guide for HP-UX Systems

Memory classes
Memory class assignments
Chapter 7 131
.
.
.
END
SUBROUTINE PARCOM2(B,JTA)
INTEGER B(*), JTA
INTEGER C(1000), D(1000)
COMMON /BLK1/ C, D
C$DIR THREAD_PRIVATE(/BLK1/)
DO J = 1, 1000
C(J) = D(J) * B(J)
ENDDO
END
.
.
.
In this example, COMMON block BLK1 is declared THREAD_PRIVATE, so
every parallel instance of PARCOM gets its own copy of the arrays C and D.
Because this code is already thread-parallel when the COMMON block is
defined, no further parallelism is possible, and BLK1 is therefore suitable
for use anywhere in PARCOM. The local variables TEMP1 and TEMP2 are
allocated on the stack, so each thread effectively has private copies of
them.
node_private
Because the space for node_private variables is physically replicated,
static declarations make the most sense for them.
In Fortran, the node_private memory class is assigned using the
NODE_PRIVATE compiler directive, as shown in the following example:
REAL*8 XNP(1000)
REAL*8 YNP(1000)
REAL*8 ZNP(1000), X, Y
COMMON /BLK1/ ZNP, X, Y
C$DIR NODE_PRIVATE(XNP, YNP, /BLK1/)
Again, the data requires 24,016 bytes. The contents of BLK1 are placed in
node_private memory along with XNP and YNP. Space for each data item
is replicated once per hypernode in hypernode-local physical memory.
The same virtual address is used by each thread to access its hypernode’s
copy of a data item.
node_private variables and arrays can be initialized in Fortran DATA
statements.