Skip to content

[FEA] Replace the CUDA and PTX UDF parsers with explicit dispatch and direct linking #23566

Description

@lamarrr

Is your feature request related to a problem? Please describe.

cuDF currently rewrites CUDA and PTX UDFs with custom text parsers before compiling them.

The CUDA parser removes comments, finds the first opening parenthesis, and renames the preceding
token as the UDF entry point. Because it does not perform C++ semantic analysis, it cannot reliably
select a function when the source contains helper functions, templates, macros, or declarations
from included headers.

The PTX parser is substantially more complex. It parses a PTX function, maps register types to CUDA
types and inline-assembly constraints, and converts PTX instructions into inline PTX embedded in
generated CUDA source. This approach:

  • Duplicates part of the PTX grammar and ABI in cuDF.
  • Can mis-handle instruction operands, parameter layouts, or register constraints.
  • Must be updated when PTX syntax or semantics evolve.
  • Still invokes the CUDA C++ frontend even though the input is already PTX.
  • Can produce architecture-specific failures that are difficult to diagnose.

Describe the solution you'd like

Remove both custom UDF parsers after explicit UDF entry-point selection is available:

  • Require CUDA UDF callers to provide an invocation expression or explicit entry point. Compile the
    supplied source and headers without discovering or renaming a function.
  • Pass PTX UDF fragments directly to nvJitLink through RTCX instead of translating PTX into
    inline CUDA.
  • Generate a small, typed dispatcher only when cuDF must adapt its kernel entry ABI to the selected
    UDF symbol.
  • Let nvJitLink diagnose unresolved symbols, duplicate definitions, unsupported PTX, and ABI
    mismatches.
  • Remove ptx_parser, parse_single_function_ptx, and parse_single_function_cuda after all
    callers use explicit dispatch.
  • Add coverage for multiple functions, helper functions, templates, external headers, overloaded
    names, and PTX generated for every supported GPU architecture.
  • Document any compatibility or deprecation period required for existing UDF callers.

Describe alternatives you've considered

  • Continue extending the custom PTX parser. This retains a large maintenance surface and cannot
    delegate validation and optimization to NVIDIA's linker.
  • Replace the text parser with a full CUDA or Clang frontend. This would add a large dependency and
    duplicate work already performed by NVRTC and nvJitLink.
  • Keep generating CUDA wrappers around PTX. This preserves the extra frontend compilation step and
    the fragile PTX-to-inline-assembly conversion.

Additional context

  • Current implementation:
    cpp/src/jit/parser.cpp
  • A PTX operand mismatch surfaced as an architecture-specific failure in
    #21597.
  • #22496 lists replacing the PTX parser with proper
    PTX linking as follow-up work.
  • #23548 Implements a prototype of this proposal

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feature requestNew feature or requestlibcudfAffects libcudf (C++/CUDA) code.

Projects

  • Status
    No status

Relationships

None yet

Development

No branches or pull requests

Issue actions