Issue |
149284
|
Summary |
[offload] Allow liboffload cuda plugin to accept PTX binaries as input
|
Labels |
offload
|
Assignees |
|
Reporter |
RossBrunton
|
Currently users of liboffload have to manually build and link any input PTX files into CUBIN files. For example (from Unified Runtime):
```c++
ur_result_t ProgramCreateCudaWorkaround(ur_context_handle_t hContext,
const uint8_t *Binary, size_t Length,
ur_program_handle_t hProgram) {
uint8_t *RealBinary;
size_t RealLength;
CUlinkState State;
cuLinkCreate(0, nullptr, nullptr, &State);
cuLinkAddData(State, CU_JIT_INPUT_PTX, (char *)(Binary), Length, nullptr, 0,
nullptr, nullptr);
void *CuBin = nullptr;
size_t CuBinSize = 0;
cuLinkComplete(State, &CuBin, &CuBinSize);
RealBinary = (uint8_t *)CuBin;
RealLength = CuBinSize;
auto Res = olCreateProgram(hContext->Device->OffloadDevice, RealBinary,
RealLength, &hProgram->OffloadProgram);
// Program owns the linked module now
cuLinkDestroy(State);
return offloadResultToUR(Res);
}
```
It makes sense for this format to be detected, built and linked in liboffload itself to save users from having to duplicate this logic and link against libcudadrv.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs