Skip to content

Commit 70b1c39

Browse files
committed
[libc][Docs] Add some motivation for the GPU libc
This provides some basic motivation behind the GPU libc. Suggests are welcome. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D152028
1 parent 7a70968 commit 70b1c39

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

libc/docs/gpu/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ learn more about this project.
1616
support
1717
testing
1818
rpc
19+
motivation

libc/docs/gpu/motivation.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.. _libc_gpu_motivation:
2+
3+
==========================
4+
Motivation and Limitations
5+
==========================
6+
7+
.. contents:: Table of Contents
8+
:depth: 4
9+
:local:
10+
11+
Motivation
12+
==========
13+
14+
This project aims to provide a large subset of the C standard library to users
15+
of GPU accelerators. We deliberately choose to only implement a subset of the C
16+
library as some features are not expressly useful or easily implemented on the
17+
GPU. This will be discussed further in `Limitations <libc_gpu_limitations>`_.
18+
The main motivation behind this project is to provide the well understood C
19+
library as a firm base for GPU development.
20+
21+
The main idea behind this project is that programming GPUs can be as
22+
straightforward as programming on CPUs. This project aims to validate the GPU as
23+
a more general-purpose target. The implementations here will also enable more
24+
complex implementations of other libraries on the GPU, such as ``libc++``.
25+
26+
Host services and C library features are currently provided sparsely by the
27+
different GPU vendors. We wish to provide these functions more completely and
28+
make their implementations available in a common format. This is useful for
29+
targets like OpenMP offloading or SYCL which wish to unify the offloading
30+
toolchain. We also aim to provide these functions in a format compatible with
31+
offloading in ``Clang`` so that we can treat the C library for the GPU as a
32+
standard static library.
33+
34+
A valuable use for providing C library features on the GPU is for testing. For
35+
this reason we build `tests on the GPU <libc_gpu_testing>`_ that can run a unit
36+
test as if it were being run on the CPU. This also helps users port applications
37+
that traditionally were run on the CPU. With this support, we can expand test
38+
coverage for the GPU backend to the existing LLVM C library tests.
39+
40+
.. _libc_gpu_limitations:
41+
42+
Limitations
43+
===========
44+
45+
We only implement a subset of the standard C library. The GPU does not
46+
currently support thread local variables in all cases, so variables like
47+
``errno`` are not provided. Furthermore, the GPU under the OpenCL execution
48+
model cannot safely provide a mutex interface. This means that features like
49+
file buffering are not implemented on the GPU. We can also not easily provide
50+
threading features on the GPU due to the execution model so these will be
51+
ignored, as will features like ``locale`` or ``time``.

libc/docs/gpu/support.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Supported Functions
1212

1313
The following functions and headers are supported at least partially on the
1414
device. Some functions are implemented fully on the GPU, while others require a
15-
`remote procedure call <libc_gpu_rpc>`.
15+
`remote procedure call <libc_gpu_rpc>`_.
1616

1717
ctype.h
1818
-------

libc/docs/gpu/testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Testing Infrastructure
1919

2020
The testing support in LLVM's libc implementation for GPUs is designed to mimic
2121
the standard unit tests as much as possible. We use the `remote procedure call
22-
<libc_gpu_rpc>` support to provide the necessary utilities like printing from
22+
<libc_gpu_rpc>`_ support to provide the necessary utilities like printing from
2323
the GPU. Execution is performed by emitting a ``_start`` kernel from the GPU
2424
that is then called by an external loader utility. This is an example of how
2525
this can be done manually:

0 commit comments

Comments
 (0)