Gaussian Elimination: HPF Program
REAL a(n,n), tmp(n)
!HPF$ DISTRIBUTE a(CYCLIC,CYCLIC)
!HPF$ ALIGN tmp(i) WITH a(*,i)
DO k = 1, n-1
! Select the pivot
ipivot = MAXLOC( ABS(a(k:n,k)) ) + k - 1
! Swap the rows
tmp(k:n) = a(ipivot,k:n)
a(ipivot,k:n) = a(k,k:n)
a(k,k:n) = tmp(k:n)
! Update the submatrix
FORALL ( i=k+1:n, j=k+1:n ) &
& a(i,j) = a(i,j) - a(i,k)/tmp(k)*tmp(j)
END DO