This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add startup code implementation for GPU targets
ClosedPublic

Authored by jhuber6 on Feb 2 2023, 12:53 PM.

Details

Summary

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.

Diff Detail

Event Timeline

jhuber6 created this revision.Feb 2 2023, 12:53 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 2 2023, 12:53 PM
jhuber6 requested review of this revision.Feb 2 2023, 12:53 PM
jhuber6 updated this revision to Diff 494419.Feb 2 2023, 12:55 PM

Remove unrelated change.

I had a hard time testing these changes. For reasons unknown to me, this does
not seem to actually build the sources. Thus, the install does not have a file
to install. I copied the source mostly from the existing support for linux but
it seems like it doesn't create a standard object library that is linked in.
Rather we extract the object manually. This is also a bit problematic as we will
need to pass --target= to the link job to tell it to use the appropriate
toolchain for the linking job.

Reading the patch doesn't show me any obvious problems. Can you tell me how to reproduce what you are seeing?

Reading the patch doesn't show me any obvious problems. Can you tell me how to reproduce what you are seeing?

The only issue right now is that I don't see the crt1.o being built anywhere. The install line then fails to find it at install time. I wasn't sure how this dependency is supposed to be handled. It might be difficult for you to reproduce right now because I'm assuming you don't have a GPU on your system. I'll need to add those lines that let you force a build of one GPU architecture for testing.

sivachandra accepted this revision.Feb 6 2023, 4:15 PM
sivachandra added inline comments.
libc/startup/gpu/CMakeLists.txt
93

The problem is here: replace ${LIBC_COMPONENT} with libc.

This revision is now accepted and ready to land.Feb 6 2023, 4:15 PM
jhuber6 updated this revision to Diff 495336.Feb 6 2023, 5:49 PM

Updating the component. This works now with ninja install-libc. it would be nice if we could add a public link interface to use --target= so that anything linking against the startup code will use the correct device linker.

This revision was automatically updated to reflect the committed changes.