Fortran multi-thread synchronization

I have a Fortran 90 program calling a multi-threaded procedure. I would like to send this program from the calling program. If I use cpu_time(), I get cpu_time for all threads (8 in my case) added together, and not the actual time it takes to start the program. The procedure etime()seems to do the same. Any idea on how I can use this program (without using a stopwatch)?

+3
source share
2 answers

Give it a try omp_get_wtime(); see http://gcc.gnu.org/onlinedocs/libgomp/omp_005fget_005fwtime.html for a signature.

+4
source

, larsmans, gprof - - , , ; , . , , - , , , , .

, omp_get_wtime(), ; , OpenMP - , , , , . Edited; .

Fortran90 system_clock(), ; , gfortran , ifort - . :

subroutine tick(t)
    integer, intent(OUT) :: t

    call system_clock(t)
end subroutine tick

! returns time in seconds from now to time described by t
real function tock(t)
    integer, intent(in) :: t
    integer :: now, clock_rate

    call system_clock(now,clock_rate)

    tock = real(now - t)/real(clock_rate)
end function tock

:

call tick(calc)
! do big calculation
calctime = tock(calc)

print *,'Timing summary'
print *,'Calc: ', calctime
+2

Source: https://habr.com/ru/post/1793968/


All Articles