This is an archive of the discontinued LLVM Phabricator instance.

[libc] Implement the RPC client / server for NVPTX
ClosedPublic

Authored by jhuber6 on Mar 24 2023, 2:07 PM.

Details

Summary

This patch adds the necessary code to impelement the existing RPC client
/ server interface when targeting NVPTX GPUs. This follows closely to
the implementation in the AMDGPU version. This does not yet enable unit
testing as the nvlink linker does not support static libraries. So
that will need to be worked around.

I am ignoring the RPC duplication between the AMDGPU and NVPTX loaders. This
will be changed completely later so there's no point unifying the code at this
stage. The implementation was tested manually with the following file and
compilation flags.

namespace __llvm_libc {
void write_to_stderr(const char *msg);
void quick_exit(int);
} // namespace __llvm_libc

using namespace __llvm_libc;

int main(int argc, char **argv, char **envp) {
  for (int i = 0; i < argc; ++i) {
    write_to_stderr(argv[i]);
    write_to_stderr("\n");
  }
  quick_exit(255);
}
$ clang++ crt1.o rpc_client.o quick_exit.o io.o main.cpp --target=nvptx64-nvidia-cuda -march=sm_70 -o image
$ ./nvptx_loader image 1 2 3
image
1
2
3
$ echo $?
255

Depends on D146681

Diff Detail

Event Timeline

jhuber6 created this revision.Mar 24 2023, 2:07 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 24 2023, 2:07 PM
jhuber6 requested review of this revision.Mar 24 2023, 2:07 PM
jdoerfert accepted this revision.Mar 24 2023, 3:51 PM

Matches the AMD side.

This revision is now accepted and ready to land.Mar 24 2023, 3:51 PM
This revision was landed with ongoing or failed builds.Mar 24 2023, 6:05 PM
This revision was automatically updated to reflect the committed changes.