[libc-commits] [PATCH] D153388: [libc] Add basic utility support for timing functions on the GPU

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jun 21 06:45:37 PDT 2023


jhuber6 added a comment.

In D153388#4437714 <https://reviews.llvm.org/D153388#4437714>, @arsenm wrote:

> In D153388#4437695 <https://reviews.llvm.org/D153388#4437695>, @JonChesterfield wrote:
>
>> @arsenm what do you think of adding a built-in that expands to one of the above? This sort of "try to get the time" isn't libc specific and the switch over different builtins is basically architecture mess that ideally wouldn't get reimplemented in lot of different library code.
>
> That's kind of what I thought __builtin_readcyclecounter was for. I don't really understand the difference between the different time operations (e.g what is the difference between clock and time?)

The boards have a fixed-frequency clock and a cycle counter. The fixed-frequency clock from `time` is used for measuring absolute time elapsed because it is not matched to any frequency throttling or stalling the processor might do. The cycle counter from `clock` is the variable frequency clock that corresponds to the actual number of processor cycles that have elapsed since you last called it. In this patch I specifically choose to use `memtime` over `readcyclecounter` if available (As it is in RDNA2) because the former is 64-bits while the latter is only 20-bits. Getting the real time from the fixed-frequency clock requires querying the driver unfortunately.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153388/new/

https://reviews.llvm.org/D153388



More information about the libc-commits mailing list