aboutsummaryrefslogtreecommitdiff
path: root/libc/src/stdio/gpu/stdout.cpp
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2023-08-08 11:55:32 -0500
committerJoseph Huber <jhuber6@vols.utk.edu>2023-08-09 14:42:20 -0500
commitd04494ccc913d0fa0aba914d2336619ad03fa3b0 (patch)
tree6785c5e89547a0f744a8a2cce247f84c516be68c /libc/src/stdio/gpu/stdout.cpp
parent996559602bfb692030b6e63ab4cfa8ba205674fb (diff)
downloadllvm-d04494ccc913d0fa0aba914d2336619ad03fa3b0.zip
llvm-d04494ccc913d0fa0aba914d2336619ad03fa3b0.tar.gz
llvm-d04494ccc913d0fa0aba914d2336619ad03fa3b0.tar.bz2
[libc] Rework the file handling for the GPU
The GPU has much tighter requirements for handling IO functions. Previously we attempted to define the GPU as one of the platform files. Using a common interface allowed us to easily define these functions without much extra work. However, it became more clear that this was a poor fit for the GPU. The file interface uses function pointers, which prevented inlining and caused bad perfromance and resource usage on the GPU. Further, using an actual `FILE` type rather than referring to it as a host stub prevented us from usin files coming from the host on the GPU device. After talking with @sivachandra, the approach now is to simply define GPU specific versions of the functions we intend to support. Also, we are ignoring `errno` for the time being as it is unlikely we will ever care about supporting it fully. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D157427
Diffstat (limited to 'libc/src/stdio/gpu/stdout.cpp')
-rw-r--r--libc/src/stdio/gpu/stdout.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libc/src/stdio/gpu/stdout.cpp b/libc/src/stdio/gpu/stdout.cpp
new file mode 100644
index 0000000..02425d3
--- /dev/null
+++ b/libc/src/stdio/gpu/stdout.cpp
@@ -0,0 +1,16 @@
+//===-- Definition of the global stdout object ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+namespace __llvm_libc {
+static struct {
+} stub;
+FILE *stdout = reinterpret_cast<FILE *>(&stub);
+} // namespace __llvm_libc
+extern "C" FILE *stdout = reinterpret_cast<FILE *>(&__llvm_libc::stub);