Skip to content

Functional/Non-Functional C++ Tile Evaluation #9038

Closed

Description

@fbusato

Functional/Non-Functional C++ Tile Evaluation

Tile-based GPU programming is a promising direction for both providing performance and maintainable code. As a new technology, it is fundamental to explore and evaluate capabilities and limitations in the context of CCCL algorithms.

In particular, this issue lists several functional and non-functional properties that should be covered to get a robust understanding of the new programming approach. This step is critical to understand future directions and development effort.

We will focus on the following routine for the exploration:

Functional

  • Correctness

    • What (current) cuTile limitations prevent algorithm implementation?
    • Numerical behavior compared to CUDA C++ implementation.
    • Could GPU arch-dependencies or constrains impact correctness?
  • API surface

    • What new APIs are introduced? and they could be coupled together with existing one? (are they stable, experimental, internal?)
    • Which input sizes, ranks, layouts, data types, execution spaces, or iterator/category are supported?
  • Interoperability

    • Interaction with existing CCCL components: CUB, Thrust, libcudacxx, CMake targets, tests, benchmarks.

Non-functional properties

Implementation Complexity

  • Is Tile documented enough?
  • Does the Tile implementation reduce or increase the amount work?
  • Are diagnostics good enough to understand the problem?
  • How well it support direct or automatic tuning?

Maintainability

  • Are implementation details isolated from public APIs?
  • What could be enforced in Debug mode?

Performance

  • Is Tile mature enough to compete with C++ implementation in terms of perfomance metrics? (do they have the same distribution properties, see NVBench)
  • Launch overhead? Impact of tuning?
  • Compilation intermediate steps inspection, e.g. IR

Ecosystem

  • How current tools Nsight Compute/Systems, nvdisasm, cuobjdump interact with Tile?

Compile time

  • How Tile compared to C++ implementation?
  • Linking time?

Binary size

  • Any changes in final or intermediate artifacts, e.g object files, fatbin

Activity

  1. added theissue type on May 15, 2026
  2. moved this from Todo to In Progress in CCCLon May 15, 2026
  3. nanan-nvidia commented on May 18, 2026

    @nanan-nvidia
    Contributor

    A tile kernel was implemented and did some test runs on RTX A6000 ADA.

    Of the 22 CUB::DeviceTransform benches ran on RTX A6000 ADA, 20 of them is on the same performance as CUB. The ones that showed sigificant performance degrade are two cases: fibonacci and heavy.

    1. fibonacci

    Measurements

    size      tile GElem/s   cub GElem/s   ratio
    2^16        152            144         1.06x
    2^20        441            553         0.80x
    2^24        505            673         0.75x
    2^28        501            684         0.73x
    

    Code on each side

    CUB (bench/fib_cub.cu):

    [] __device__ (int64_t n) -> int64_t {
        int64_t t1 = 0, t2 = 1;
        if (n < 1) return 0;
        if (n == 1) return 0;
        if (n == 2) return 1;
        for (int64_t k = 3; k <= n; ++k) {
            auto next = t1 + t2;  t1 = t2;  t2 = next;
        }
        return t2;
    }

    Tile (bench/fib_tile.cu):

    struct fib_op {
        template <class N> __tile__ auto operator()(N n) const {
            auto zero = n - n, one = zero + 1;
            auto t1 = zero, t2 = one;
            for (int i = 3; i <= MAX_FIB_N; ++i) {
                auto next = t1 + t2;
                auto cond = n >= i;
                t1 = ct::select(cond, t2, t1);
                t2 = ct::select(cond, next, t2);
            }
            auto out = ct::select(n < 1,  zero, t2);
            out     = ct::select(n == 1, zero, out);
            out     = ct::select(n == 2, one,  out);
            return out;
        }
    };

    The fundemental reason for performance difference is because how the tile semantics works : we have to operate on the whole tile. Therefore, we have to use fully unroll the kernel with ct::select which does a lot more wasted compute.

    2. heavy

    The tile kernel fails to launch at any size beyond 6K elements because Device-side malloc failed.

    The tile function is as follows:

    template <int N>
    struct heavy_op {
        template <class T> __tile__ auto operator()(T data) const {
            T reg[N];
            reg[0] = data;
            for (int i = 1; i < N; ++i) reg[i] = reg[i-1] * reg[i-1] + 1u;
            for (int i = 0; i < N; ++i) reg[i] = (reg[i] * reg[i]) % 19u;
            for (int i = 0; i < N; ++i) reg[i] = reg[N-i-1] * reg[i];
            T x = data - data;
            for (int i = 0; i < N; ++i) x = x + reg[i];
            return x;
        }
    };

    At compile time, lets say the input is int and with N=8 and TileSize=256, T is tile<int, shape<256>>. Here, with normal cuda semantics this should be 8 registers per thread; however, the nvcc frontend lowers this to

    %7 = alloca num_elem = 8192, alignment = 4 : tile<ptr<i8>>

    For N=8 with TileSize=256, that is 8 x 256 x 4 = 8192 bytes. This gets lowered to a malloc call on GPU:

    ...                                         ; execute only on thread0
    /*0090*/  MOV R0, 0x8
    /*00a0*/  MOV R4, 0x2000                    ; malloc size = 8192
    /*00b0*/  LDC.64 R2, c[0x4][R0]             ; R2 should now point to __cuda_syscall_aligned_malloc
    /*0160*/  CALL.ABS.NOINC R2                 ; CALL
    ...
    

    Therefore, reg[N] is entirely on global memory and allocated on heap (I did not even know you can call malloc on GPUs, LOL), which causes sigificant performance degrade and failures when there are too many elements to malloc.

    Not sure if this is the expected behavior of the front end, since for those cases we'd expect them to be on registers.

  4. nanan-nvidia commented on Jun 1, 2026

    @nanan-nvidia
    Contributor

    Benchmarks on B200s are on #9210. Walking through the checklist with answers we can give today.

    Functional

    Correctness

    cuTile limitations preventing algorithm implementation:

    • Pointers must be 16-byte aligned, otherwise it regresses to unvectorized loads
    • Limited support for numeric types, e.g. std::complex
    • Device side arrays are silently lowered to heap allocations
    • No SIMT support in Tile kernels, making it hard to incorporate into existing APIs

    Numerical behavior: We have correctness tests in #9210, all of them pass.

    Arch dependencies: cutile only supports sm80+.

    Interoperability

    • Device wise: __tile__ kernels are basically standalone and cannot be interleaved with SIMT kernels.
    • Host wise: once the kernels is compiled it is launch-able like any other kenel.

    Non-functional

    Implementation Complexity

    • Documentation: the public tile C++ spec is reasonable; however there are a lot of unspecified tune knobs. However, it is not intended for the users to use those tune knobs as they are expected to be handled by heuristics in the compiler.
    • LOC delta: Massively less code (-90%).
    • Diagnostics quality (mixed): Reasonable for an MLIR compiler.
    • Tuning support: Not documented.

    Maintainability

    • Should be highly maintainable, since we have much less code, and tileIR team is committed to support existing code onto new generations of hardware

    Performance

    Discussed in detail in #9210.

    Ecosystem

    • The support is complete. All those tools work with tile kernels.

    Compile time

    Results from cross compiling for sm_100 on my local workstation, --enable-tile vs CUB:

    bench tile cub tile/cub
    babelstream 7.20s 9.90s 0.73×
    pytorch 10.35s 14.80s 0.70×

    Tile is about 25 - 30% faster to compile.

    Binary size

    bench tile cub tile/cub
    babelstream 427K 762K 0.56×
    pytorch 993K 1560K 0.64×
    copy 232K 363K 0.64×
    grayscale 157K 255K 0.62×
    fill 158K 252K 0.63×

    Tile binaries are ~35-45% smaller.

    Note that those comparison is unfair to CUB since it is a much bigger library.

  5. fbusato commented on Jun 2, 2026

    @fbusato
    ContributorAuthor

    amazing analysis. I have many questions:

    Pointers must be 16-byte aligned, otherwise it regresses to unvectorized loads

    This seems not a blocker. I guess unvectorized loads have comparable performance with CUB in the same conditions.

    Limited support for numeric types, e.g. std::complex

    Could you be more specific? are all fundamental C++ types supported? from char to long long, float, int128, extended floating-point types, pointers, structure, complex, etc.

    Device side arrays are silently lowered to heap allocations

    what kind of array? C raw array, std::array? and where? e.g. passed by argument, local variable, etc.

    Numerical behavior: We have correctness tests in #9210, all of them pass.

    My main concern is about floating-point. I don't think we can get identical results with C++ implementation.

    Arch dependencies: cutile only supports sm80+.

    we also depend on the CTK version and C++ versions (>= c++20), right?

    LOC delta: Massively less code (-90%).

    wow

    Tile is about 25 - 30% faster to compile.

    this is surprising to me. I would expect the opposite as it adds more steps for the compiler, not less. I don't have a strong reason for that, maybe because it is just less code to compile.

    Tile binaries are ~35-45% smaller.
    Note that those comparison is unfair to CUB since it is a much bigger library.

    The compiler strips practically everything that is not used in C++. This is also amazing, considering that performance benefits!

  6. bernhardmgruber commented on Jun 2, 2026

    @bernhardmgruber
    Contributor

    This seems not a blocker. I guess unvectorized loads have comparable performance with CUB in the same conditions.

    Not for the ublkcp kernel of DeviceTransform, which should perform well for unaligned inputs ;) I would be very curious to also compare performance of a tile kernel with DeviceTransform where the input is off by 1 element and the size is reduced by 2 elements (so input is unaligned + oddly sized)

    LOC delta: Massively less code (-90%).

    I am surprised, since the ublkcp kernel has about 200 SASS instructions. I am curious how tile can do it in less. Unless the entire programming model is different. Doesn't the binary store some intermediate language as well (like PTX) and JIT compiles the tile kernel when loading?

    Tile is about 25 - 30% faster to compile.

    cub::DeviceTransform pulls in a TON of headers to cover a lot of edge cases. I am not surprised Tile is ahead. Also, Tile can handle a lot more logic in the compiler. Like, it doesn't need all the headers for libcuda-ptx, bulk copy, barriers, all the CUB launching and tuning infrastructure, arch utilities, etc. Thinking about it, I think Tile should actually be a lot faster than CUB. Does -fdevice-time-trace work for Tile kernels btw? Can we get a compilation trace?

    I really love the results so far, this is going into a good direction! I am curious

  7. moved this from In Progress to Done in CCCLon Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions