Commit b4a63be2 authored by Matthias Redies's avatar Matthias Redies

fix overflow

parent 1cebd154
...@@ -65,24 +65,26 @@ CONTAINS ...@@ -65,24 +65,26 @@ CONTAINS
logical :: parallel_ok logical :: parallel_ok
real :: summe, t_omp, t_seq real :: summe, t_omp, t_seq
integer :: rank, size, ierr integer :: rank, size, ierr
integer :: i, omp_threads integer :: i, j, omp_threads
integer, parameter :: loop_end = 300000000 integer, parameter :: loop_end = 300000000
summe = 0.0 summe = 0.0
t_omp=0.0 t_omp = 0.0
!$omp parallel reduction(+: t_omp)
!$omp parallel reduction(+: t_omp)
omp_threads = OMP_GET_NUM_THREADS() omp_threads = OMP_GET_NUM_THREADS()
t_omp = OMP_GET_WTIME() t_omp = OMP_GET_WTIME()
!$omp do reduction(+:summe) !$omp do schedule(static) reduction(+:summe)
do i = 1, loop_end*omp_threads do i = 1, loop_end
summe = summe + 1.0 do j = 1, omp_threads
summe = summe + 1.0
enddo
enddo enddo
!$omp end do !$omp end do
t_omp = OMP_GET_WTIME() - t_omp t_omp = OMP_GET_WTIME() - t_omp
!$omp end parallel !$omp end parallel
t_omp = t_omp / omp_threads t_omp = t_omp / omp_threads
summe = summe / omp_threads summe = summe / omp_threads
t_seq = OMP_GET_WTIME() t_seq = OMP_GET_WTIME()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment