HP C Programmer's Guide (92434-90009)

Chapter 4 111
Optimizing HP C Programs
Parallel Execution
data dependence in the inner loop only, allowing the outer loop to be parallelized. Consider
the following:
for (i=0; i<10; i++)
for (j=1; j<100; j++)
a[i][j] = a[i][j-1] + 1;
The data dependence in this nested loop occurs in the inner [j] loop: Each row access of
a[j,i] depends upon the preceding row [j-1] having been assigned in the previous
iteration. If the iterations of the j loop were to execute in any other order than the one in
which they would execute on a single processor, the matrix would be assigned different
values. The inner loop, therefore, must not be parallelized.
But no such data dependence appears in the outer loop: Each column access is
independent of every other column access. Consequently, the compiler can safely distribute
entire columns of the matrix to execute on different processors; the data assignments will
be the same regardless of the order in which the columns are executed, so long as each
executes in serial order.
Assumed Dependences When analyzing a loop, the compiler will err on the safe side
and assume that what looks like a data dependence really is one and so not parallelize the
loop. Consider the following:
for (i=100; i<200; i++)
a[i] = a[i-k];
The compiler will assume that a data dependence exists in this loop because it appears
that data that has been defined in a previous iteration is being used in a later iteration.
However, if the value of k is 100, the dependence is assumed rather than real because
a[i-k] is defined outside the loop.
Runtime Messages
This section discusses runtime error, warning, and informational messages that are
unique to parallelized programs. Following each message is an explanation of the message
and a corrective action.
Error Messages
File I/O output lost from parallelized loop. (Parallel Library 211)
The parallel runtime library lost output from an I/O statement within a parallelized loop.
This error typically occurs because the tmp directory's file system ran out of disk space. You
should remove any unwanted files.
Trouble reserving shared memory for the stack. (Parallel Library 212)
Trouble allocating shared memory for static variables.(Parallel Library 213)
Trouble allocating shared memory for the stack and static variables.
(Parallel Library 214)
The parallel runtime library could not reserve shared memory for the program's stack
and/or static variables.
Make sure that your program has adequate swap space. Also, use
ipcs
(1) and
ipcrm
(1) to
remove any unused shared memory segments. If that fails, you should consider increasing