Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

CPU_TIME in FORTRAN 90

elquin
Beginner
3,409 Views
Dear all,
When trying to get computing time of each subroutine, I use
call cpu_time(t1)
.
.
computational part
.
.
call cpu_time(t2)
print *, 'CPU TIME = ', t2 - t1
But this returns zero because t1 and t2 are same.
My environments are ;
MS Visual Studio 2008
Intel Visual Fortran 11.1.065
MKL 10.2 update release 4
0 Kudos
7 Replies
Arjen_Markus
Honored Contributor II
3,409 Views
It depends on the amount of time actually spent in the computational part, but you may run into
the granularity of the timer. There must be a certain minimum amount of computational time.
I do not know what that minimum time is, but it could be surprisingly large.

Regards,

Arjen
0 Kudos
TimP
Honored Contributor III
3,409 Views
CPU_TIME was introduced in Fortran 95. ifort doesn't have any option to drop back to Fortran 90, where you would be required to supply your own version (but you could refer to ifport docs to see which names from that era are supported there). On the popular Intel platforms, cpu_time has a granularity of 0.01 seconds, so a smaller time interval may be reported as 0.
The ifport legacy equivalent functions won't help you there. In fact, with timers written as functions as opposed to subroutines, a compiler might decide that 2 calls using the same argument could be replaced by one.
0 Kudos
JVanB
Valued Contributor II
3,409 Views
0 Kudos
TimP
Honored Contributor III
3,409 Views
That thread was about improving granularity of elapsed time accounting, which may or may not be relevant.
0 Kudos
John_Campbell
New Contributor II
3,409 Views
Tim,

I think the thread is more about stating the problem of granularity. I'd be very interested if there were known ways of improving the granularity, especially for CPU_TIME and GetProcessTimes.
Last year, I unsuccessfully tried to use multi-processor coding with Ver 11 of ifort, where comparing accumulated elapsed and cpu times would have been helpful in idenitfying what was happening.

John

0 Kudos
rase
New Contributor I
3,409 Views
As far as I know CPU time is accumulated time for all processors working simultaneously for the same task. Correct? What about multithreading?
0 Kudos
TimP
Honored Contributor III
3,409 Views
Up to now, openmp-profile has been an effective way to view thread activity correlated to source regions. It would not deal with co-arrays on distributed architecture, nor would combinations of cpu_time and system_clock. I'll be sorry to see it go, if in fact it's about to disappear.
0 Kudos
Reply