[英]Benchmarking fortran loop
我需要對fortran程序的一部分進行基准測試,以理解和量化特定更改的影響(為了使代碼更易於維護,我們希望使其更趨於面向對象(例如,利用函數指針))。
我有一個循環,多次調用相同的子例程以對有限元素執行計算。 我想看看使用函數指針而不只是硬編碼函數的影響。
do i=1,n_of_finite_elements
! Need to benchmark execution time of this code
end do
獲取此類循環的執行時間並以nic方式對其進行格式化的簡單方法是什么?
我有一個github項目,該項目在https://github.com/jlokimlin/array_passing_performance.git上測量傳遞各種數組的性能
它使用從https://github.com/jlokimlin/cpu_timer.git派生的CpuTimer數據類型。
用法:
use, intrinsic :: iso_fortran_env, only: &
wp => REAL64, &
ip => INT32
use type_CpuTimer, only: &
CpuTimer
type (CpuTimer) :: timer
real (wp) :: wall_clock_time
real (wp) :: total_processor_time
integer (ip) :: units = 0 ! (optional argument) = 0 for seconds, or 1 for minutes, or 2 for hours
! Starting the timer
call timer%start()
do i = 1, n
!...some big calculation...
end do
! Stopping the timer
call timer%stop()
! Reading the time
wall_clock_time = timer%get_elapsed_time(units)
total_processor_time = timer%get_total_cpu_time(units)
! Write time stamp to standard output
call timer%print_time_stamp()
! Write compiler info to standard output
call timer%print_compiler_info()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.