0

Fortran プログラムの一部をベンチマークして、特定の変更の影響を理解し、定量化する必要があります (コードをより保守しやすくするために、たとえば関数ポインターを利用して、よりオブジェクト指向にしたいと考えています)。

有限要素の計算を実行するために、同じサブルーチンを数回呼び出すループがあります。ハードコーディングされた関数だけでなく、関数ポインターを使用することの影響を確認したいと考えています。

do i=1,n_of_finite_elements
   ! Need to benchmark execution time of this code
end do

そのようなループの実行時間を取得し、それを nic の方法でフォーマットする簡単な方法は何でしょうか?

4

1 に答える 1

2

https://github.com/jlokimlin/array_passing_performance.gitでさまざまな配列を渡すパフォーマンスを測定する github プロジェクトがあります。

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()
于 2016-05-13T21:28:52.447 に答える