mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 12:56:08 +00:00

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
140 lines
3.1 KiB
ReStructuredText
140 lines
3.1 KiB
ReStructuredText
.. _libc_gpu_support:
|
|
|
|
===================
|
|
Supported Functions
|
|
===================
|
|
|
|
.. include:: ../check.rst
|
|
|
|
.. contents:: Table of Contents
|
|
:depth: 4
|
|
:local:
|
|
|
|
The following functions and headers are supported at least partially on the
|
|
device. Some functions are implemented fully on the GPU, while others require a
|
|
`remote procedure call <libc_gpu_rpc>`_.
|
|
|
|
ctype.h
|
|
-------
|
|
|
|
============= ========= ============
|
|
Function Name Available RPC Required
|
|
============= ========= ============
|
|
isalnum |check|
|
|
isalpha |check|
|
|
isascii |check|
|
|
isblank |check|
|
|
iscntrl |check|
|
|
isdigit |check|
|
|
isgraph |check|
|
|
islower |check|
|
|
isprint |check|
|
|
ispunct |check|
|
|
isspace |check|
|
|
isupper |check|
|
|
isxdigit |check|
|
|
toascii |check|
|
|
tolower |check|
|
|
toupper |check|
|
|
============= ========= ============
|
|
|
|
string.h
|
|
--------
|
|
|
|
============= ========= ============
|
|
Function Name Available RPC Required
|
|
============= ========= ============
|
|
bcmp |check|
|
|
bzero |check|
|
|
memccpy |check|
|
|
memchr
|
|
memcmp |check|
|
|
memcpy |check|
|
|
memmove |check|
|
|
mempcpy |check|
|
|
memrchr |check|
|
|
memset |check|
|
|
stpcpy |check|
|
|
stpncpy |check|
|
|
strcat |check|
|
|
strchr
|
|
strcmp |check|
|
|
strcpy |check|
|
|
strcspn |check|
|
|
strlcat |check|
|
|
strlcpy |check|
|
|
strlen |check|
|
|
strncat |check|
|
|
strncmp |check|
|
|
strncpy |check|
|
|
strnlen |check|
|
|
strpbrk
|
|
strrchr
|
|
strspn |check|
|
|
strstr
|
|
strtok |check|
|
|
strtok_r |check|
|
|
strdup
|
|
strndup
|
|
============= ========= ============
|
|
|
|
stdlib.h
|
|
--------
|
|
|
|
============= ========= ============
|
|
Function Name Available RPC Required
|
|
============= ========= ============
|
|
abs |check|
|
|
atoi |check|
|
|
atof |check|
|
|
atol |check|
|
|
atoll |check|
|
|
exit |check| |check|
|
|
labs |check|
|
|
llabs |check|
|
|
div |check|
|
|
ldiv |check|
|
|
lldiv |check|
|
|
strtod |check|
|
|
strtof |check|
|
|
strtol |check|
|
|
strtold |check|
|
|
strtoll |check|
|
|
strtoul |check|
|
|
strtoull |check|
|
|
============= ========= ============
|
|
|
|
inttypes.h
|
|
--------
|
|
|
|
============= ========= ============
|
|
Function Name Available RPC Required
|
|
============= ========= ============
|
|
imaxabs |check|
|
|
imaxdiv |check|
|
|
strtoimax |check|
|
|
strtoumax |check|
|
|
============= ========= ============
|
|
|
|
stdio.h
|
|
--------
|
|
|
|
============= ========= ============
|
|
Function Name Available RPC Required
|
|
============= ========= ============
|
|
puts |check| |check|
|
|
fputs |check| |check|
|
|
fclose |check| |check|
|
|
fopen |check| |check|
|
|
fread |check| |check|
|
|
============= ========= ============
|
|
|
|
stdio.h
|
|
--------
|
|
|
|
============= ========= ============
|
|
Function Name Available RPC Required
|
|
============= ========= ============
|
|
clock |check|
|
|
============= ========= ============
|