brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · e637d67 Raw
52 lines · plain
1.. _libc_gpu_motivation:2 3==========================4Motivation and Limitations5==========================6 7.. contents:: Table of Contents8  :depth: 49  :local:10 11Motivation12==========13 14This project aims to provide a large subset of the C standard library to users15of GPU accelerators. We deliberately choose to only implement a subset of the C16library as some features are not expressly useful or easily implemented on the17GPU. This will be discussed further in `Limitations <libc_gpu_limitations>`_.18The main motivation behind this project is to provide the well understood C19library as a firm base for GPU development.20 21The main idea behind this project is that programming GPUs can be as22straightforward as programming on CPUs. This project aims to validate the GPU as23a more general-purpose target. The implementations here will also enable more24complex implementations of other libraries on the GPU, such as ``libc++``.25 26Host services and C library features are currently provided sparsely by the27different GPU vendors. We wish to provide these functions more completely and28make their implementations available in a common format. This is useful for29targets like OpenMP offloading or SYCL which wish to unify the offloading30toolchain. We also aim to provide these functions in a format compatible with31offloading in ``Clang`` so that we can treat the C library for the GPU as a32standard static library.33 34A valuable use for providing C library features on the GPU is for testing. For35this reason we build `tests on the GPU <libc_gpu_testing>`_ that can run a unit36test as if it were being run on the CPU. This also helps users port applications37that traditionally were run on the CPU. With this support, we can expand test38coverage for the GPU backend to the existing LLVM C library tests.39 40.. _libc_gpu_limitations:41 42Limitations43===========44 45We only implement a subset of the standard C library. The GPU does not46currently support thread local variables in all cases, so variables like47``errno`` are atomic and global. Furthermore, the GPU under the OpenCL execution48model cannot safely provide a mutex interface. This means that features like49file buffering are not implemented on the GPU. We can also not easily provide50threading features on the GPU due to the execution model so these will be51ignored, as will features like ``locale`` or ``time``.52