Commit 666b8933 authored by Budiardja, Reuben's avatar Budiardja, Reuben
Browse files

Added total time to output.

parent f6b7c8fa
......@@ -9,6 +9,7 @@
double *m_gate;
double *Vm;
double TimeTotal = 0.0;
void Initialize ( long nCells )
{
......@@ -23,8 +24,11 @@ void Initialize ( long nCells )
double start = omp_get_wtime ( );
#pragma omp target enter data map ( to: m_gate [ : nCells ] )
#pragma omp target enter data map ( to: Vm [ : nCells ] )
printf ( "OMP Time H2D : %.4lf sec\n", omp_get_wtime ( ) - start );
double Time_H2D = omp_get_wtime ( ) - start;
printf ( "OMP Time H2D : %.4lf sec\n", Time_H2D );
TimeTotal += Time_H2D;
}
......@@ -82,8 +86,11 @@ void Compute ( long nCells, int nIterations )
m_gate[ii] += (mhu - m_gate[ii])*(1-exp(-tauR));
}
}
printf ( "OMP Time Compute : %.4lf sec\n", omp_get_wtime ( ) - start );
double TimeCompute = omp_get_wtime ( ) - start;
printf ( "OMP Time Compute : %.4lf sec\n", TimeCompute );
TimeTotal += TimeCompute;
}
......@@ -91,7 +98,10 @@ void Verify ( long nCells )
{
double start = omp_get_wtime ( );
#pragma omp target update from ( m_gate [ : nCells ] )
printf ( "OMP Time D2H : %.4lf sec\n", omp_get_wtime ( ) - start );
double Time_D2H = omp_get_wtime ( ) - start;
printf ( "OMP Time D2H : %.4lf sec\n", Time_D2H );
TimeTotal += Time_D2H;
if ( m_gate[0] < 0.506796 || m_gate[0] > 0.996322 )
printf ( "FAILED sanity check, m_gate[0]=%.15lf\n", m_gate[0] );
......@@ -120,6 +130,8 @@ int main ( int argc, char* argv[] )
Initialize ( nCells );
Compute ( nCells, nIterations );
Verify ( nCells );
printf ( "OMP Time Total : %.4lf sec\n", TimeTotal );
Finalize ( nCells );
return 0;
......
......@@ -6,6 +6,9 @@ module rush_larsen_simple_module
implicit none
public
real ( real64 ) :: &
TimeTotal = 0.0_real64
real ( real64 ), dimension ( : ), allocatable :: &
m_gate, &
Vm
......@@ -18,7 +21,8 @@ contains
nCells
real ( real64 ) :: &
Start
Start, &
Time_H2D
allocate ( m_gate ( 0 : nCells-1 ) )
m_gate = 0.0_real64
......@@ -29,8 +33,11 @@ contains
Start = omp_get_wtime ( )
!$OMP target enter data map ( to: m_gate )
!$OMP target enter data map ( to: Vm )
Time_H2D = omp_get_wtime ( ) - Start
write ( *, fmt = '(a20, f6.4, a4)' ) &
'OMP Time H2D : ', omp_get_wtime ( ) - Start, ' sec'
'OMP Time H2D : ', Time_H2D, ' sec'
TimeTotal = TimeTotal + Time_H2D
end subroutine Initialize
......@@ -50,7 +57,8 @@ contains
Tau_m = 18
real ( real64 ) :: &
x, sum1, sum2, mhu, tauR, &
Start
Start, &
TimeCompute
real ( real64 ), parameter :: &
Mhu_a ( 0 : 14 ) = &
[ 9.9632117206253790e-01_real64, 4.0825738726469545e-02_real64, &
......@@ -90,7 +98,6 @@ contains
do iT = 0, nIterations
!$OMP target teams distribute parallel do &
!$OMP firstprivate ( Mhu_a, Tau_a ) &
!$OMP private ( x, sum1, j, sum2, k, mhu, tauR )
do ii = 0, nCells - 1
......@@ -117,8 +124,11 @@ contains
!$OMP end target teams distribute parallel do
end do
TimeCompute = omp_get_wtime ( ) - Start
write ( *, fmt = '(a20, f6.4, a4)' ) &
'OMP Time Compute : ', omp_get_wtime ( ) - Start, ' sec'
'OMP Time Compute : ', TimeCompute, ' sec'
TimeTotal = TimeTotal + TimeCompute
!$OMP barrier
!$OMP target exit data map ( delete: Mhu_a )
......@@ -133,12 +143,16 @@ contains
nCells
real ( real64 ) :: &
Start
Start, &
Time_D2H
Start = omp_get_wtime ( )
!$OMP target update from ( m_gate )
Time_D2H = omp_get_wtime ( ) - Start
write(*, fmt = '(a20, f6.4, a4)' ) &
'OMP Time D2H : ', omp_get_wtime ( ) - Start, ' sec'
'OMP Time D2H : ', Time_D2H, ' sec'
TimeTotal = TimeTotal + Time_D2H
if ( m_gate ( 0 ) < 0.506796_real64 &
.or. m_gate ( 0 ) > 0.996322_real64 ) then
......@@ -187,6 +201,10 @@ program rush_larsen_simple
call Initialize ( nCells )
call Compute ( nCells, nIterations )
call Verify ( nCells )
write(*, fmt = '(a20, f6.4, a4)' ) &
'OMP Time Total : ', TimeTotal, ' sec'
call Finalize ( nCells )
......
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