This is an archive of the discontinued LLVM Phabricator instance.

[libc][Docs] Add some motivation for the GPU libc
ClosedPublic

Authored by jhuber6 on Jun 2 2023, 1:42 PM.

Details

Summary

This provides some basic motivation behind the GPU libc. Suggests are welcome.

Diff Detail

Event Timeline

jhuber6 created this revision.Jun 2 2023, 1:42 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 2 2023, 1:42 PM
jhuber6 requested review of this revision.Jun 2 2023, 1:42 PM
jhuber6 updated this revision to Diff 527953.Jun 2 2023, 1:43 PM

Clean up leftover change

Honestly, I feel this is too pessimistic and short sighted. I understand we likely don't want everything on a GPU, maybe event can't, but I would not be so eager to guess for some of the things mentioned here. File I/O, for one, is on my TODO list. The entire "we do not want dependencies" is nice, but also somewhat irrelevant given that the vendor libs are linked in (to this day) anyway. Sure, we do not link them into libcgpu, but that is not because of some grant design, IMHO, but rather because we didn't need to (yet). Once libmgpu arrives, we will have to (or link libdevice later), so we will do what the motivation now states we don't want to.

libc/docs/gpu/motivation.rst
17

typo

55

2x currently

FWIW, GPUs have thread local variables, aka. local

Way back I started down this path because I thought running N lua virtual machines on a gpu would be an interesting programming model and the reference lua machine is written in C. Whether that's motivation for anyone else is not totally clear to me.

In principle I'd like to be able to do things like put a sqlite database instance in a persistent kernel. In general a persistent kernel that spawns other threads on the GPU and occasionally calls into the CPU is an interesting alternative to the current offload in batches model. Perhaps we'll be able to DMA from a nic into GPU memory, do some maths, push results back without the host cpu doing anything much.

Today my primary interest in libc is as a precise and comprehensive vehicle for stress testing the GPU back ends, so that when people try to use them for general purpose software things they have a better experience, but tomorrow I hope it'll be the layer below more complicated GPU applications.

libc/docs/gpu/motivation.rst
21

Libc isn't really here to provide host services. It's to provide a familiar userspace. It's also a reasonable foundation for bigger userspace stuff, notably libc++. Weve just started with the host services part because without syscall a lot of libc can't do anything.

jhuber6 updated this revision to Diff 528034.Jun 2 2023, 4:21 PM

Changing up, addressing comments

Honestly, I feel this is too pessimistic and short sighted. I understand we likely don't want everything on a GPU, maybe event can't, but I would not be so eager to guess for some of the things mentioned here. File I/O, for one, is on my TODO list.

I think that File I/O should be mostly straightforward. The existing interface I pushed for puts support pretty much just keeps a reference to a FILE * on the host. Using newer CUDA with asyncs in a separate stream we should be able to generically support H2D or D2H memcpy, so we should probably have some logic that lets us use that if the device pointer is global

The entire "we do not want dependencies" is nice, but also somewhat irrelevant given that the vendor libs are linked in (to this day) anyway. Sure, we do not link them into libcgpu, but that is not because of some grant design, IMHO, but rather because we didn't need to (yet). Once libmgpu arrives, we will have to (or link libdevice later), so we will do what the motivation now states we don't want to.

So, a long-term goal of this project is to provide a lot of those facilities in a more complete way. I think the initial invocation of libmgpu.a will simply map to the vendor libraries, but we can easily extend it further using a more generic implementation.

jdoerfert accepted this revision.Jun 16 2023, 10:03 AM

I still think it's too negative but OK for now

libc/docs/gpu/motivation.rst
39

@tianshilei1992 Can you link the IWOMP paper here please. In a follow up.

48–49
This revision is now accepted and ready to land.Jun 16 2023, 10:03 AM
This revision was automatically updated to reflect the committed changes.