How I calculate the time in each thread ? the CPU_time not work in this case , because If the process is multithreaded, the CPU time is the sum for all threads.
Pseudocode example:
PROGRAM MAIN
implicit none
REAL Times_thread1_Started,Times_thread2_Started,....
REAL Times_thread1_finiched
!$OMP PARALLEL
!$OMP DO !for each thread do :
call CPU_TIME_thread1(Times_thread1_Started)
call CPU_TIME_thread2(Times_thread2_Started)
..........
..........
!$OMP END DO
......................
......................
processing multithread
............
............
!$OMP PARALLEL
!$OMP DO !for each thread do :
call CPU_TIME_thread1(Times_thread1_finiched)
write(*,*) 'Thread1 times:',Times_thread1_finiched-Times_thread1_Started
call CPU_TIMEE_thread2(Times_thread2)
write(*,*) 'Thread1 times:',Times_thread1_finiched-Times_thread1_Started
..........
..........
!$OMP END DO
!$OMP END PARALLEL
END
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…