cpp: #include <stdio.h>\n#define N 1000\ndouble a[N][N],v[N],v_out[N];\n\nvoid mv()\n{           \n  int i,j;\n  for (i = 0; i < N; i++)\n  {         \n    float sum = 0.0;\n#pragma omp parallel for reduction(+:sum)\n    for (j = 0; j < N; j++)\n    { \n      sum += a[i][j]*v[j];\n    }  \n    v_out[i] = sum;\n  }         \n}\n\nint main()\n{\n  mv();\n  return 0;\n}\n
fortran: program DRB062_matrixvector2_orig_no\n    use omp_lib\n    implicit none\n\n    call foo\ncontains\n    subroutine foo()\n        integer :: i, j, N\n        real :: sum\n        real, dimension(:,:), allocatable :: a\n        real, dimension(:), allocatable :: v, v_out\n\n        N = 1000\n        allocate (a(N,N))\n        allocate (v(N))\n        allocate (v_out(N))\n\n        do i = 1, N\n            sum = 0.0\n            !$omp parallel do reduction(+:sum)\n            do j = 1, N\n                sum = sum + a(i,j)*v(j)\n                print*,sum\n            end do\n            !$omp end parallel do\n            v_out(i) = sum\n        end do\n\n    end subroutine foo\nend program