Skip to content

[GPU] Device-side filters - #128777

Closed
scanhex12 wants to merge 1 commit into
masterfrom
gpu-device-filters
Closed

scanhex12 wants to merge 1 commit into
masterfrom
gpu-device-filters

Conversation

@scanhex12

@scanhex12 scanhex12 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Workflow [PR]
Sync PR [sync-upstream/pr/128777]

`GPUFilterCompiler` compiles a predicate of an `ActionsDAG` - comparisons of numeric, `Date`,
`Date32` and `DateTime` columns with each other and with constants, `and`, `or` and `not` - into a
`GPUFilterProgram`, a short program of registers, and `GPUFilter.cuh` evaluates such a program for
a row on the device. `compileGPUExpression` compiles a `Float64` computed by `plus`, `minus`,
`multiply` and `divide` into one as well. Nothing uses them yet: they are for the aggregations and
reads on the GPU to filter rows on the device.
@scanhex12
scanhex12 marked this pull request as draft November 2, 2026 23:06
@clickhouse-gh

clickhouse-gh Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cbb4892]

Summary: ❌

job_name test_name status info comment
Style check FAIL
whitespace_check FAIL cidb
Code Review DROPPED
Fast test (arm_darwin) DROPPED
Build (amd_debug) DROPPED
Build (amd_asan_ubsan) DROPPED
Build (amd_tsan) DROPPED
Build (amd_msan) DROPPED
Build (amd_binary) DROPPED
Build (arm_asan_ubsan) DROPPED
Build (arm_binary) DROPPED

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Nov 2, 2026
@scanhex12

Copy link
Copy Markdown
Member Author

I'll try to use JIT compilation to escape the creation another pipeline executor

@scanhex12 scanhex12 closed this Nov 4, 2026
Blargian pushed a commit to Blargian/ClickHouse that referenced this pull request Nov 10, 2026
…to PTX

The device evaluates a predicate or an expression over the columns of a row
with the code that the functions of ClickHouse compile into for the CPU, rather
than with a second implementation of their semantics.

`GPUExpressionCompiler` builds the `CompileDAG` of an output of `ActionsDAG`,
as the CPU's JIT does, and emits a kernel around `CompileDAG::compile`, a thread
for each row, that LLVM's NVPTX target turns into PTX for the device's
architecture. An expression with a function that does not compile, or with a
`Nullable` column, is refused, with the reason. A predicate's kernel writes the
null mask of cuDF directly, by `vote.ballot.sync`; an expression's kernel writes
a `Float64` for each row. The PTX is kept by the hash of the expression, and
`GPUExpression.cpp` loads it once, with `cudaLibraryLoadData`, and runs it with
`cudaLaunchKernel`.

- A string or `Decimal` constant compared with a column is converted to the
  column's type and the comparison rebuilt for it: `d < '1994-01-01'`.
- `FunctionComparison` compiles a comparison of two dates of the same type,
  `Date`, `Date32` or `DateTime`, as the integers that hold them, which the CPU's
  JIT gains as well.
- The bundled LLVM builds its NVPTX target with `ENABLE_GPU`, which now requires
  `ENABLE_EMBEDDED_COMPILER`.

Related: ClickHouse#119502
Related: ClickHouse#128777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant