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

CPU time issue

mbehzad
Beginner
737 Views
Hi,
I am compiling and running a Fortran77 code on the i7 Intel Processor. In this code there is a subroutine (called second) and it computed the CPU time whenever called. But as I amdebuggingthe code, it returns a negative value which is obviously wrong. I know it works on the one core processor well. So I guess it is because of the new CPU that I used and the function "etime" which is not compatible with multiple processor. I am wondering if anyone has any experience that could be helpful. Following is the second subroutine which is used by the main code.

subroutine second (tnow)

double precision tnow

real*4 d(2)

rtnow=etime(d)

tnow=d(1)+d(2)

return

end


Thanks in advance.

Mohsen

0 Kudos
3 Replies
Steven_L_Intel1
Employee
737 Views
ETIME does behave differently on a multicore or multiprocessor system, as documented. On single-core systems, the first element is CPU time in seconds and the second element is system time. On multicore or multiprocessor systems, the first element is wallclock time in seconds and the second element is zero. (Don't ask me why this is, but it seems to be a common definition.)

I recommend using the standard Fortran intrinsic CPU_TIME instead. You can call it just the way you are calling SECOND.
0 Kudos
chuckwh
Beginner
737 Views
Quoting - mbehzad
Hi,
I am compiling and running a Fortran77 code on the i7 Intel Processor. In this code there is a subroutine (called second) and it computed the CPU time whenever called. But as I amdebuggingthe code, it returns a negative value which is obviously wrong. I know it works on the one core processor well. So I guess it is because of the new CPU that I used and the function "etime" which is not compatible with multiple processor. I am wondering if anyone has any experience that could be helpful. Following is the second subroutine which is used by the main code.

subroutine second (tnow)

double precision tnow

real*4 d(2)

rtnow=etime(d)

tnow=d(1)+d(2)

return

end


Thanks in advance.

Mohsen


Ihave just moved to Fortran 11.0 from Fortran 9.1, and I am working on multi-core systems with x64.

Under version 9.1, ETIME returned the cpu time in seconds. Under version 11.0 it returns a very small number, usually about a factor of 1000 smaller than the correct result. This is NOT a matter of the first array member being the wallclock time, at least not the wallclock time in seconds. If I had to guess without stepping into the code, I wouldsuspect that the code was returning a real(8) instead of the documented real(4).

For the time being, I have followed the recommendation and changed my code to use CPU_TIME.

Regards,
Chuck
0 Kudos
Steven_L_Intel1
Employee
737 Views
Yes, the units in this case are off by a factor of 1000. This should be fixed in 11.1. Even so, I recommend use of CPU_TIME instead.
0 Kudos
Reply