[PATCH] D105969: [flang] Add default implementation for SYSTEM_CLOCK

Diana Picus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 14 03:38:57 PDT 2021


rovka created this revision.
rovka added reviewers: klausler, jeanPerier, clementval.
rovka added a project: Flang.
Herald added a subscriber: jdoerfert.
rovka requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add an implementation for the runtime functions related to SYSTEM_CLOCK.
As with CPU_TIME, this is based on std::clock(), which should be
available everywhere, but it is highly recommended to add
platform-specific implementations for systems where std::clock() behaves
poorly (e.g. POSIX).

The documentation for std::clock() doesn't specify a maximum value and
in fact wrap around behaviour is non-conforming.  Therefore, this
implementation of SYSTEM_CLOCK is not guaranteed to wrap around either,
and after std::clock reaches its maximum value we will likely just
return failure rather than wrap around. If this happens often on your
system, please add a new platform-specific implementation.

We define COUNT_MAX as either the maximum value that can be stored in
a std::clock_t or in a 64-bit integer (whichever is smaller), and
COUNT_RATE as CLOCKS_PER_SEC. For POSIX systems, the value of
CLOCKS_PER_SEC is hardcoded to 10^6 and irrelevant for the values
returned by std::clock.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105969

Files:
  flang/runtime/time-intrinsic.cpp
  flang/unittests/RuntimeGTest/Time.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105969.358551.patch
Type: text/x-patch
Size: 3958 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210714/ce6b82fa/attachment.bin>


More information about the llvm-commits mailing list