[flang-commits] [flang] [llvm] [flang][flang-rt] Add support for non-standard TIMEF intrinsic (PR #185377)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Mon Mar 9 07:33:31 PDT 2026
================
@@ -413,6 +413,18 @@ double RTNAME(Dsecnds)(double *refTime, const char *sourceFile, int line) {
// GNU extension function TIME()
std::int64_t RTNAME(time)() { return time(nullptr); }
+// Intel extension function TIMEF()
+// Returns number of seconds that have elapsed since the first time
+// TIMEF was called. For the first call, it returns 0.
+double RTNAME(Timef)() {
+ static double first = -1;
----------------
eugeneepshteyn wrote:
`thread_local` could work, please try it.
Here's the parallel tests I wrote for `secnds()` intrinsic, you can adapt it to test multithreaded `timef()`:
```
use omp_lib
real sec_mid
real results(1000)
integer i, num_threads
results = 0.0
!$omp parallel do
do i=1, size(results)
results(i) = secnds(0.0)
num_threads = omp_get_num_threads()
end do
!$omp end parallel do
print *, "Number of threads in parallel region:", num_threads
sec_mid = minval(results)
print *, "Seconds from midnight: min:", sec_mid, ", max:", maxval(results)
call sleep(2)
!$omp parallel do
do i=1, size(results)
results(i) = secnds(sec_mid)
end do
!$omp end parallel do
print *, "Seconds from sec_mid: min:", minval(results), ", max:", maxval(results)
print *, "Seconds from midnight:", secnds(0.0)
end
```
https://github.com/llvm/llvm-project/pull/185377
More information about the flang-commits
mailing list