From d04494ccc913d0fa0aba914d2336619ad03fa3b0 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Tue, 8 Aug 2023 11:55:32 -0500 Subject: [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 --- libc/src/stdio/gpu/stdout.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 libc/src/stdio/gpu/stdout.cpp (limited to 'libc/src/stdio/gpu/stdout.cpp') 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 + +namespace __llvm_libc { +static struct { +} stub; +FILE *stdout = reinterpret_cast(&stub); +} // namespace __llvm_libc +extern "C" FILE *stdout = reinterpret_cast(&__llvm_libc::stub); -- cgit v1.1