NVIDIA / NVIDIA/cccl

Extend `DeviceTransform::TransformIf` to support a stencil array

Open
#5,572 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

Thrust offers a `transform_if` algorithm evaluating a predicate on a dedicated stencil array. If the predicate is true, the input elements are loaded for the transformation function, the function is applied, and the results are written back. A naive implementation (based on a `for_each`) only needs to fully load the stencil data, and can skip any loads and stores of input and output data if the predicate is false.

PR #5296 tried to use `DeviceTransform::TransformIf` and loaded all the data and only passing the stencil input to the predicate and the other inputs to the transformation function. This gave speedups for small data types (more throughput due to bulk copy), but slowdowns for larger data types (all data is always loaded).

We could consider extending `DeviceTransform::TransformIf` to load and evaluate the stencil first, potentially exchanging the result of the predicate with neighboring threads and then decide to bulk load (or vector load, or prefetch) the actual data and evaluate the transformation.

For now, we imagine the need for a `transform_if` with stencil as small, but anybody is free to comment and proof us wrong :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.