unified-runtime icon indicating copy to clipboard operation
unified-runtime copied to clipboard

Consider changing `urProgramGetFunctionPointer` to `urProgramQueryHasKernel`

Open callumfare opened this issue 2 years ago • 1 comments

E.g.

ur_result_t urProgramQueryHasKernel(ur_program_handle_t hProgram, const char *pKernelName, bool *pHasKernelRet);

Currently SYCL-RT only uses urProgramGetFunctionPointer to check whether a program contains a kernel, and doesn't use the actual value of the result. This is only implementable in the OpenCL adapter by using the undocumented clGetDeviceFunctionPointer extension function, and we would like to rely on fewer vendor extensions.

We could implement this simplified entry point in the OpenCL adapter using clGetProgramInfo.

We can't just rely on the UR_PROGRAM_INFO_KERNEL_NAMES query, because this query cannot be implemented in the CUDA and HIP adapters, since there's no way to get the name of all functions in a module. There are long-standing comments in these adapters suggesting moving the has_kernel query from SYCL-RT to PI/UR.

Also, returning the actual function pointer in a backend-agnostic way doesn't make much sense, so it's unlikely other users of UR could make use of the existing entry point. Instead, using native interop of the program and kernel objects can be used to get the underlying function pointer.

callumfare avatar Sep 21 '23 10:09 callumfare

  • Is only implementable by OpenCL adapter, and even then only with extensions.
    • Possible that this could still represent an important use-case, e.g. on FPGA, needs to be investigated.
  • Seems like using interop would be more useful than this.

alycm avatar Jan 10 '24 16:01 alycm