Global Operations
Pi1 (
source
):
computes pi as
parallelisation of loop in several steps
Pi2 (
source
):
distribute loop to threads
PARALLEL DO
shortcut for
PARALLEL
, followed by
DO
pi2 returns wrong results
reason: threads write to x and sum "simultaneously"
Pi3 (
source
):
local copy for each thread:
PRIVATE(x, sum)
private variables
have no initial value
have no value (which one?) after the parallel/do
private variables with initial values:
FIRSTPRIVATE(var-liste)
hold value of the last iteration:
LASTPRIVATE(var-liste)
pi3 erroneous: private sum's must be summed
Pi4 (
source
):
"automatic" summation of all thread private sum values:
REDUCTION(+:sum)
possible reduction operations:
+, -, *, .AND:, .OR., .EQV., .NEQV.
MAX, MIN, IAND, IOR, IEOR
reduction variables are initialised properly
(0 for +, 1 for *,
.TRUE.
for
.AND.
etc.)
Peter Junglas 16.2.1999