
238 Introduction to Concurrency in Programming Languages
Listing 11.2: A simple data parallel matrix multiply.
! three 2D arrays : a ,b,c
real , dime nsion (100 ,100) :: a,b , c
! loop counters
integer :: i , j
do i =1 ,100
do j =1 ,100
c(i, j ) = sum ( a(i ,:) * b (:, j ))
end do
end do
The inner loop is then easy to remove and replace with a single concise line of
code. The code for the new data parallel algorithm is shown in Listing 11.2.
What do we gain by this? The code has become simpler, as the innermost
loop is now gone and replaced by an implicit loop due to the use of array
notation. Similarly, we no longer need to explicitly zero out the element ...