mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 01:55:08 +00:00
30307a7bb7
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 |
||
---|---|---|
.. | ||
AOR_v20.02 | ||
benchmarks | ||
cmake/modules | ||
config | ||
docs | ||
examples | ||
fuzzing | ||
include | ||
lib | ||
spec | ||
src | ||
startup | ||
test | ||
utils | ||
.clang-tidy | ||
.gitignore | ||
CMakeLists.txt | ||
common_libc_tuners.cmake | ||
LICENSE.TXT | ||
README.txt |
LLVM libc ========= This directory and its subdirectories contain source code for llvm-libc, a retargetable implementation of the C standard library. LLVM is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.