summaryrefslogtreecommitdiff
path: root/libc/src/time/gpu/clock.cpp
AgeCommit message (Collapse)Author
2025-01-07[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)Joseph Huber
Summary: This patch switches the GPU utility helpers to wrapping around the gpuintrin.h ones with a C++ flavor.
2024-12-05Reapply "[libc][windows] start time API implementation (#117775)" (#118886)Schrodinger ZHU Yifan
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek
This is a part of #97655.
2024-05-10Reland "[libc][NFC] adjust time related implementations"" (#91687)Schrodinger ZHU Yifan
Reverts llvm/llvm-project#91657 and Relands #91485
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-08-30[libc] Implement the 'clock()' function on the GPUJoseph Huber
This patch implements the `clock()` function on the GPU. This function is supposed to return a timestamp that can be converted into seconds using the `CLOCKS_PER_SEC` macro. The GPU has a fixed frequency timer that can be used for this purpose. However, there are some considerations. First is that AMDGPU does not have a statically known fixed frequency. I know internally that the gfx10xx and gfx11xx series use a 100 MHz clock which will probably remain for the future. Gfx9xx typically uses a 25 MHz clock except for the Vega 10 GPU. The only way to know for sure is to look it up from the runtime. For this purpose, I elected to default it to some known values and assign these to an exteranlly visible symbol that can be initialized if needed. If we do not have a good guess we just return zero. Second is that the `CLOCKS_PER_SEC` macro only gives about a microsecond of resolution. POSIX demands that it's 1,000,000 so it's best that we keep with this tradition as almost all targets seem to respect this. The reason this is important is because on the GPU we will almost assuredly be copying the host's macro value (see the wrapper header) so we should go with the POSIX version that's most likely to be set. (We could probably make a warning if the included header doesn't match the expected value). Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D159118