[all-commits] [llvm/llvm-project] a62130: [libc] Implement basic `malloc` and `free` support...
Joseph Huber via All-commits
all-commits at lists.llvm.org
Mon Jun 5 15:57:12 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a6213088812f813ce8527139f4aa9c03f40c7c1d
https://github.com/llvm/llvm-project/commit/a6213088812f813ce8527139f4aa9c03f40c7c1d
Author: Joseph Huber <jhuber6 at vols.utk.edu>
Date: 2023-06-05 (Mon, 05 Jun 2023)
Changed paths:
M libc/src/__support/RPC/rpc.h
M libc/src/stdlib/CMakeLists.txt
A libc/src/stdlib/free.h
A libc/src/stdlib/gpu/CMakeLists.txt
A libc/src/stdlib/gpu/free.cpp
A libc/src/stdlib/gpu/malloc.cpp
A libc/src/stdlib/malloc.h
M libc/test/src/stdlib/CMakeLists.txt
A libc/test/src/stdlib/malloc_test.cpp
M libc/utils/gpu/loader/CMakeLists.txt
M libc/utils/gpu/loader/Server.h
M libc/utils/gpu/loader/amdgpu/Loader.cpp
M libc/utils/gpu/loader/nvptx/Loader.cpp
Log Message:
-----------
[libc] Implement basic `malloc` and `free` support on the GPU
This patch adds support for the `malloc` and `free` functions. These
currently aren't implemented in-tree so we first add the interface
filies.
This patch provides the most basic support for a true `malloc` and
`free` by using the RPC interface. This is functional, but in the future
we will want to implement a more intelligent system and primarily use
the RPC interface more as a `brk()` or `sbrk()` interface only called
when absolutely necessary. We will need to design an intelligent
allocator in the future.
The semantics of these memory allocations will need to be checked. I am
somewhat iffy on the details. I've heard that HSA can allocate
asynchronously which seems to work with my tests at least. CUDA uses an
implicit synchronization scheme so we need to use an explicitly separate
stream from the one launching the kernel or the default stream. I will
need to test the NVPTX case.
I would appreciate if anyone more experienced with the implementation details
here could chime in for the HSA and CUDA cases.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D151735
Commit: e6c401b5e84619c542b3db0d977fe622e872cfa1
https://github.com/llvm/llvm-project/commit/e6c401b5e84619c542b3db0d977fe622e872cfa1
Author: Joseph Huber <jhuber6 at vols.utk.edu>
Date: 2023-06-05 (Mon, 05 Jun 2023)
Changed paths:
M libc/config/gpu/api.td
M libc/config/gpu/entrypoints.txt
M libc/config/gpu/headers.txt
M libc/src/__support/File/file.cpp
M libc/src/__support/File/file.h
A libc/src/__support/File/gpu/CMakeLists.txt
A libc/src/__support/File/gpu/dir.cpp
A libc/src/__support/File/gpu/file.cpp
M libc/src/__support/RPC/rpc.h
M libc/test/src/stdio/CMakeLists.txt
M libc/utils/gpu/loader/Server.h
Log Message:
-----------
[libc] Add initial support for 'puts' and 'fputs' to the GPU
This patch adds the initial support required to support basic priting in
`stdio.h` via `puts` and `fputs`. This is done using the existing LLVM C
library `File` API. In this sense we can think of the RPC interface as
our system call to dump the character string to the file. We carry a
`uintptr_t` reference as our native "file descriptor" as it will be used
as an opaque reference to the host's version once functions like
`fopen` are supported.
For some unknown reason the declaration of the `StdIn` variable causes
both the AMDGPU and NVPTX backends to crash if I use the `READ` flag.
This is not used currently as we only support output now, but it needs
to be fixed
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D151282
Compare: https://github.com/llvm/llvm-project/compare/30bd96fa17f9...e6c401b5e846
More information about the All-commits
mailing list