[all-commits] [llvm/llvm-project] 96e45a: [flang] Use full result range for clock_gettime im...
vdonaldson via All-commits
all-commits at lists.llvm.org
Thu Apr 14 13:01:55 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 96e45a8958cbfb5906f5b8b3c2423ad5dd884963
https://github.com/llvm/llvm-project/commit/96e45a8958cbfb5906f5b8b3c2423ad5dd884963
Author: V Donaldson <vdonaldson at nvidia.com>
Date: 2022-04-14 (Thu, 14 Apr 2022)
Changed paths:
M flang/docs/Extensions.md
M flang/runtime/time-intrinsic.cpp
Log Message:
-----------
[flang] Use full result range for clock_gettime implementation of SYSTEM_CLOCK
Update the primary clock_gettime implementation of SYSTEM_CLOCK to use
the full range of values, dependent on the type kind of the requested
result. Counts/sec and count max for supported kinds become:
kind counts/sec count max
1 10 127
2 1000 32767
4 1000 2147483647
8 1000000000 9223372036854775807
16 1000000000 9223372036854775807
The secondary "fallback" implementation is not changed.
Real valued COUNT_RATE arguments are not changed.
The test program below has calls for kinds 1, 2, 4, 8, 16. Support for
these types varies by compiler. The code as given can be restricted to
accommodate these variations, with results shown below.
subroutine c
integer(1) c1, r1, m1
integer(2) c2, r2, m2
integer(4) c4, r4, m4
integer(8) c8, r8, m8
integer(16) c16, r16, m16
print*
print '(a5,3a22)', 'kind', 'counts/sec', 'count max', 'count'
print*
call system_clock(c1, r1, m1)
print '(i5,3i22)', 1, r1, m1, c1
call system_clock(c2, r2, m2)
print '(i5,3i22)', 2, r2, m2, c2
call system_clock(c4, r4, m4)
print '(i5,3i22)', 4, r4, m4, c4
call system_clock(c8, r8, m8)
print '(i5,3i22)', 8, r8, m8, c8
call system_clock(c16, r16, m16)
print '(i5,3i22)', 16, r16, m16, c16
end
subroutine k(j)
j = 0
do i=1,1000000000
j = j + i
enddo
end
program p
do i=1,1 ! increase loop count to check for (kind=1) wraparound
call k(j)
call c
enddo
end
=== flang output without change (last column counts vary per run) ===
kind counts/sec count max count
1 -24 127 83
2 1000 290 211
4 1000 290 211
8 1000000000 290448383 211631452
16 1000000000 290448383 211633853
=== flang output with change (last column counts vary per run) ===
1 10 127 21
2 1000 32767 2100
4 1000 2147483647 2100
8 1000000000 9223372036854775807 2100183374
16 1000000000 9223372036854775807 2100185353
Other compilers; kind support varies (last column counts vary per run).
Test and ouput modified to avoid crashes and normalize results.
Some negative values indicate unsupported kinds; others are bugs.
kind counts/sec count max count
1 0 0 -127
2 0 0 -32767
4 1000 2147483647 69271692
8 1000000000 9223372036854775807 69271692353290
16 1000000000 9223372036854775807 69271692354794
=======
1 10 127 0
2 1000 32767 0
4 1000000 2147483647 0
8 10000000 9223372036854775807 9
=======
1 0 0 -127
2 1000 32767 3263
4 10000 2147483647 1788192630
8 1000000 9223372036854775807 1649443459263095
=======
1 -24 -1 36
2 1000 -1 -10716
4 1000 2147483647 176018980
8 1000 9223372036854775807 1649443460644
=======
2 100 28799 23080
4 100 8639999 4285480
8 100 8639999 4285480
16 100 8639999 4285480
=======
1 -24 -1 4
2 1000 23551 -26108
4 1000 86399999 67541508
8 1000000 9223372036854775807 1649443541508087
More information about the All-commits
mailing list