This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add basic support for calling host functions from the GPU
ClosedPublic

Authored by jhuber6 on Jul 11 2023, 12:19 PM.

Details

Summary

This patch adds the rpc_host_call function as a GPU extension. This is
exported from the libc project to use the RPC interface to call a
function pointer via RPC any copying the arguments by-value. The
interface can only support a single void pointer argument much like
pthreads. The function call here is the bare-bones version of what's
required for OpenMP reverse offloading. Full support will require
interfacing with the mapping table, nowait support, etc.

I decided to test this interface in libomptarget as that will be the
primary consumer and it would be more difficult to make a test in libc
due to the testing infrastructure not really having a concept of the
"host" as it runs directly on the GPU as if it were a CPU target.

Diff Detail

Event Timeline

jhuber6 created this revision.Jul 11 2023, 12:19 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 11 2023, 12:19 PM
jhuber6 requested review of this revision.Jul 11 2023, 12:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 12:19 PM
jhuber6 updated this revision to Diff 539241.Jul 11 2023, 12:24 PM

Make the test work for the CPU targets.

Could you find somewhere to document very explicitly that the pointer in question is to some function on the host and not to some function on the gpu, and not some magic thing which can be called on either?

Could you find somewhere to document very explicitly that the pointer in question is to some function on the host and not to some function on the gpu, and not some magic thing which can be called on either?

I probably should have some documentation for these "GPU" extensions. Though I only expect one more for the H2D / D2H memcpy. I'll just put it in the implementation for now.

jhuber6 updated this revision to Diff 539243.Jul 11 2023, 12:28 PM

Add comment

jplehr accepted this revision.Jul 19 2023, 2:21 AM

LGTM

openmp/libomptarget/test/libc/host_call.c
55

Nit: Should main return something?

This revision is now accepted and ready to land.Jul 19 2023, 2:21 AM