-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
Description
Currently users of liboffload have to manually build and link any input PTX files into CUBIN files. For example (from Unified Runtime):
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.