Actions
Feature #39491
closedrdtsc() support for s390x
Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
common
Target version:
-
% Done:
0%
Source:
Community (dev)
Tags:
Backport:
Description
z Systems (aka s390x/s390) supports a time-of-day clock of 64-bits whose bit 63 every 2**-12 seconds, (Bit 53 equates to a microsecond.) This would appear to serve as the source for the rdtsc() method in Cycles.h. I have a PR ready that will provide this capability. This patch looks as follows:
--- a/src/common/Cycles.h +++ b/src/common/Cycles.h @@ -78,6 +78,12 @@ class Cycles { uint32_t lo = 0, hi = 0; asm volatile("mftbu %0; mftb %1" : "=r" (hi), "=r" (lo)); return (((uint64_t)hi << 32) | lo); +#elif defined(__s390__) + uint64_t tod; + + asm volatile(" stck %0\n" + : "=Q" (tod) : : "cc"); + return (tod); #else #warning No high-precision counter available for your OS/arch return 0;
Note, this clock is a subset of a 128-bit clock kept by the hardware which supports multiple epochs. The base time for this clock is Jan 1 1900. The 64-bit subset will rollover in 2042.
The stck instruction guarantees a monotonically increasing value in a multiprocessor environment.
Updated by Greg Farnum almost 5 years ago
- Pull request ID set to 27797
Updated by Kefu Chai almost 5 years ago
- Status changed from New to Fix Under Review
Updated by Kefu Chai over 4 years ago
- Status changed from Fix Under Review to Resolved
Actions