PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Code execution time measurements - strange

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling
View previous topic :: View next topic  
Author Message
szczelba



Joined: 29 Jun 2010
Posts: 26

PostPosted: Fri Oct 01, 2010 3:49 am    Post subject: Code execution time measurements - strange Reply with quote

Hello,

I've got a simple code like this:

Code:
   program test

c        Variables
     integer, save :: nbl, nblcks, ijk, k, l, n, n2
     integer, dimension(:), allocatable, save :: ijkpr
     real(kind(zzz)), dimension(:,:), allocatable, save :: vvect
     real rrnorm

     real, dimension(2) :: tarray
     integer :: total, t1, t2, t3, t4, t5, clock_rate, clock_max
     real :: cputime, gputime

c        Setting the variables values
     nblcks = 10000000
     k=10
     l = 110
     rrnorm = 3.5

     allocate(ijkpr(200))
     allocate(vvect(1000,1000))
   
     do n=1,200
        ijkpr(n) = n
     enddo

     do n=1,1000
       do n2=1,1000
         vvect(n,n2) = n2+n
       enddo
     enddo

c        Loop
     call system_clock(t1, clock_rate, clock_max)
     do nbl=1,nblcks
       do n=k,l
         vvect(n,1)=vvect(n,1)*rrnorm
       enddo
     enddo
     call system_clock(t2, clock_rate, clock_max)
     cputime = 1000.0*real(t2-t1)/real(clock_rate)
     write(*,*) 'CPU = ', cputime, ' ms, vvect(100,1)=', vvect(100,1)

   end


And the time results in consecutive code executions are:
CPU = 1125.0 ms
CPU = 0 ms
CPU = 1110.0 ms
CPU = 0 ms
CPU = 0 ms
...

Why sometimes the same code takes 1125 ms and sometimes 0 ms? It is all running on the same machine, same system, just one execution right after another.
I tried different time measurement functions (etime, cpu_time, system_clock, etc) and there is always a similar result - zeros appear sometime. There is the same situation also with totaly different codes.

Thank for clearing me up this problem.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Fri Oct 01, 2010 3:36 pm    Post subject: Reply with quote

Hi szczelba,

Your results will be dependent upon your system's clock granularity. Given your results, I'm assuming your running on Windows? Windows clock granularity is fairly course.

- Mat
Back to top
View user's profile
szczelba



Joined: 29 Jun 2010
Posts: 26

PostPosted: Mon Oct 04, 2010 12:09 am    Post subject: Reply with quote

Following your suggestions, I've downloaded and ran a program which should change my current timer resolution to about 1ms (called Set Timer Resolution). But still, the results looks like this:

CPU = 1453 ms
CPU = 1438 ms
CPU = 1438 ms
CPU = 0 ms
CPU = 0 ms
...

I read that the default windows xp timer resolution is about 10-20 ms. It still should find a difference between 1453 ms and 0 ms...

How to understand this?
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group