Joseph Huber fa34b9e032 [libc] Add startup code implementation for GPU targets
This patch introduces startup code for executing `main` on a device
compiled for the GPU. We will primarily use this to run standalone
integration tests on the GPU. The actual execution of this routine will
need to be provided by a `loader` utility to bootstrap execution on the
GPU.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D143212
2023-02-07 11:36:16 -06:00

16 lines
698 B
C++

//===-- Implementation of crt for amdgpu ----------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
extern "C" __attribute__((device)) int main(int argc, char **argv);
// TODO: We shouldn't need to use the CUDA language to emit a kernel for NVPTX.
extern "C" [[gnu::visibility("protected")]] __attribute__((global)) void
_start(int argc, char **argv, int *ret) {
__atomic_fetch_or(ret, main(argc, argv), __ATOMIC_RELAXED);
}