Release v13.3 of the CUDA samples with CUDA 13.3 Toolkit (#435)

This is the release of the CUDA 13.3 samples, which include additions for CUDA Tile C++, and updated CCCL and Python samples.
This commit is contained in:
Dheemanth
2026-05-27 14:50:59 -07:00
committed by GitHub
parent aeab82ff30
commit b7c5481c55
150 changed files with 7977 additions and 246 deletions

View File

@@ -0,0 +1,62 @@
cmake_minimum_required(VERSION 3.20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
project(cubDeviceTransform LANGUAGES C CXX CUDA)
# Disable response file for libraries on QNX as qcc does not support lib paths with double quotes
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)
endif()
find_package(CUDAToolkit REQUIRED)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CUDA_ARCHITECTURES 75 80 86 87 89 90 100 110 120)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
if(ENABLE_CUDA_DEBUG)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (may significantly affect performance on some targets)
else()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -lineinfo") # add line information to all builds for debug tools (exclusive to -G option)
endif()
# Fetch CCCL via CPM.
# Override with -DCCCL_SOURCE_DIR=/path/to/cccl to use a local checkout
set(CCCL_SAMPLES_CCCL_TAG "v3.3.3" CACHE STRING
"Tag/branch of NVIDIA/cccl to fetch for the CCCL samples")
if(NOT TARGET CCCL::CCCL)
include("${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/CPM.cmake")
if(DEFINED CCCL_SOURCE_DIR AND NOT CCCL_SOURCE_DIR STREQUAL "")
CPMAddPackage(NAME CCCL SOURCE_DIR "${CCCL_SOURCE_DIR}")
else()
CPMAddPackage(
NAME CCCL
GIT_REPOSITORY "https://github.com/NVIDIA/cccl"
GIT_TAG "${CCCL_SAMPLES_CCCL_TAG}"
)
endif()
endif()
# Include directories and libraries
include_directories(../../../Common)
# Source file
# Add target for cubDeviceTransform
add_executable(cubDeviceTransform cubDeviceTransform.cu)
target_compile_options(cubDeviceTransform PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
target_compile_features(cubDeviceTransform PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(cubDeviceTransform PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_link_libraries(cubDeviceTransform PRIVATE
CUDA::cudart
CCCL::CCCL
)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -0,0 +1,48 @@
# cubDeviceTransform - CUB DeviceTransform N-to-M
## Description
This sample demonstrates `cub::DeviceTransform` in its N-input / M-output form. A single device-wide call reads from N input sequences and writes to M output sequences, driven by a user-provided op that returns a `cuda::std::tuple` of M values. Two cases are shown: N=3 inputs producing 1 output, and N=2 inputs producing 2 outputs (sum and difference in one fused pass).
## Key Concepts
CCCL 3.3, CUB Device Algorithms, Fused Elementwise Transforms, Counting Iterators
## Supported SM Architectures
[SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.5 ](https://developer.nvidia.com/cuda-gpus) [SM 8.0 ](https://developer.nvidia.com/cuda-gpus) [SM 8.6 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus) [SM 10.0 ](https://developer.nvidia.com/cuda-gpus) [SM 11.0 ](https://developer.nvidia.com/cuda-gpus) [SM 12.0 ](https://developer.nvidia.com/cuda-gpus)
## Supported OSes
Linux, Windows
## Supported CPU Architecture
x86_64, aarch64
## CUDA APIs involved
### [CCCL CUB](https://nvidia.github.io/cccl/cub/)
cub::DeviceTransform::Transform
### [CCCL libcu++](https://nvidia.github.io/cccl/libcudacxx/)
cuda::counting_iterator, cuda::std::tuple
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
cudaDeviceSynchronize, cudaGetDeviceProperties
## Dependencies needed to build/run
[CCCL 3.3+](https://github.com/NVIDIA/cccl). Fetched automatically via CPM at configure time (pinned to `v3.3.3`). Override with `-DCCCL_SOURCE_DIR=/path/to/cccl` to use a local checkout.
## Prerequisites
Download and install the [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
Make sure the dependencies mentioned in [Dependencies]() section above are installed.
## References (for more details)
[CCCL 3.3 release notes](https://github.com/NVIDIA/cccl/releases), [cub::DeviceTransform header](https://github.com/NVIDIA/cccl/blob/main/cub/cub/device/device_transform.cuh)

View File

@@ -0,0 +1,155 @@
/* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* This sample demonstrates cub::DeviceTransform in its N-input/M-output
* form (extended in CCCL 3.3). A single device-wide call reads from
* N input sequences and writes to M output sequences, driven by a
* user-provided op that returns a tuple of M values. Two cases are
* shown: N=3 -> 1 and N=2 -> 2. Results are verified against a host
* reference.
*/
/* Includes, system */
#include <stdio.h>
#include <stdlib.h>
#include <vector>
/* Includes, cuda */
#include <cuda_runtime.h>
#include <helper_cuda.h>
/* Includes, cccl */
#include <cub/device/device_transform.cuh>
#include <cuda/iterator>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
static bool run_n_to_one_transform()
{
/* result[i] = (a[i] + b[i]) * c[i], with c = counting_iterator<int>(100). */
thrust::device_vector<int> a = {0, -2, 5, 3};
thrust::device_vector<float> b = {5.2f, 3.1f, -1.1f, 3.0f};
auto counting = cuda::counting_iterator<int>{100};
thrust::device_vector<int> result(a.size());
auto op = [] __host__ __device__(int x, float y, int z) -> int {
return static_cast<int>((x + y) * z);
};
checkCudaErrors(cub::DeviceTransform::Transform(
cuda::std::tuple{a.begin(), b.begin(), counting}, result.begin(), a.size(), op));
checkCudaErrors(cudaDeviceSynchronize());
thrust::host_vector<int> ha = a;
thrust::host_vector<float> hb = b;
thrust::host_vector<int> got = result;
std::vector<int> expected(a.size());
for (size_t i = 0; i < a.size(); ++i) {
expected[i] = static_cast<int>((ha[i] + hb[i]) * static_cast<int>(100 + i));
}
bool ok = true;
printf("cub::DeviceTransform::Transform (N=3 inputs -> 1 output)\n");
printf(" result = (a + b) * c with c = counting_iterator(100)\n");
printf(" got = {");
for (size_t i = 0; i < got.size(); ++i) {
printf(" %d", got[i]);
if (got[i] != expected[i])
ok = false;
}
printf(" }\n expected = {");
for (size_t i = 0; i < expected.size(); ++i)
printf(" %d", expected[i]);
printf(" } %s\n", ok ? "OK" : "FAIL");
return ok;
}
static bool run_n_to_m_transform()
{
/* (sum[i], diff[i]) = (a[i] + b[i], a[i] - b[i]) in one pass. */
thrust::device_vector<int> a = {1, 5, 10, 7, 3};
thrust::device_vector<int> b = {4, 2, 8, 1, 9};
thrust::device_vector<int> sum(a.size());
thrust::device_vector<int> diff(a.size());
auto op = [] __host__ __device__(int x, int y) -> cuda::std::tuple<int, int> {
return {x + y, x - y};
};
checkCudaErrors(cub::DeviceTransform::Transform(cuda::std::tuple{a.begin(), b.begin()},
cuda::std::tuple{sum.begin(), diff.begin()},
a.size(),
op));
checkCudaErrors(cudaDeviceSynchronize());
thrust::host_vector<int> ha = a, hb = b, got_sum = sum, got_diff = diff;
std::vector<int> exp_sum(a.size()), exp_diff(a.size());
for (size_t i = 0; i < a.size(); ++i) {
exp_sum[i] = ha[i] + hb[i];
exp_diff[i] = ha[i] - hb[i];
}
bool ok = true;
printf("cub::DeviceTransform::Transform (N=2 inputs -> M=2 outputs)\n");
printf(" op returns cuda::std::tuple{a + b, a - b}\n");
printf(" sum = {");
for (size_t i = 0; i < got_sum.size(); ++i) {
printf(" %d", got_sum[i]);
if (got_sum[i] != exp_sum[i])
ok = false;
}
printf(" } expected = {");
for (auto v : exp_sum)
printf(" %d", v);
printf(" }\n diff = {");
for (size_t i = 0; i < got_diff.size(); ++i) {
printf(" %d", got_diff[i]);
if (got_diff[i] != exp_diff[i])
ok = false;
}
printf(" } expected = {");
for (auto v : exp_diff)
printf(" %d", v);
printf(" } %s\n", ok ? "OK" : "FAIL");
return ok;
}
int main(int argc, char **argv)
{
int devID = findCudaDevice(argc, (const char **)argv);
cudaDeviceProp props;
checkCudaErrors(cudaGetDeviceProperties(&props, devID));
printf("Device: %s (Compute Capability %d.%d)\n\n", props.name, props.major, props.minor);
bool ok = true;
ok &= run_n_to_one_transform();
printf("\n");
ok &= run_n_to_m_transform();
printf("\n%s\n", ok ? "Done" : "FAILED");
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}