Operators#

Operators are the MathDx + pieces used to compose processing steps in a fused kernel (ingest, exgest, pointwise, area). Each step also carries the compile-time configuration it needs (formats, tile geometry, architecture). NPPDx follows the same MathDx programming model as other device extensions libraries: compose each processing step by joining operators with +. See Terminology. The library validates each expression and generates specialized device code for the specified formats, tile geometry, and target architecture.

For detailed descriptions of each processing step (I/O, pointwise, and area including resize), see Processing overview.

Operators are composed from two groups:

  • Description: what to execute (I/O direction and format, image-processing function, tile size, precision, architecture, and optional Memory halo optimization).

  • Execution: how to execute on the GPU (block mapping and thread-block size).

Most function processing steps pair a function tag (Function<function:: ...>) with a parameter piece that supplies compile-time values (kernel size, color spaces, resize ratio, and so on). Ingest and exgest steps pair InputOutput with InputFormat or OutputFormat.

Composing a processing step#

Start by joining a series of MathDx operators with +.

Example: minimal ingest step:

using Ingest = decltype(
    InputOutput<input_output_direction::ingest>() +
    InputFormat<packing_format::rgb24>() +
    TileSize<48, 48>() +
    Block() +
    SM<900>());

Example compute step between ingest and exgest:

using Blur = decltype(
    Function<function::box_blur>() +
    BoxBlur<5, 5>() +
    TileSize<48, 48>() +
    Block() +
    SM<900>());

Description operators#

I/O operators#

Operator

Description

InputOutput<input_output_direction::ingest>

Ingest: load data arranged in global memory according to its packing format into an internal tile (with halo when required). See Ingest.

InputOutput<input_output_direction::exgest>

Exgest: write an internal tile to global memory according to its packing format. See Exgest.

InputFormat<packing_format:: ...>

Selects the packed input layout for ingest. See Packing formats (InputFormat / OutputFormat).

OutputFormat<packing_format:: ...>

Selects the packed output layout for exgest. See Packing formats (InputFormat / OutputFormat).

Architecture and tile geometry#

Operator

Description

SM<Architecture>

Target GPU architecture (for example SM<900> for Hopper). Required for a complete operator.

TileSize<X, Y>

Tile width and height in pixels. All operators in the same fused kernel must use the same tile size.

Function tag operator (processing step)#

Function<function::Tag> selects the image-processing step. Pair it with the matching parameter operator listed in the next section. Detailed behavior is in Processing overview.

function value

Kind

color_convert

Pointwise color-space / bit-depth conversion. See Color convert.

gamma

Forward or inverse gamma (SDR, HLG, or PQ). See Gamma.

affine_channel_map

Per-channel affine map out = (in + pre) * num / den + post. See Affine channel map.

box_blur

Box blur (arithmetic mean); kernel size from BoxBlur<W, H>. See Box blur.

gaussian_blur

Discrete Gaussian FIR; pixel radius from GaussianBlur<RadiusTenths, TailWidth>. See Gaussian blur.

median

Median filter; shape from Median<median_radius:: ...>. See Median filter.

sharpen

3x3 convolutional sharpen; weights from Sharpen<Weights>. See Sharpen.

resize

Rational resize J \(\rightarrow\) K samples; method from Resize<J, K, Method>. See Resize.

Function parameter operators#

Operator

Parameters / notes

ColorConvert<InputCS, OutputCS, InputDepth, OutputDepth>

color_space: rgb, yuv_bt601, yuv_bt709, yuv_bt2020. bit_depth: bpp_8u, bpp_10u, bpp_16u. See Color convert.

GammaTransform<BitDepth, Direction, TransferFunction>

gamma_dir: forward, inverse. gamma_transfer_function: SDR, HLG, PQ. See Gamma.

AffineChannelMap<Pre, Num, Den, Post[, ClipMin, ClipMax]>

Integer affine coefficients; use NPPDX_AFFINE_NO_CLIP to disable a clip bound. See Affine channel map.

BoxBlur<Width, Height>

Odd kernel sizes \(\geq\) 1. See Box blur.

GaussianBlur<RadiusTenths[, TailWidth]>

Pixel radius 0.1–10.0 (RadiusTenths 1–100). Optional TailWidth: standard (default) or wide (same \(\sigma\), greater support; RadiusTenths \(\leq\) 50). See Gaussian blur.

Median<Radius>

Square (r1_0, r2_0) and round (r0_5, r1_5) neighborhoods. See Median filter.

Sharpen<Weights>

3x3 convolutional sharpen; use sharpen_weights::rosenfeld_generalized_weights<N> for generalized Laplacian. See Sharpen.

Resize<J, K, Method>

Coprime J, K. interpolation_method: nearest, bilinear, bicubic, lanczos3. See Resize.

Halo operators#

Neighborhood steps derive a local halo from their parameter operator. A fused kernel’s cumulative halo is composed from those local halos – overlap between tiles and extended ingest region for tiled processing – and the remaining halo on each step is tracked through MemoryHalo and CumulativeHalo (see Halos and step order).

Operator

Description

MemoryHalo<LeftTop, RightBottom>

Override the in-tile buffer border for this step (advanced). LeftTop and RightBottom are Int2D compile-time values.

CumulativeHalo<LeftTop, RightBottom>

Remaining halo on this step. On ingest, set to the fused kernel’s full cumulative halo – minimum additional data so every processing step can run without boundary-condition considerations – composed from the local halos of neighborhood steps in the kernel. Set MemoryHalo and CumulativeHalo on each step as in the area and resize examples; they are not automatically filled in.

Packing formats (InputFormat / OutputFormat)#

The packing_format enumerators available for I/O operators:

Packed RGB: rgb24, rgb10, rgb16

Packed YUV 4:2:2: yuv2, y210, uyvp, v210

Semi-planar YUV: nv12, p010 (4:2:0); nv16, p216 (4:2:2)

Planar: rgbp, bgrp; yuv420p, yuv420p10; yuv422p, yuv422p10; yuv444p, yuv444p10

See Requirements and Functionality for release-level format support. The authoritative enum is in operators/formats.hpp.

Execution operators#

Operator

Description

Block

Block-level execution mapping (the supported execution mode in the current release).

BlockDim<X, 1, 1>

CUDA thread-block size. NPPDx uses 1D thread indexing: Y and Z must be 1.

Complete processing steps (composed operators)#

A processing step is complete when it includes the operators required for its role:

  • Ingest / exgest: InputOutput, matching format operator, TileSize, Block, SM, and (for block Shared-memory APIs) BlockDim.

  • Function operator: Function<...>, matching parameter operator, TileSize, Block, SM, and BlockDim when executing on a block.

Use is_supported_v or the shipped examples to confirm that a specific combination of operators, tile size, format, and architecture is implemented for the workload.