Is your feature request related to a problem? Please describe.
cuDF's current UDF interfaces make the implementation fragment and the selected entry point
inseparable.
For CUDA source UDFs, cuDF identifies and rewrites the first function declaration using textual
parsing. This works for simple, self-contained UDFs, but it prevents a source fragment from safely
containing helper functions or multiple UDF entry points. It also makes it difficult to invoke a
function template or a function supplied by a separate header.
Precompiled UDFs have a similar limitation. A fragment is associated with one predetermined symbol,
so an application cannot select one of several functions from the same compiled fragment at runtime.
Nor can it compose a UDF from multiple precompiled fragments containing shared utilities and the
selected operation.
These restrictions lead to duplicated source and binary fragments, limit code reuse, and make
runtime dispatch more expensive than necessary.
Describe the solution you'd like
Extend the UDF representation so callers specify how a UDF is invoked independently of the source
or binary fragments that provide it:
- For CUDA source UDFs, accept an explicit invocation expression or entry-point specification
instead of discovering the first function in the source.
- Allow CUDA UDFs to provide multiple named headers and include paths. The invocation expression
should be able to reference functions or templates declared by those headers.
- For PTX and LTO IR UDFs, require the symbol name of the function to invoke.
- Allow a precompiled UDF to contain multiple PTX, LTO IR, or compatible binary fragments. The
runtime linker should resolve the requested symbol and its dependencies across those fragments.
- Include the invocation expression, symbol, headers, fragments, and relevant compilation options
in the JIT cache key.
- Report clear compilation or linking errors when the requested entry point is missing, duplicated,
or has an incompatible ABI.
This should support UDFs that share helper code, runtime selection among several precompiled
operations, CUDA function templates defined in supplied headers, and UDFs assembled from
independently compiled operation and utility fragments.
Describe alternatives you've considered
- Continue requiring one source or binary fragment per UDF. This preserves the current
implementation but duplicates shared code and prevents runtime symbol selection.
- Generate a new CUDA wrapper for every selected function. This enables dispatch but still invokes
the CUDA C++ frontend and does not solve precompiled-fragment composition.
- Expand the existing text parser to recognize more CUDA syntax. A text parser cannot reliably
provide C++ semantic analysis and would remain fragile for templates, macros, and included code.
Additional context
The prototype for this proposal is implemented in #23548
Is your feature request related to a problem? Please describe.
cuDF's current UDF interfaces make the implementation fragment and the selected entry point
inseparable.
For CUDA source UDFs, cuDF identifies and rewrites the first function declaration using textual
parsing. This works for simple, self-contained UDFs, but it prevents a source fragment from safely
containing helper functions or multiple UDF entry points. It also makes it difficult to invoke a
function template or a function supplied by a separate header.
Precompiled UDFs have a similar limitation. A fragment is associated with one predetermined symbol,
so an application cannot select one of several functions from the same compiled fragment at runtime.
Nor can it compose a UDF from multiple precompiled fragments containing shared utilities and the
selected operation.
These restrictions lead to duplicated source and binary fragments, limit code reuse, and make
runtime dispatch more expensive than necessary.
Describe the solution you'd like
Extend the UDF representation so callers specify how a UDF is invoked independently of the source
or binary fragments that provide it:
instead of discovering the first function in the source.
should be able to reference functions or templates declared by those headers.
runtime linker should resolve the requested symbol and its dependencies across those fragments.
in the JIT cache key.
or has an incompatible ABI.
This should support UDFs that share helper code, runtime selection among several precompiled
operations, CUDA function templates defined in supplied headers, and UDFs assembled from
independently compiled operation and utility fragments.
Describe alternatives you've considered
implementation but duplicates shared code and prevents runtime symbol selection.
the CUDA C++ frontend and does not solve precompiled-fragment composition.
provide C++ semantic analysis and would remain fragile for templates, macros, and included code.
Additional context
The prototype for this proposal is implemented in #23548