[libc] Add single threaded kernel attributes to AMDGPU startup utility (#104651)

Summary:
I fixed the errors here recently so I can actually use these. This
shouldn't impact much, just should hopefully make the code generated
slightly better.
This commit is contained in:
Joseph Huber 2024-08-18 12:50:15 -05:00 committed by GitHub
parent caa1070b1c
commit 5c13f9aea2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,7 +41,9 @@ static void call_fini_array_callbacks() {
} // namespace LIBC_NAMESPACE_DECL
extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel]] void
extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel,
clang::amdgpu_flat_work_group_size(1, 1),
clang::amdgpu_max_num_work_groups(1)]] void
_begin(int argc, char **argv, char **env) {
__atomic_store_n(&LIBC_NAMESPACE::app.env_ptr,
reinterpret_cast<uintptr_t *>(env), __ATOMIC_RELAXED);
@ -60,7 +62,9 @@ _start(int argc, char **argv, char **envp, int *ret) {
__atomic_fetch_or(ret, main(argc, argv, envp), __ATOMIC_RELAXED);
}
extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel]] void
extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel,
clang::amdgpu_flat_work_group_size(1, 1),
clang::amdgpu_max_num_work_groups(1)]] void
_end(int retval) {
// Only a single thread should call `exit` here, the rest should gracefully
// return from the kernel. This is so only one thread calls the destructors