Skip to content

Add GPU support for EnforceSingleRow operator #16888

@perlitz

Description

@perlitz

Problem

When running Presto TPC-DS queries with cuDF backend enabled, the EnforceSingleRow operator falls back to CPU
execution because no GPU implementation exists. This operator appears 26 times across TPC-DS queries at SF100.

Related to #15772 (tracking issue for missing cuDF operators in TPC-DS)

Description

EnforceSingleRow is a simple operator that validates input produces at most one row and throws an exception if more
than one row is detected. It's commonly used in scalar subqueries.

TPC-DS Queries Affected

Queries using EnforceSingleRow (27 total occurrences across these queries):

  • Q6 (1 occurrence) ✓
  • Q9 (15 occurrences) - fails due to unrelated NestedLoopJoin issue
  • Q14 (3 occurrences) ✓
  • Q24 (1 occurrence) ✓
  • Q44 (2 occurrences) ✓
  • Q54 (2 occurrences) ✓
  • Q58 (3 occurrences) ✓

Implementation Approach

The GPU implementation (CudfEnforceSingleRow) should:

  1. Accept GPU input and produce GPU output (maintain GPU pipeline continuity)
  2. Check row count on GPU using cuDF table APIs
  3. Throw VeloxUserError if row count > 1
  4. Pass through the single row unchanged
  5. Include a config flag cudf.enable_enforce_single_row to allow toggling for performance measurement

Performance Characteristics

Based on benchmarks SF100 data with PR #16357, the GPU implementation shows comparable performance to CPU (±5%
variance), which is expected given:

  • The operator is lightweight (just a row count check)
  • Typical input is 0-1 rows
  • The benefit is avoiding GPU↔CPU transfers in the operator pipeline, not faster execution of the check itself

Implementation Status

  • CudfEnforceSingleRow implementation
  • Unit tests (EnforceSingleRowTest.cpp)
  • Integration with operator adapter registry
  • Configuration support (cudf.enable_enforce_single_row)
  • PR submitted (will link once created)

Related Work

Metadata

Metadata

Assignees

No one assigned

    Labels

    cudfcudf related - GPU accelerationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions