Project

General

Profile

Feature #39491

Updated by Nathan Cutler about 5 years ago

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: 

 <pre> 
 --- 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; 
 </pre> 

 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. 

Back