CUDA 13.4 samples update - v13.4-public

Release 13.4 of the CUDA Samples supported by CUDA Toolkit 13.4.
See Changelog for more information.
This commit is contained in:
Dheemanth
2026-09-09 15:07:08 -07:00
committed by GitHub
parent b7c5481c55
commit 5443602d89
871 changed files with 6843 additions and 321849 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
/* Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,86 +25,47 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef _WIN32
#define WINDOWS_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#else
#include <sys/utsname.h>
#endif
// Includes, system
// System includes
#include <cassert>
#include <stdio.h>
// Includes CUDA
// CUDA runtime
#include <cuda_runtime.h>
// Utilities and timing functions
#include <helper_functions.h> // includes cuda.h and cuda_runtime_api.h
// CUDA helper functions
#include <helper_cuda.h> // helper functions for CUDA error check
const char *sampleName = "simpleAssert";
////////////////////////////////////////////////////////////////////////////////
// Auto-Verification Code
bool testResult = true;
////////////////////////////////////////////////////////////////////////////////
// Kernels
////////////////////////////////////////////////////////////////////////////////
//! Tests assert function.
//! Thread whose id > N will print assertion failed error message.
////////////////////////////////////////////////////////////////////////////////
__global__ void testKernel(int N)
// Each thread computes its global index and asserts it is below N. Threads with
// gtid >= N trip the assertion, which aborts the kernel and surfaces on the host
// as cudaErrorAssert at the next synchronization point.
__global__ void simpleAssertKernel(int N)
{
int gtid = blockIdx.x * blockDim.x + threadIdx.x;
assert(gtid < N);
}
////////////////////////////////////////////////////////////////////////////////
// Declaration, forward
void runTest(int argc, char **argv);
////////////////////////////////////////////////////////////////////////////////
// Program main
////////////////////////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
printf("%s starting...\n", sampleName);
runTest(argc, argv);
printf("%s completed, returned %s\n", sampleName, testResult ? "OK" : "ERROR!");
exit(testResult ? EXIT_SUCCESS : EXIT_FAILURE);
}
void runTest(int argc, char **argv)
{
int Nblocks = 2;
int Nthreads = 32;
cudaError_t error;
#ifndef _WIN32
utsname OS_System_Type;
uname(&OS_System_Type);
printf("%s starting...\n\n", sampleName);
printf("OS_System_Type.release = %s\n", OS_System_Type.release);
// Select device 0 as the active GPU
int devID = 0;
cudaSetDevice(devID);
if (!strcasecmp(OS_System_Type.sysname, "Darwin")) {
printf("simpleAssert is not current supported on Mac OSX\n\n");
exit(EXIT_SUCCESS);
}
else {
printf("OS Info: <%s>\n\n", OS_System_Type.version);
}
// Query compute capability (major.minor) and number of SMs on the device
int major = 0, minor = 0, smCount = 0;
cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, devID);
cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, devID);
cudaDeviceGetAttribute(&smCount, cudaDevAttrMultiProcessorCount, devID);
#endif
// This will pick the best possible CUDA capable device
findCudaDevice(argc, (const char **)argv);
// Print device info
printf("GPU Device %d: with compute capability %d.%d and Number of SMs %d\n\n", devID, major, minor, smCount);
// Kernel configuration, where a one-dimensional
// grid and one-dimensional blocks are configured.
@@ -112,7 +73,7 @@ void runTest(int argc, char **argv)
dim3 dimBlock(Nthreads);
printf("Launch kernel to generate assertion failures\n");
testKernel<<<dimGrid, dimBlock>>>(60);
simpleAssertKernel<<<dimGrid, dimBlock>>>(60);
// Synchronize (flushes assert output).
printf("\n-- Begin assert output\n\n");
@@ -127,4 +88,7 @@ void runTest(int argc, char **argv)
}
testResult = error == cudaErrorAssert;
printf("%s completed, returned %s\n", sampleName, testResult ? "OK" : "ERROR!");
exit(testResult ? EXIT_SUCCESS : EXIT_FAILURE);
}