mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-11-18 01:48:16 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a78fba92df | ||
|
|
876266c941 | ||
|
|
97bb3938a6 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
build
|
|
||||||
.vs
|
|
||||||
.clangd
|
|
||||||
187
CHANGELOG.md
187
CHANGELOG.md
@@ -1,187 +0,0 @@
|
|||||||
## Changelog
|
|
||||||
|
|
||||||
### CUDA 12.8
|
|
||||||
* Updated build system across the repository to CMake. Removed Visual Studio project files and Makefiles.
|
|
||||||
* Removed the following outdated samples:
|
|
||||||
* `0_Introduction`
|
|
||||||
* `c++11_cuda` demonstrating CUDA and C++ 11 interoperability (reason: obsolete)
|
|
||||||
* `concurrentKernels` demonstrating the ability to run multiple kernels simultaneously (reason: obsolete)
|
|
||||||
* `cppIntegration` demonstrating calling between .cu and .cpp files (reason: obsolete)
|
|
||||||
* `cppOverload` demonstrating C++ function overloading (reason: obsolete)
|
|
||||||
* `simpleSeparateCompilation` demonstrating NVCC compilation to a static library (reason: trivial)
|
|
||||||
* `simpleTemplates_nvrtc` demonstrating NVRTC usage for `simpleTemplates` sample (reason: redundant)
|
|
||||||
* `simpleVoteIntrinsics_nvrtc` demonstrating NVRTC usage for `simpleVoteIntrinsics` sample (reason: redundant)
|
|
||||||
* `2_Concepts_and_Techniques`
|
|
||||||
* `cuHook` demonstrating dlsym hooks. (reason: incompatible with modern `glibc`)
|
|
||||||
* `4_CUDA_Libraries`
|
|
||||||
* `batchedLabelMarkersAndLabelCompressionNPP` demonstrating NPP features (reason: some functionality removed from library)
|
|
||||||
* `5_Domain_Specific`
|
|
||||||
* Legacy Direct3D 9 and 10 interoperability samples:
|
|
||||||
* `fluidsD3D9`
|
|
||||||
* `simpleD3D10`
|
|
||||||
* `simpleD3D10RenderTarget`
|
|
||||||
* `simpleD3D10Texture`
|
|
||||||
* `simpleD3D9`
|
|
||||||
* `simpleD3D9Texture`
|
|
||||||
* `SLID3D10Texture`
|
|
||||||
* `VFlockingD3D10`
|
|
||||||
* `8_Platform_Specific/Tegra`
|
|
||||||
* Temporarily removed the following two samples pending updates:
|
|
||||||
* `nbody_screen` demonstrating the nbody sample in QNX
|
|
||||||
* `simpleGLES_screen` demonstrating GLES interop in QNX
|
|
||||||
* Moved the following Tegra-specific samples to a dedicated subdirectory: `8_Platform_Specific/Tegra`
|
|
||||||
* `EGLSync_CUDAEvent_Interop`
|
|
||||||
* `cuDLAErrorReporting`
|
|
||||||
* `cuDLAHybridMode`
|
|
||||||
* `cuDLALayerwiseStatsHybrid`
|
|
||||||
* `cuDLALayerwiseStatsStandalone`
|
|
||||||
* `cuDLAStandaloneMode`
|
|
||||||
* `cudaNvSciNvMedia`
|
|
||||||
* `fluidsGLES`
|
|
||||||
* `nbody_opengles`
|
|
||||||
* `simpleGLES`
|
|
||||||
* `simpleGLES_EGLOutput`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### CUDA 12.5
|
|
||||||
|
|
||||||
### CUDA 12.4
|
|
||||||
* Added graphConditionalNodes Sample
|
|
||||||
|
|
||||||
### CUDA 12.3
|
|
||||||
* Added cuDLA samples
|
|
||||||
* Fixed jitLto regression
|
|
||||||
|
|
||||||
### CUDA 12.2
|
|
||||||
* libNVVM samples received updates
|
|
||||||
* Fixed jitLto Case issues
|
|
||||||
* Enabled HOST_COMPILER flag to the makefiles for GCC which is untested but may still work.
|
|
||||||
|
|
||||||
### CUDA 12.1
|
|
||||||
* Added new sample for Large Kernels
|
|
||||||
|
|
||||||
### CUDA 12.0
|
|
||||||
* Added new flags for JIT compiling
|
|
||||||
* Removed deprecated APIs in Hopper Architecture
|
|
||||||
|
|
||||||
### CUDA 11.6
|
|
||||||
* Added new folder structure for samples
|
|
||||||
* Added support of Visual Studio 2022 to all samples supported on [Windows](#windows-1).
|
|
||||||
* All CUDA samples are now only available on [GitHub](https://github.com/nvidia/cuda-samples). They are no longer available via CUDA toolkit.
|
|
||||||
|
|
||||||
### CUDA 11.5
|
|
||||||
* Added `cuDLAHybridMode`. Demonstrate usage of cuDLA in hybrid mode.
|
|
||||||
* Added `cuDLAStandaloneMode`. Demonstrate usage of cuDLA in standalone mode.
|
|
||||||
* Added `cuDLAErrorReporting`. Demonstrate DLA error detection via CUDA.
|
|
||||||
* Added `graphMemoryNodes`. Demonstrates memory allocations and frees within CUDA graphs using Graph APIs and Stream Capture APIs.
|
|
||||||
* Added `graphMemoryFootprint`. Demonstrates how graph memory nodes re-use virtual addresses and physical memory.
|
|
||||||
* All samples from CUDA toolkit are now available on [GitHub](https://github.com/nvidia/cuda-samples).
|
|
||||||
|
|
||||||
### CUDA 11.4 update 1
|
|
||||||
* Added support for VS Code on linux platform.
|
|
||||||
|
|
||||||
### CUDA 11.4
|
|
||||||
* Added `cdpQuadtree`. Demonstrates Quad Trees implementation using CUDA Dynamic Parallelism.
|
|
||||||
* Updated `simpleVulkan`, `simpleVulkanMMAP` and `vulkanImageCUDA`. Demonstrates use of SPIR-V shaders.
|
|
||||||
|
|
||||||
### CUDA 11.3
|
|
||||||
* Added `streamOrderedAllocationIPC`. Demonstrates Inter Process Communication using one process per GPU for computation.
|
|
||||||
* Added `simpleCUBLAS_LU`. Demonstrates batched matrix LU decomposition using cuBLAS API `cublas<t>getrfBatched()`
|
|
||||||
* Updated `simpleVulkan`. Demonstrates use of timeline semaphore.
|
|
||||||
* Updated multiple samples to use pinned memory using `cudaMallocHost()`.
|
|
||||||
|
|
||||||
### CUDA 11.2
|
|
||||||
* Added `streamOrderedAllocation`. Demonstrates stream ordered memory allocation on a GPU using cudaMallocAsync and cudaMemPool family of APIs.
|
|
||||||
* Added `streamOrderedAllocationP2P`. Demonstrates peer-to-peer access of stream ordered memory allocated using cudaMallocAsync and cudaMemPool family of APIs.
|
|
||||||
* Dropped Visual Studio 2015 support from all the windows supported samples.
|
|
||||||
* FreeImage is no longer distributed with the CUDA Samples. On Windows, see the [Dependencies](./README.md#freeimage) section for more details on how to set up FreeImage. On Linux, it is recommended to install FreeImage with your distribution's package manager.
|
|
||||||
* All the samples using CUDA Pipeline & Arrive-wait barriers are been updated to use new `cuda::pipeline` and `cuda::barrier` interfaces.
|
|
||||||
* Updated all the samples to build with parallel build option `--threads` of `nvcc` cuda compiler.
|
|
||||||
* Added `cudaNvSciNvMedia`. Demonstrates CUDA-NvMedia interop via NvSciBuf/NvSciSync APIs.
|
|
||||||
* Added `simpleGL`. Demonstrates interoperability between CUDA and OpenGL.
|
|
||||||
|
|
||||||
### CUDA 11.1
|
|
||||||
* Added `watershedSegmentationNPP`. Demonstrates how to use the NPP watershed segmentation function.
|
|
||||||
* Added `batchedLabelMarkersAndLabelCompressionNPP`. Demonstrates how to use the NPP label markers generation and label compression functions based on a Union Find (UF) algorithm including both single image and batched image versions.
|
|
||||||
* Dropped Visual Studio 2012, 2013 support from all the windows supported samples.
|
|
||||||
* Added kernel performing warp aggregated atomic max in multi buckets using cg::labeled_partition & cg::reduce in `warpAggregatedAtomicsCG`.
|
|
||||||
* Added extended CG shuffle mechanics to `shfl_scan` sample.
|
|
||||||
* Added `cudaOpenMP`. Demonstrates how to use OpenMP API to write an application for multiple GPUs.
|
|
||||||
* Added `simpleZeroCopy`. Demonstrates how to use zero copy, kernels can read and write directly to pinned system memory.
|
|
||||||
|
|
||||||
### CUDA 11.0
|
|
||||||
* Added `dmmaTensorCoreGemm`. Demonstrates double precision GEMM computation using the Double precision Warp Matrix Multiply and Accumulate (WMMA) API introduced with CUDA 11 in Ampere chip family tensor cores.
|
|
||||||
* Added `bf16TensorCoreGemm`. Demonstrates __nv_bfloat16 (e8m7) GEMM computation using the __nv_bfloat16 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.
|
|
||||||
* Added `tf32TensorCoreGemm`. Demonstrates tf32 (e8m10) GEMM computation using the tf32 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.
|
|
||||||
* Added `globalToShmemAsyncCopy`. Demonstrates async copy of data from global to shared memory when on compute capability 8.0 or higher. Also demonstrates arrive-wait barrier for synchronization.
|
|
||||||
* Added `simpleAWBarrier`. Demonstrates arrive wait barriers.
|
|
||||||
* Added `simpleAttributes`. Demonstrates the stream attributes that affect L2 locality.
|
|
||||||
* Added warp aggregated atomic multi bucket increments kernel using labeled_partition cooperative groups in `warpAggregatedAtomicsCG` which can be used on compute capability 7.0 and above GPU architectures.
|
|
||||||
* Added `binaryPartitionCG`. Demonstrates binary partition cooperative groups and reduction within the thread block.
|
|
||||||
* Added two new reduction kernels in `reduction` one which demonstrates reduce_add_sync intrinstic supported on compute capability 8.0 and another which uses cooperative_groups::reduce function which does thread_block_tile level reduction introduced from CUDA 11.0.
|
|
||||||
* Added `cudaCompressibleMemory`. Demonstrates compressible memory allocation using cuMemMap API.
|
|
||||||
* Added `simpleVulkanMMAP`. Demonstrates Vulkan CUDA Interop via cuMemMap APIs.
|
|
||||||
* Added `concurrentKernels`. Demonstrates the use of CUDA streams for concurrent execution of several kernels on a GPU.
|
|
||||||
* Dropped Mac OSX support from all samples.
|
|
||||||
|
|
||||||
### CUDA 10.2
|
|
||||||
* Added `simpleD3D11`. Demonstrates CUDA-D3D11 External Resource Interoperability APIs for updating D3D11 buffers from CUDA and synchronization between D3D11 and CUDA with Keyed Mutexes.
|
|
||||||
* Added `simpleDrvRuntime`. Demonstrates CUDA Driver and Runtime APIs working together to load fatbinary of a CUDA kernel.
|
|
||||||
* Added `vectorAddMMAP`. Demonstrates how cuMemMap API allows the user to specify the physical properties of their memory while retaining the contiguous nature of their access.
|
|
||||||
* Added `memMapIPCDrv`. Demonstrates Inter Process Communication using cuMemMap APIs.
|
|
||||||
* Added `cudaNvSci`. Demonstrates CUDA-NvSciBuf/NvSciSync Interop.
|
|
||||||
* Added `jacobiCudaGraphs`. Demonstrates Instantiated CUDA Graph Update with Jacobi Iterative Method using different approaches.
|
|
||||||
* Added `cuSolverSp_LinearSolver`. Demonstrates cuSolverSP's LU, QR and Cholesky factorization.
|
|
||||||
* Added `MersenneTwisterGP11213`. Demonstrates the Mersenne Twister random number generator GP11213 in cuRAND.
|
|
||||||
|
|
||||||
### CUDA 10.1 Update 2
|
|
||||||
* Added `vulkanImageCUDA`. Demonstrates how to perform Vulkan image - CUDA Interop.
|
|
||||||
* Added `nvJPEG_encoder`. Demonstrates encoding of jpeg images using NVJPEG Library.
|
|
||||||
* Added Windows OS support to `nvJPEG` sample.
|
|
||||||
* Added `boxFilterNPP`. Demonstrates how to use NPP FilterBox function to perform a box filter.
|
|
||||||
* Added `cannyEdgeDetectorNPP`. Demonstrates the nppiFilterCannyBorder_8u_C1R Canny Edge Detection image filter function.
|
|
||||||
|
|
||||||
### CUDA 10.1 Update 1
|
|
||||||
* Added `NV12toBGRandResize`. Demonstrates how to convert and resize NV12 frames to BGR planars frames using CUDA in batch.
|
|
||||||
* Added `EGLStream_CUDA_Interop`. Demonstrates data exchange between CUDA and EGL Streams.
|
|
||||||
* Added `cuSolverDn_LinearSolver`. Demonstrates cuSolverDN's LU, QR and Cholesky factorization.
|
|
||||||
* Added support of Visual Studio 2019 to all samples supported on [Windows](./README.md#windows-1).
|
|
||||||
|
|
||||||
### CUDA 10.1
|
|
||||||
* Added `immaTensorCoreGemm`. Demonstrates integer GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API for integers employing the Tensor Cores.
|
|
||||||
* Added `simpleIPC`. Demonstrates Inter Process Communication with one process per GPU for computation.
|
|
||||||
* Added `nvJPEG`. Demonstrates single and batched decoding of jpeg images using NVJPEG Library.
|
|
||||||
* Added `bandwidthTest`. It measures the memcopy bandwidth of the GPU and memcpy bandwidth across PCI-e.
|
|
||||||
* Added `reduction`. Demonstrates several important optimization strategies for Data-Parallel Algorithms like reduction.
|
|
||||||
* Update all the samples to support CUDA 10.1.
|
|
||||||
|
|
||||||
|
|
||||||
### CUDA 10.0
|
|
||||||
* Added `simpleCudaGraphs`. Demonstrates CUDA Graphs creation, instantiation and launch using Graphs APIs and Stream Capture APIs.
|
|
||||||
* Added `conjugateGradientCudaGraphs`. Demonstrates conjugate gradient solver on GPU using CUBLAS and CUSPARSE library calls captured and called using CUDA Graph APIs.
|
|
||||||
* Added `simpleVulkan`. Demonstrates Vulkan - CUDA Interop.
|
|
||||||
* Added `simpleD3D12`. Demonstrates DX12 - CUDA Interop.
|
|
||||||
* Added `UnifiedMemoryPerf`. Demonstrates performance comparision of various memory types involved in system.
|
|
||||||
* Added `p2pBandwidthLatencyTest`. Demonstrates Peer-To-Peer (P2P) data transfers between pairs of GPUs and computes latency and bandwidth.
|
|
||||||
* Added `systemWideAtomics`. Demonstrates system wide atomic instructions.
|
|
||||||
* Added `simpleCUBLASXT`. Demonstrates CUBLAS-XT library which performs GEMM operations over multiple GPUs.
|
|
||||||
* Added Windows OS support to `conjugateGradientMultiDeviceCG` sample.
|
|
||||||
* Removed support of Visual Studio 2010 from all samples.
|
|
||||||
|
|
||||||
|
|
||||||
### CUDA 9.2
|
|
||||||
|
|
||||||
This is the first release of CUDA Samples on GitHub:
|
|
||||||
* Added `vectorAdd_nvrtc`. Demonstrates runtime compilation library using NVRTC of a simple vectorAdd kernel.
|
|
||||||
* Added `warpAggregatedAtomicsCG`. Demonstrates warp aggregated atomics using Cooperative Groups.
|
|
||||||
* Added `deviceQuery`. Enumerates the properties of the CUDA devices present in the system.
|
|
||||||
* Added `matrixMul`. Demonstrates a matrix multiplication using shared memory through tiled approach.
|
|
||||||
* Added `matrixMulDrv`. Demonstrates a matrix multiplication using shared memory through tiled approach, uses CUDA Driver API.
|
|
||||||
* Added `cudaTensorCoreGemm`. Demonstrates a GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API introduced in CUDA 9, as well as the new Tensor Cores introduced in the Volta chip family.
|
|
||||||
* Added `simpleVoteIntrinsics` which uses *_sync equivalent of the vote intrinsics _any, _all added since CUDA 9.0.
|
|
||||||
* Added `shfl_scan` which uses *_sync equivalent of the shfl intrinsics added since CUDA 9.0.
|
|
||||||
* Added `conjugateGradientMultiBlockCG`. Demonstrates a conjugate gradient solver on GPU using Multi Block Cooperative Groups.
|
|
||||||
* Added `conjugateGradientMultiDeviceCG`. Demonstrates a conjugate gradient solver on multiple GPUs using Multi Device Cooperative Groups, also uses unified memory prefetching and usage hints APIs.
|
|
||||||
* Added `simpleCUBLAS`. Demonstrates how perform GEMM operations using CUBLAS library.
|
|
||||||
* Added `simpleCUFFT`. Demonstrates how perform FFT operations using CUFFT library.
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(cuda-samples LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_STANDARD 17)
|
|
||||||
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda")
|
|
||||||
|
|
||||||
add_subdirectory(Samples)
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
1
Common/data/Lena_512x512_8u_Gray.raw
Normal file
1
Common/data/Lena_512x512_8u_Gray.raw
Normal file
File diff suppressed because one or more lines are too long
BIN
Common/data/lena_512x512_8u.raw
Normal file
BIN
Common/data/lena_512x512_8u.raw
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
294
Common/dynlink_d3d10.h
Normal file
294
Common/dynlink_d3d10.h
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
/* Copyright (c) 2021, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: dynlink_d3d10.h
|
||||||
|
//
|
||||||
|
// Shortcut macros and functions for using DX objects
|
||||||
|
//
|
||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef _DYNLINK_D3D10_H_
|
||||||
|
#define _DYNLINK_D3D10_H_
|
||||||
|
|
||||||
|
// Standard Windows includes
|
||||||
|
#include <windows.h>
|
||||||
|
#include <initguid.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <mmsystem.h>
|
||||||
|
#include <commctrl.h> // for InitCommonControls()
|
||||||
|
#include <shellapi.h> // for ExtractIcon()
|
||||||
|
#include <new.h> // for placement new
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// CRT's memory leak detection
|
||||||
|
#if defined(DEBUG) || defined(_DEBUG)
|
||||||
|
#include <crtdbg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Direct3D9 includes
|
||||||
|
#include <d3d9.h>
|
||||||
|
|
||||||
|
// Direct3D10 includes
|
||||||
|
#include <dxgi.h>
|
||||||
|
#include <d3d10_1.h>
|
||||||
|
#include <d3d10.h>
|
||||||
|
|
||||||
|
// XInput includes
|
||||||
|
#include <xinput.h>
|
||||||
|
|
||||||
|
// strsafe.h deprecates old unsecure string functions. If you
|
||||||
|
// really do not want to it to (not recommended), then uncomment the next line
|
||||||
|
//#define STRSAFE_NO_DEPRECATE
|
||||||
|
|
||||||
|
#ifndef STRSAFE_NO_DEPRECATE
|
||||||
|
#pragma deprecated("strncpy")
|
||||||
|
#pragma deprecated("wcsncpy")
|
||||||
|
#pragma deprecated("_tcsncpy")
|
||||||
|
#pragma deprecated("wcsncat")
|
||||||
|
#pragma deprecated("strncat")
|
||||||
|
#pragma deprecated("_tcsncat")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning( disable : 4996 ) // disable deprecated warning
|
||||||
|
#include <strsafe.h>
|
||||||
|
#pragma warning( default : 4996 )
|
||||||
|
|
||||||
|
#include <DirectXMath.h>
|
||||||
|
|
||||||
|
using namespace DirectX;
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Structs
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
struct DXUTD3D9DeviceSettings
|
||||||
|
{
|
||||||
|
UINT AdapterOrdinal;
|
||||||
|
D3DDEVTYPE DeviceType;
|
||||||
|
D3DFORMAT AdapterFormat;
|
||||||
|
DWORD BehaviorFlags;
|
||||||
|
D3DPRESENT_PARAMETERS pp;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DXUTD3D10DeviceSettings
|
||||||
|
{
|
||||||
|
UINT AdapterOrdinal;
|
||||||
|
D3D10_DRIVER_TYPE DriverType;
|
||||||
|
UINT Output;
|
||||||
|
DXGI_SWAP_CHAIN_DESC sd;
|
||||||
|
UINT32 CreateFlags;
|
||||||
|
UINT32 SyncInterval;
|
||||||
|
DWORD PresentFlags;
|
||||||
|
bool AutoCreateDepthStencil; // DXUT will create the a depth stencil resource and view if true
|
||||||
|
DXGI_FORMAT AutoDepthStencilFormat;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DXUTDeviceVersion { DXUT_D3D9_DEVICE, DXUT_D3D10_DEVICE };
|
||||||
|
struct DXUTDeviceSettings
|
||||||
|
{
|
||||||
|
DXUTDeviceVersion ver;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
DXUTD3D9DeviceSettings d3d9; // only valid if ver == DXUT_D3D9_DEVICE
|
||||||
|
DXUTD3D10DeviceSettings d3d10; // only valid if ver == DXUT_D3D10_DEVICE
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Error codes
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
#define DXUTERR_NODIRECT3D MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0901)
|
||||||
|
#define DXUTERR_NOCOMPATIBLEDEVICES MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0902)
|
||||||
|
#define DXUTERR_MEDIANOTFOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0903)
|
||||||
|
#define DXUTERR_NONZEROREFCOUNT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0904)
|
||||||
|
#define DXUTERR_CREATINGDEVICE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0905)
|
||||||
|
#define DXUTERR_RESETTINGDEVICE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0906)
|
||||||
|
#define DXUTERR_CREATINGDEVICEOBJECTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0907)
|
||||||
|
#define DXUTERR_RESETTINGDEVICEOBJECTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0908)
|
||||||
|
#define DXUTERR_DEVICEREMOVED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x090A)
|
||||||
|
|
||||||
|
|
||||||
|
typedef HRESULT(WINAPI *LPCREATEDXGIFACTORY)(REFIID, void **);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10CREATEDEVICE)(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT32,
|
||||||
|
ID3D10Device **);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10CREATEDEVICE1)(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT,
|
||||||
|
D3D10_FEATURE_LEVEL1, UINT, ID3D10Device1 **);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10CREATESTATEBLOCK)(ID3D10Device *pDevice, D3D10_STATE_BLOCK_MASK *pStateBlockMask,
|
||||||
|
ID3D10StateBlock **ppStateBlock);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKUNION)(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB,
|
||||||
|
D3D10_STATE_BLOCK_MASK *pResult);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKINTERSECT)(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB,
|
||||||
|
D3D10_STATE_BLOCK_MASK *pResult);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKDIFFERENCE)(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB,
|
||||||
|
D3D10_STATE_BLOCK_MASK *pResult);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKENABLECAPTURE)(D3D10_STATE_BLOCK_MASK *pMask,
|
||||||
|
D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart,
|
||||||
|
UINT RangeLength);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKDISABLECAPTURE)(D3D10_STATE_BLOCK_MASK *pMask,
|
||||||
|
D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart,
|
||||||
|
UINT RangeLength);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKENABLEALL)(D3D10_STATE_BLOCK_MASK *pMask);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKDISABLEALL)(D3D10_STATE_BLOCK_MASK *pMask);
|
||||||
|
typedef BOOL (WINAPI *LPD3D10STATEBLOCKMASKGETSETTING)(D3D10_STATE_BLOCK_MASK *pMask,
|
||||||
|
D3D10_DEVICE_STATE_TYPES StateType, UINT Entry);
|
||||||
|
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10COMPILEEFFECTFROMMEMORY)(void *pData, SIZE_T DataLength, LPCSTR pSrcFileName,
|
||||||
|
CONST D3D10_SHADER_MACRO *pDefines,
|
||||||
|
ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags,
|
||||||
|
ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10CREATEEFFECTFROMMEMORY)(void *pData, SIZE_T DataLength, UINT FXFlags,
|
||||||
|
ID3D10Device *pDevice,
|
||||||
|
ID3D10EffectPool *pEffectPool,
|
||||||
|
ID3D10Effect **ppEffect);
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10CREATEEFFECTPOOLFROMMEMORY)(void *pData, SIZE_T DataLength, UINT FXFlags,
|
||||||
|
ID3D10Device *pDevice, ID3D10EffectPool **ppEffectPool);
|
||||||
|
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10CREATEDEVICEANDSWAPCHAIN)(IDXGIAdapter *pAdapter,
|
||||||
|
D3D10_DRIVER_TYPE DriverType,
|
||||||
|
HMODULE Software,
|
||||||
|
UINT Flags,
|
||||||
|
UINT SDKVersion,
|
||||||
|
DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
|
||||||
|
IDXGISwapChain **ppSwapChain,
|
||||||
|
ID3D10Device **ppDevice);
|
||||||
|
|
||||||
|
typedef HRESULT(WINAPI *LPD3D10CREATEDEVICEANDSWAPCHAIN1)(IDXGIAdapter *pAdapter,
|
||||||
|
D3D10_DRIVER_TYPE DriverType,
|
||||||
|
HMODULE Software,
|
||||||
|
UINT Flags,
|
||||||
|
D3D10_FEATURE_LEVEL1 HardwareLevel,
|
||||||
|
UINT SDKVersion,
|
||||||
|
DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
|
||||||
|
IDXGISwapChain **ppSwapChain,
|
||||||
|
ID3D10Device1 **ppDevice);
|
||||||
|
|
||||||
|
// Module and function pointers
|
||||||
|
static HMODULE g_hModDXGI = NULL;
|
||||||
|
static HMODULE g_hModD3D10 = NULL;
|
||||||
|
static HMODULE g_hModD3D101 = NULL;
|
||||||
|
static LPCREATEDXGIFACTORY sFnPtr_CreateDXGIFactory = NULL;
|
||||||
|
static LPD3D10CREATESTATEBLOCK sFnPtr_D3D10CreateStateBlock = NULL;
|
||||||
|
static LPD3D10CREATEDEVICE sFnPtr_D3D10CreateDevice = NULL;
|
||||||
|
static LPD3D10CREATEDEVICE1 sFnPtr_D3D10CreateDevice1 = NULL;
|
||||||
|
static LPD3D10STATEBLOCKMASKUNION sFnPtr_D3D10StateBlockMaskUnion = NULL;
|
||||||
|
static LPD3D10STATEBLOCKMASKINTERSECT sFnPtr_D3D10StateBlockMaskIntersect = NULL;
|
||||||
|
static LPD3D10STATEBLOCKMASKDIFFERENCE sFnPtr_D3D10StateBlockMaskDifference = NULL;
|
||||||
|
static LPD3D10STATEBLOCKMASKENABLECAPTURE sFnPtr_D3D10StateBlockMaskEnableCapture = NULL;
|
||||||
|
static LPD3D10STATEBLOCKMASKDISABLECAPTURE sFnPtr_D3D10StateBlockMaskDisableCapture = NULL;
|
||||||
|
static LPD3D10STATEBLOCKMASKENABLEALL sFnPtr_D3D10StateBlockMaskEnableAll = NULL;
|
||||||
|
static LPD3D10STATEBLOCKMASKDISABLEALL sFnPtr_D3D10StateBlockMaskDisableAll = NULL;
|
||||||
|
static LPD3D10STATEBLOCKMASKGETSETTING sFnPtr_D3D10StateBlockMaskGetSetting = NULL;
|
||||||
|
static LPD3D10COMPILEEFFECTFROMMEMORY sFnPtr_D3D10CompileEffectFromMemory = NULL;
|
||||||
|
static LPD3D10CREATEEFFECTFROMMEMORY sFnPtr_D3D10CreateEffectFromMemory = NULL;
|
||||||
|
static LPD3D10CREATEEFFECTPOOLFROMMEMORY sFnPtr_D3D10CreateEffectPoolFromMemory = NULL;
|
||||||
|
static LPD3D10CREATEDEVICEANDSWAPCHAIN sFnPtr_D3D10CreateDeviceAndSwapChain = NULL;
|
||||||
|
static LPD3D10CREATEDEVICEANDSWAPCHAIN1 sFnPtr_D3D10CreateDeviceAndSwapChain1 = NULL;
|
||||||
|
|
||||||
|
// unload the D3D10 DLLs
|
||||||
|
static bool dynlinkUnloadD3D10API(void)
|
||||||
|
{
|
||||||
|
if (g_hModD3D10)
|
||||||
|
{
|
||||||
|
FreeLibrary(g_hModD3D10);
|
||||||
|
g_hModD3D10 = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_hModDXGI)
|
||||||
|
{
|
||||||
|
FreeLibrary(g_hModDXGI);
|
||||||
|
g_hModDXGI = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_hModD3D101)
|
||||||
|
{
|
||||||
|
FreeLibrary(g_hModD3D101);
|
||||||
|
g_hModD3D101 = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dynamically load the D3D10 DLLs loaded and map the function pointers
|
||||||
|
static bool dynlinkLoadD3D10API(void)
|
||||||
|
{
|
||||||
|
// First check to see if the D3D10 Library is present.
|
||||||
|
// if it succeeds, then we can call GetProcAddress to grab all of the DX10 functions
|
||||||
|
g_hModD3D10 = LoadLibrary("d3d10.dll");
|
||||||
|
|
||||||
|
if (g_hModD3D10 != NULL)
|
||||||
|
{
|
||||||
|
sFnPtr_D3D10CreateStateBlock = (LPD3D10CREATESTATEBLOCK) GetProcAddress(g_hModD3D10, "D3D10CreateStateBlock");
|
||||||
|
sFnPtr_D3D10CreateDevice = (LPD3D10CREATEDEVICE) GetProcAddress(g_hModD3D10, "D3D10CreateDevice");
|
||||||
|
|
||||||
|
sFnPtr_D3D10StateBlockMaskUnion = (LPD3D10STATEBLOCKMASKUNION) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskUnion");
|
||||||
|
sFnPtr_D3D10StateBlockMaskIntersect = (LPD3D10STATEBLOCKMASKINTERSECT) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskIntersect");
|
||||||
|
sFnPtr_D3D10StateBlockMaskDifference = (LPD3D10STATEBLOCKMASKDIFFERENCE) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskDifference");
|
||||||
|
sFnPtr_D3D10StateBlockMaskEnableCapture = (LPD3D10STATEBLOCKMASKENABLECAPTURE) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskEnableCapture");
|
||||||
|
sFnPtr_D3D10StateBlockMaskDisableCapture = (LPD3D10STATEBLOCKMASKDISABLECAPTURE)GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskDisableCapture");
|
||||||
|
|
||||||
|
sFnPtr_D3D10StateBlockMaskEnableAll = (LPD3D10STATEBLOCKMASKENABLEALL) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskEnableAll");
|
||||||
|
sFnPtr_D3D10StateBlockMaskDisableAll = (LPD3D10STATEBLOCKMASKDISABLEALL) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskDisableAll");
|
||||||
|
sFnPtr_D3D10StateBlockMaskGetSetting = (LPD3D10STATEBLOCKMASKGETSETTING) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskGetSetting");
|
||||||
|
|
||||||
|
sFnPtr_D3D10CompileEffectFromMemory = (LPD3D10COMPILEEFFECTFROMMEMORY) GetProcAddress(g_hModD3D10, "D3D10CompileEffectFromMemory");
|
||||||
|
sFnPtr_D3D10CreateEffectFromMemory = (LPD3D10CREATEEFFECTFROMMEMORY) GetProcAddress(g_hModD3D10, "D3D10CreateEffectFromMemory");
|
||||||
|
sFnPtr_D3D10CreateEffectPoolFromMemory = (LPD3D10CREATEEFFECTPOOLFROMMEMORY) GetProcAddress(g_hModD3D10, "D3D10CreateEffectPoolFromMemory");
|
||||||
|
|
||||||
|
sFnPtr_D3D10CreateDeviceAndSwapChain = (LPD3D10CREATEDEVICEANDSWAPCHAIN) GetProcAddress(g_hModD3D10, "D3D10CreateDeviceAndSwapChain");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_hModDXGI = LoadLibrary("dxgi.dll");
|
||||||
|
|
||||||
|
if (g_hModDXGI)
|
||||||
|
{
|
||||||
|
sFnPtr_CreateDXGIFactory = (LPCREATEDXGIFACTORY) GetProcAddress(g_hModDXGI , "CreateDXGIFactory");
|
||||||
|
}
|
||||||
|
|
||||||
|
// This may fail if this machine isn't Windows Vista SP1 or later
|
||||||
|
g_hModD3D101 = LoadLibrary("d3d10_1.dll");
|
||||||
|
|
||||||
|
if (g_hModD3D101 != NULL)
|
||||||
|
{
|
||||||
|
sFnPtr_D3D10CreateDevice1 = (LPD3D10CREATEDEVICE1) GetProcAddress(g_hModD3D101, "D3D10CreateDevice1");
|
||||||
|
sFnPtr_D3D10CreateDeviceAndSwapChain1 = (LPD3D10CREATEDEVICEANDSWAPCHAIN1) GetProcAddress(g_hModD3D101, "D3D10CreateDeviceAndSwapChain1");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_hModD3D10 == NULL || g_hModDXGI == NULL || g_hModD3D101 == NULL)
|
||||||
|
{
|
||||||
|
dynlinkUnloadD3D10API();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -665,12 +665,6 @@ inline int _ConvertSMVer2Cores(int major, int minor) {
|
|||||||
{0x75, 64},
|
{0x75, 64},
|
||||||
{0x80, 64},
|
{0x80, 64},
|
||||||
{0x86, 128},
|
{0x86, 128},
|
||||||
{0x87, 128},
|
|
||||||
{0x89, 128},
|
|
||||||
{0x90, 128},
|
|
||||||
{0xa0, 128},
|
|
||||||
{0xa1, 128},
|
|
||||||
{0xc0, 128},
|
|
||||||
{-1, -1}};
|
{-1, -1}};
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@@ -717,12 +711,6 @@ inline const char* _ConvertSMVer2ArchName(int major, int minor) {
|
|||||||
{0x75, "Turing"},
|
{0x75, "Turing"},
|
||||||
{0x80, "Ampere"},
|
{0x80, "Ampere"},
|
||||||
{0x86, "Ampere"},
|
{0x86, "Ampere"},
|
||||||
{0x87, "Ampere"},
|
|
||||||
{0x89, "Ada"},
|
|
||||||
{0x90, "Hopper"},
|
|
||||||
{0xa0, "Blackwell"},
|
|
||||||
{0xa1, "Blackwell"},
|
|
||||||
{0xc0, "Blackwell"},
|
|
||||||
{-1, "Graphics Device"}};
|
{-1, "Graphics Device"}};
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -113,12 +113,6 @@ inline int _ConvertSMVer2CoresDRV(int major, int minor) {
|
|||||||
{0x75, 64},
|
{0x75, 64},
|
||||||
{0x80, 64},
|
{0x80, 64},
|
||||||
{0x86, 128},
|
{0x86, 128},
|
||||||
{0x87, 128},
|
|
||||||
{0x89, 128},
|
|
||||||
{0x90, 128},
|
|
||||||
{0xa0, 128},
|
|
||||||
{0xa1, 128},
|
|
||||||
{0xc0, 128},
|
|
||||||
{-1, -1}};
|
{-1, -1}};
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@@ -408,3 +402,4 @@ bool inline findFatbinPath(const char *module_file, std::string &module_path, ch
|
|||||||
// end of CUDA Helper Functions
|
// end of CUDA Helper Functions
|
||||||
|
|
||||||
#endif // COMMON_HELPER_CUDA_DRVAPI_H_
|
#endif // COMMON_HELPER_CUDA_DRVAPI_H_
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -168,7 +168,7 @@ int waitProcess(Process *process) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__QNX__)
|
#if defined(__linux__)
|
||||||
int ipcCreateSocket(ipcHandle *&handle, const char *name,
|
int ipcCreateSocket(ipcHandle *&handle, const char *name,
|
||||||
const std::vector<Process> &processes) {
|
const std::vector<Process> &processes) {
|
||||||
int server_fd;
|
int server_fd;
|
||||||
@@ -262,48 +262,41 @@ int ipcRecvShareableHandle(ipcHandle *handle, ShareableHandle *shHandle) {
|
|||||||
// Union to guarantee alignment requirements for control array
|
// Union to guarantee alignment requirements for control array
|
||||||
union {
|
union {
|
||||||
struct cmsghdr cm;
|
struct cmsghdr cm;
|
||||||
// This will not work on QNX as QNX CMSG_SPACE calls __cmsg_alignbytes
|
char control[CMSG_SPACE(sizeof(int))];
|
||||||
// And __cmsg_alignbytes is a runtime function instead of compile-time macros
|
|
||||||
// char control[CMSG_SPACE(sizeof(int))]
|
|
||||||
char* control;
|
|
||||||
} control_un;
|
} control_un;
|
||||||
|
|
||||||
size_t sizeof_control = CMSG_SPACE(sizeof(int)) * sizeof(char);
|
|
||||||
control_un.control = (char*) malloc(sizeof_control);
|
|
||||||
struct cmsghdr *cmptr;
|
struct cmsghdr *cmptr;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
int receivedfd;
|
int receivedfd;
|
||||||
char dummy_buffer[1];
|
char dummy_buffer[1];
|
||||||
ssize_t sendResult;
|
ssize_t sendResult;
|
||||||
|
|
||||||
msg.msg_control = control_un.control;
|
msg.msg_control = control_un.control;
|
||||||
msg.msg_controllen = sizeof_control;
|
msg.msg_controllen = sizeof(control_un.control);
|
||||||
|
|
||||||
iov[0].iov_base = (void *)dummy_buffer;
|
iov[0].iov_base = (void *)dummy_buffer;
|
||||||
iov[0].iov_len = sizeof(dummy_buffer);
|
iov[0].iov_len = sizeof(dummy_buffer);
|
||||||
|
|
||||||
msg.msg_iov = iov;
|
msg.msg_iov = iov;
|
||||||
msg.msg_iovlen = 1;
|
msg.msg_iovlen = 1;
|
||||||
|
|
||||||
if ((n = recvmsg(handle->socket, &msg, 0)) <= 0) {
|
if ((n = recvmsg(handle->socket, &msg, 0)) <= 0) {
|
||||||
perror("IPC failure: Receiving data over socket failed");
|
perror("IPC failure: Receiving data over socket failed");
|
||||||
free(control_un.control);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((cmptr = CMSG_FIRSTHDR(&msg)) != NULL) &&
|
if (((cmptr = CMSG_FIRSTHDR(&msg)) != NULL) &&
|
||||||
(cmptr->cmsg_len == CMSG_LEN(sizeof(int)))) {
|
(cmptr->cmsg_len == CMSG_LEN(sizeof(int)))) {
|
||||||
if ((cmptr->cmsg_level != SOL_SOCKET) || (cmptr->cmsg_type != SCM_RIGHTS)) {
|
if ((cmptr->cmsg_level != SOL_SOCKET) || (cmptr->cmsg_type != SCM_RIGHTS)) {
|
||||||
free(control_un.control);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(&receivedfd, CMSG_DATA(cmptr), sizeof(receivedfd));
|
memmove(&receivedfd, CMSG_DATA(cmptr), sizeof(receivedfd));
|
||||||
*(int *)shHandle = receivedfd;
|
*(int *)shHandle = receivedfd;
|
||||||
} else {
|
} else {
|
||||||
free(control_un.control);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(control_un.control);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,12 +340,9 @@ int ipcSendShareableHandle(ipcHandle *handle,
|
|||||||
|
|
||||||
union {
|
union {
|
||||||
struct cmsghdr cm;
|
struct cmsghdr cm;
|
||||||
char* control;
|
char control[CMSG_SPACE(sizeof(int))];
|
||||||
} control_un;
|
} control_un;
|
||||||
|
|
||||||
size_t sizeof_control = CMSG_SPACE(sizeof(int)) * sizeof(char);
|
|
||||||
control_un.control = (char*) malloc(sizeof_control);
|
|
||||||
|
|
||||||
struct cmsghdr *cmptr;
|
struct cmsghdr *cmptr;
|
||||||
ssize_t readResult;
|
ssize_t readResult;
|
||||||
struct sockaddr_un cliaddr;
|
struct sockaddr_un cliaddr;
|
||||||
@@ -370,7 +360,7 @@ int ipcSendShareableHandle(ipcHandle *handle,
|
|||||||
int sendfd = (int)shareableHandles[data];
|
int sendfd = (int)shareableHandles[data];
|
||||||
|
|
||||||
msg.msg_control = control_un.control;
|
msg.msg_control = control_un.control;
|
||||||
msg.msg_controllen = sizeof_control;
|
msg.msg_controllen = sizeof(control_un.control);
|
||||||
|
|
||||||
cmptr = CMSG_FIRSTHDR(&msg);
|
cmptr = CMSG_FIRSTHDR(&msg);
|
||||||
cmptr->cmsg_len = CMSG_LEN(sizeof(int));
|
cmptr->cmsg_len = CMSG_LEN(sizeof(int));
|
||||||
@@ -390,11 +380,9 @@ int ipcSendShareableHandle(ipcHandle *handle,
|
|||||||
ssize_t sendResult = sendmsg(handle->socket, &msg, 0);
|
ssize_t sendResult = sendmsg(handle->socket, &msg, 0);
|
||||||
if (sendResult <= 0) {
|
if (sendResult <= 0) {
|
||||||
perror("IPC failure: Sending data over socket failed");
|
perror("IPC failure: Sending data over socket failed");
|
||||||
free(control_un.control);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(control_un.control);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -84,7 +84,7 @@ int waitProcess(Process *process);
|
|||||||
#define checkIpcErrors(ipcFuncResult) \
|
#define checkIpcErrors(ipcFuncResult) \
|
||||||
if (ipcFuncResult == -1) { fprintf(stderr, "Failure at %u %s\n", __LINE__, __FILE__); exit(EXIT_FAILURE); }
|
if (ipcFuncResult == -1) { fprintf(stderr, "Failure at %u %s\n", __LINE__, __FILE__); exit(EXIT_FAILURE); }
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__QNX__)
|
#if defined(__linux__)
|
||||||
struct ipcHandle_st {
|
struct ipcHandle_st {
|
||||||
int socket;
|
int socket;
|
||||||
char *socketName;
|
char *socketName;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -399,10 +399,10 @@ int getInputDir(std::string &input_dir, const char *executable_path) {
|
|||||||
// Search in default paths for input images.
|
// Search in default paths for input images.
|
||||||
std::string pathname = "";
|
std::string pathname = "";
|
||||||
const char *searchPath[] = {
|
const char *searchPath[] = {
|
||||||
"./images",
|
"./images", "../../../../Samples/<executable_name>/images",
|
||||||
"../../../../Samples/4_CUDA_Libraries/<executable_name>/images",
|
"../../../Samples/<executable_name>/images",
|
||||||
"../../../Samples/4_CUDA_Libraries/<executable_name>/images",
|
"../../Samples/<executable_name>/images"};
|
||||||
"../../Samples/4_CUDA_Libraries/<executable_name>/images"};
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < sizeof(searchPath) / sizeof(char *); ++i) {
|
for (unsigned int i = 0; i < sizeof(searchPath) / sizeof(char *); ++i) {
|
||||||
std::string pathname(searchPath[i]);
|
std::string pathname(searchPath[i]);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -285,73 +285,14 @@ inline char *sdkFindFilePath(const char *filename,
|
|||||||
// the .exe file, a .bat file launching an .exe, a browser .exe launching the
|
// the .exe file, a .bat file launching an .exe, a browser .exe launching the
|
||||||
// .exe or .bat, etc
|
// .exe or .bat, etc
|
||||||
const char *searchPath[] = {
|
const char *searchPath[] = {
|
||||||
"./", // same dir
|
"./", // same dir
|
||||||
"./data/", // same dir
|
"./data/", // same dir
|
||||||
|
|
||||||
"../../../../Samples/<executable_name>/", // up 4 in tree
|
"../../../../Samples/<executable_name>/", // up 4 in tree
|
||||||
"../../../Samples/<executable_name>/", // up 3 in tree
|
"../../../Samples/<executable_name>/", // up 3 in tree
|
||||||
"../../Samples/<executable_name>/", // up 2 in tree
|
"../../Samples/<executable_name>/", // up 2 in tree
|
||||||
|
|
||||||
"../../../../Samples/<executable_name>/data/", // up 4 in tree
|
"../../../../Samples/<executable_name>/data/", // up 4 in tree
|
||||||
"../../../Samples/<executable_name>/data/", // up 3 in tree
|
"../../../Samples/<executable_name>/data/", // up 3 in tree
|
||||||
"../../Samples/<executable_name>/data/", // up 2 in tree
|
"../../Samples/<executable_name>/data/", // up 2 in tree
|
||||||
|
|
||||||
"../../../../Samples/0_Introduction/<executable_name>/", // up 4 in tree
|
|
||||||
"../../../Samples/0_Introduction/<executable_name>/", // up 3 in tree
|
|
||||||
"../../Samples/0_Introduction/<executable_name>/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/1_Utilities/<executable_name>/", // up 4 in tree
|
|
||||||
"../../../Samples/1_Utilities/<executable_name>/", // up 3 in tree
|
|
||||||
"../../Samples/1_Utilities/<executable_name>/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/2_Concepts_and_Techniques/<executable_name>/", // up 4 in tree
|
|
||||||
"../../../Samples/2_Concepts_and_Techniques/<executable_name>/", // up 3 in tree
|
|
||||||
"../../Samples/2_Concepts_and_Techniques/<executable_name>/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/3_CUDA_Features/<executable_name>/", // up 4 in tree
|
|
||||||
"../../../Samples/3_CUDA_Features/<executable_name>/", // up 3 in tree
|
|
||||||
"../../Samples/3_CUDA_Features/<executable_name>/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/4_CUDA_Libraries/<executable_name>/", // up 4 in tree
|
|
||||||
"../../../Samples/4_CUDA_Libraries/<executable_name>/", // up 3 in tree
|
|
||||||
"../../Samples/4_CUDA_Libraries/<executable_name>/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/5_Domain_Specific/<executable_name>/", // up 4 in tree
|
|
||||||
"../../../Samples/5_Domain_Specific/<executable_name>/", // up 3 in tree
|
|
||||||
"../../Samples/5_Domain_Specific/<executable_name>/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/6_Performance/<executable_name>/", // up 4 in tree
|
|
||||||
"../../../Samples/6_Performance/<executable_name>/", // up 3 in tree
|
|
||||||
"../../Samples/6_Performance/<executable_name>/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/0_Introduction/<executable_name>/data/", // up 4 in tree
|
|
||||||
"../../../Samples/0_Introduction/<executable_name>/data/", // up 3 in tree
|
|
||||||
"../../Samples/0_Introduction/<executable_name>/data/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/1_Utilities/<executable_name>/data/", // up 4 in tree
|
|
||||||
"../../../Samples/1_Utilities/<executable_name>/data/", // up 3 in tree
|
|
||||||
"../../Samples/1_Utilities/<executable_name>/data/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/2_Concepts_and_Techniques/<executable_name>/data/", // up 4 in tree
|
|
||||||
"../../../Samples/2_Concepts_and_Techniques/<executable_name>/data/", // up 3 in tree
|
|
||||||
"../../Samples/2_Concepts_and_Techniques/<executable_name>/data/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/3_CUDA_Features/<executable_name>/data/", // up 4 in tree
|
|
||||||
"../../../Samples/3_CUDA_Features/<executable_name>/data/", // up 3 in tree
|
|
||||||
"../../Samples/3_CUDA_Features/<executable_name>/data/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/4_CUDA_Libraries/<executable_name>/data/", // up 4 in tree
|
|
||||||
"../../../Samples/4_CUDA_Libraries/<executable_name>/data/", // up 3 in tree
|
|
||||||
"../../Samples/4_CUDA_Libraries/<executable_name>/data/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/5_Domain_Specific/<executable_name>/data/", // up 4 in tree
|
|
||||||
"../../../Samples/5_Domain_Specific/<executable_name>/data/", // up 3 in tree
|
|
||||||
"../../Samples/5_Domain_Specific/<executable_name>/data/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Samples/6_Performance/<executable_name>/data/", // up 4 in tree
|
|
||||||
"../../../Samples/6_Performance/<executable_name>/data/", // up 3 in tree
|
|
||||||
"../../Samples/6_Performance/<executable_name>/data/", // up 2 in tree
|
|
||||||
|
|
||||||
"../../../../Common/data/", // up 4 in tree
|
"../../../../Common/data/", // up 4 in tree
|
||||||
"../../../Common/data/", // up 3 in tree
|
"../../../Common/data/", // up 3 in tree
|
||||||
"../../Common/data/" // up 2 in tree
|
"../../Common/data/" // up 2 in tree
|
||||||
@@ -421,7 +362,6 @@ inline char *sdkFindFilePath(const char *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// File not found
|
// File not found
|
||||||
printf("\nerror: sdkFindFilePath: file <%s> not found!\n", filename);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -49,11 +49,6 @@
|
|||||||
|
|
||||||
void compileFileToCUBIN(char *filename, int argc, char **argv, char **cubinResult,
|
void compileFileToCUBIN(char *filename, int argc, char **argv, char **cubinResult,
|
||||||
size_t *cubinResultSize, int requiresCGheaders) {
|
size_t *cubinResultSize, int requiresCGheaders) {
|
||||||
if (!filename) {
|
|
||||||
std::cerr << "\nerror: filename is empty for compileFileToCUBIN()!\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ifstream inputFile(filename,
|
std::ifstream inputFile(filename,
|
||||||
std::ios::in | std::ios::binary | std::ios::ate);
|
std::ios::in | std::ios::binary | std::ios::ate);
|
||||||
|
|
||||||
@@ -116,12 +111,7 @@ void compileFileToCUBIN(char *filename, int argc, char **argv, char **cubinResul
|
|||||||
|
|
||||||
compileOptions = "--include-path=";
|
compileOptions = "--include-path=";
|
||||||
|
|
||||||
char *strPath = sdkFindFilePath(HeaderNames, argv[0]);
|
std::string path = sdkFindFilePath(HeaderNames, argv[0]);
|
||||||
if (!strPath) {
|
|
||||||
std::cerr << "\nerror: header file " << HeaderNames << " not found!\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
std::string path = strPath;
|
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
std::size_t found = path.find(HeaderNames);
|
std::size_t found = path.find(HeaderNames);
|
||||||
path.erase(found);
|
path.erase(found);
|
||||||
@@ -130,7 +120,6 @@ void compileFileToCUBIN(char *filename, int argc, char **argv, char **cubinResul
|
|||||||
"\nCooperativeGroups headers not found, please install it in %s "
|
"\nCooperativeGroups headers not found, please install it in %s "
|
||||||
"sample directory..\n Exiting..\n",
|
"sample directory..\n Exiting..\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
compileOptions += path.c_str();
|
compileOptions += path.c_str();
|
||||||
compileParams[numCompileOptions] = reinterpret_cast<char *>(
|
compileParams[numCompileOptions] = reinterpret_cast<char *>(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
128
Common/rendercheck_d3d10.cpp
Normal file
128
Common/rendercheck_d3d10.cpp
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/* Copyright (c) 2021, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Utility funcs to wrap up saving a surface or the back buffer as a PPM file
|
||||||
|
// In addition, wraps up a threshold comparision of two PPMs.
|
||||||
|
//
|
||||||
|
// These functions are designed to be used to implement an automated QA testing
|
||||||
|
// for SDK samples.
|
||||||
|
//
|
||||||
|
// Author: Bryan Dudash
|
||||||
|
// Email: sdkfeedback@nvidia.com
|
||||||
|
//
|
||||||
|
// Copyright (c) NVIDIA Corporation. All rights reserved.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <helper_functions.h>
|
||||||
|
#include <rendercheck_d3d10.h>
|
||||||
|
|
||||||
|
HRESULT CheckRenderD3D10::ActiveRenderTargetToPPM(ID3D10Device *pDevice,
|
||||||
|
const char *zFileName) {
|
||||||
|
ID3D10RenderTargetView *pRTV = NULL;
|
||||||
|
pDevice->OMGetRenderTargets(1, &pRTV, NULL);
|
||||||
|
|
||||||
|
ID3D10Resource *pSourceResource = NULL;
|
||||||
|
pRTV->GetResource(&pSourceResource);
|
||||||
|
|
||||||
|
return ResourceToPPM(pDevice, pSourceResource, zFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CheckRenderD3D10::ResourceToPPM(ID3D10Device *pDevice,
|
||||||
|
ID3D10Resource *pResource,
|
||||||
|
const char *zFileName) {
|
||||||
|
D3D10_RESOURCE_DIMENSION rType;
|
||||||
|
pResource->GetType(&rType);
|
||||||
|
|
||||||
|
if (rType != D3D10_RESOURCE_DIMENSION_TEXTURE2D) {
|
||||||
|
printf("SurfaceToPPM: pResource is not a 2D texture! Aborting...\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D10Texture2D *pSourceTexture = (ID3D10Texture2D *)pResource;
|
||||||
|
ID3D10Texture2D *pTargetTexture = NULL;
|
||||||
|
|
||||||
|
D3D10_TEXTURE2D_DESC desc;
|
||||||
|
pSourceTexture->GetDesc(&desc);
|
||||||
|
desc.BindFlags = 0;
|
||||||
|
desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
|
||||||
|
desc.Usage = D3D10_USAGE_STAGING;
|
||||||
|
|
||||||
|
if (FAILED(pDevice->CreateTexture2D(&desc, NULL, &pTargetTexture))) {
|
||||||
|
printf(
|
||||||
|
"SurfaceToPPM: Unable to create target Texture resoruce! Aborting... "
|
||||||
|
"\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDevice->CopyResource(pTargetTexture, pSourceTexture);
|
||||||
|
|
||||||
|
D3D10_MAPPED_TEXTURE2D mappedTex2D;
|
||||||
|
pTargetTexture->Map(0, D3D10_MAP_READ, 0, &mappedTex2D);
|
||||||
|
|
||||||
|
// Need to convert from dx pitch to pitch=width
|
||||||
|
unsigned char *pPPMData = new unsigned char[desc.Width * desc.Height * 4];
|
||||||
|
|
||||||
|
for (unsigned int iHeight = 0; iHeight < desc.Height; iHeight++) {
|
||||||
|
memcpy(
|
||||||
|
&(pPPMData[iHeight * desc.Width * 4]),
|
||||||
|
(unsigned char *)(mappedTex2D.pData) + iHeight * mappedTex2D.RowPitch,
|
||||||
|
desc.Width * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
pTargetTexture->Unmap(0);
|
||||||
|
|
||||||
|
// Prepends the PPM header info and bumps byte data afterwards
|
||||||
|
sdkSavePPM4ub(zFileName, pPPMData, desc.Width, desc.Height);
|
||||||
|
|
||||||
|
delete[] pPPMData;
|
||||||
|
pTargetTexture->Release();
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CheckRenderD3D10::PPMvsPPM(const char *src_file, const char *ref_file,
|
||||||
|
const char *exec_path, const float epsilon,
|
||||||
|
const float threshold) {
|
||||||
|
char *ref_file_path = sdkFindFilePath(ref_file, exec_path);
|
||||||
|
|
||||||
|
if (ref_file_path == NULL) {
|
||||||
|
printf(
|
||||||
|
"CheckRenderD3D10::PPMvsPPM unable to find <%s> in <%s> Aborting "
|
||||||
|
"comparison!\n",
|
||||||
|
ref_file, exec_path);
|
||||||
|
printf(">>> Check info.xml and [project//data] folder <%s> <<<\n",
|
||||||
|
ref_file);
|
||||||
|
printf("Aborting comparison!\n");
|
||||||
|
printf(" FAILURE!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (sdkComparePPM(src_file, ref_file_path, epsilon, threshold, true) ==
|
||||||
|
true);
|
||||||
|
}
|
||||||
53
Common/rendercheck_d3d10.h
Normal file
53
Common/rendercheck_d3d10.h
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/* Copyright (c) 2021, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef _RENDERCHECK_D3D10_H_
|
||||||
|
#define _RENDERCHECK_D3D10_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <d3d10.h>
|
||||||
|
|
||||||
|
class CheckRenderD3D10 {
|
||||||
|
public:
|
||||||
|
CheckRenderD3D10() {}
|
||||||
|
|
||||||
|
static HRESULT ActiveRenderTargetToPPM(ID3D10Device *pDevice,
|
||||||
|
const char *zFileName);
|
||||||
|
static HRESULT ResourceToPPM(ID3D10Device *pDevice, ID3D10Resource *pResource,
|
||||||
|
const char *zFileName);
|
||||||
|
|
||||||
|
static bool PPMvsPPM(const char *src_file, const char *ref_file,
|
||||||
|
const char *exec_path, const float epsilon,
|
||||||
|
const float threshold = 0.0f);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
167
Common/rendercheck_d3d9.cpp
Normal file
167
Common/rendercheck_d3d9.cpp
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
/* Copyright (c) 2021, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Utility funcs to wrap up savings a surface or the back buffer as a PPM file
|
||||||
|
// In addition, wraps up a threshold comparision of two PPMs.
|
||||||
|
//
|
||||||
|
// These functions are designed to be used to implement an automated QA testing
|
||||||
|
// for SDK samples.
|
||||||
|
//
|
||||||
|
// Author: Bryan Dudash
|
||||||
|
// Email: sdkfeedback@nvidia.com
|
||||||
|
//
|
||||||
|
// Copyright (c) NVIDIA Corporation. All rights reserved.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <helper_functions.h>
|
||||||
|
#include <rendercheck_d3d9.h>
|
||||||
|
|
||||||
|
// originally copied from checkrender_gl.cpp and slightly modified
|
||||||
|
bool CheckRenderD3D9::PPMvsPPM(const char *src_file, const char *ref_file,
|
||||||
|
const char *exec_path, const float epsilon,
|
||||||
|
const float threshold) {
|
||||||
|
char *ref_file_path = sdkFindFilePath(ref_file, exec_path);
|
||||||
|
|
||||||
|
if (ref_file_path == NULL) {
|
||||||
|
printf(
|
||||||
|
"CheckRenderD3D9::PPMvsPPM unable to find <%s> in <%s> Aborting "
|
||||||
|
"comparison!\n",
|
||||||
|
ref_file, exec_path);
|
||||||
|
printf(">>> Check info.xml and [project//data] folder <%s> <<<\n",
|
||||||
|
ref_file);
|
||||||
|
printf("Aborting comparison!\n");
|
||||||
|
printf(" FAILURE!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (sdkComparePPM(src_file, ref_file_path, epsilon, threshold, true) ==
|
||||||
|
true);
|
||||||
|
};
|
||||||
|
|
||||||
|
HRESULT CheckRenderD3D9::BackbufferToPPM(IDirect3DDevice9 *pDevice,
|
||||||
|
const char *zFileName) {
|
||||||
|
IDirect3DSurface9 *pSurface = NULL;
|
||||||
|
|
||||||
|
if (FAILED(
|
||||||
|
pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pSurface))) {
|
||||||
|
printf("Unable to get the back buffer. Aborting...\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// D3DXSaveSurfaceToFile("C:\\bing.dds",D3DXIFF_DDS,pSurface,NULL,NULL);
|
||||||
|
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
hr = SurfaceToPPM(pDevice, pSurface, zFileName);
|
||||||
|
|
||||||
|
pSurface->Release();
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CheckRenderD3D9::SurfaceToPPM(IDirect3DDevice9 *pDevice,
|
||||||
|
IDirect3DSurface9 *pSurface,
|
||||||
|
const char *zFileName) {
|
||||||
|
D3DSURFACE_DESC pDesc;
|
||||||
|
pSurface->GetDesc(&pDesc);
|
||||||
|
|
||||||
|
// $$ For now only support common 8bit formats. TODO: support for more
|
||||||
|
// complex formats via conversion?
|
||||||
|
if (!(pDesc.Format == D3DFMT_A8R8G8B8 || pDesc.Format == D3DFMT_X8R8G8B8)) {
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
IDirect3DTexture9 *pTargetTex = NULL;
|
||||||
|
|
||||||
|
if (FAILED(pDevice->CreateTexture(pDesc.Width, pDesc.Height, 1,
|
||||||
|
D3DUSAGE_DYNAMIC, pDesc.Format,
|
||||||
|
D3DPOOL_SYSTEMMEM, &pTargetTex, NULL))) {
|
||||||
|
printf("Unable to create texture for surface transfer! Aborting...\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
IDirect3DSurface9 *pTargetSurface = NULL;
|
||||||
|
|
||||||
|
if (FAILED(pTargetTex->GetSurfaceLevel(0, &pTargetSurface))) {
|
||||||
|
printf("Unable to get surface for surface transfer! Aborting...\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is required because we cannot lock a D3DPOOL_DEAULT surface directly.
|
||||||
|
// So, we copy to our sysmem surface.
|
||||||
|
if (FAILED(pDevice->GetRenderTargetData(pSurface, pTargetSurface))) {
|
||||||
|
printf(
|
||||||
|
"Unable to GetRenderTargetData() for surface transfer! Aborting...\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
D3DLOCKED_RECT lockedRect;
|
||||||
|
HRESULT hr = pTargetSurface->LockRect(&lockedRect, NULL, 0);
|
||||||
|
|
||||||
|
// Need to convert from dx pitch to pitch=width
|
||||||
|
//
|
||||||
|
// $ PPM is BGR and not RGB it seems. Saved image looks "funny" in viewer(red
|
||||||
|
// and blue swapped), but since ref will be dumped using same method, this is
|
||||||
|
// ok.
|
||||||
|
// however, if we want the saved image to be properly colored, then we
|
||||||
|
// can swizzle the color bytes here.
|
||||||
|
unsigned char *pPPMData = new unsigned char[pDesc.Width * pDesc.Height * 4];
|
||||||
|
|
||||||
|
for (unsigned int iHeight = 0; iHeight < pDesc.Height; iHeight++) {
|
||||||
|
#if 1 // swizzle to implment RGB to BGR conversion.
|
||||||
|
|
||||||
|
for (unsigned int iWidth = 0; iWidth < pDesc.Width; iWidth++) {
|
||||||
|
DWORD color = *(DWORD *)((unsigned char *)(lockedRect.pBits) +
|
||||||
|
iHeight * lockedRect.Pitch + iWidth * 4);
|
||||||
|
|
||||||
|
// R<->B, [7:0] <-> [23:16], swizzle
|
||||||
|
color = ((color & 0xFF) << 16) | (color & 0xFF00) |
|
||||||
|
((color & 0xFF0000) >> 16) | (color & 0xFF000000);
|
||||||
|
|
||||||
|
memcpy(&(pPPMData[(iHeight * pDesc.Width + iWidth) * 4]),
|
||||||
|
(unsigned char *)&color, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
memcpy(&(pPPMData[iHeight * pDesc.Width * 4]),
|
||||||
|
(unsigned char *)(lockedRect.pBits) + iHeight * lockedRect.Pitch,
|
||||||
|
pDesc.Width * 4);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
pTargetSurface->UnlockRect();
|
||||||
|
|
||||||
|
// Prepends the PPM header info and bumps byte data afterwards
|
||||||
|
sdkSavePPM4ub(zFileName, pPPMData, pDesc.Width, pDesc.Height);
|
||||||
|
|
||||||
|
delete[] pPPMData;
|
||||||
|
pTargetSurface->Release();
|
||||||
|
pTargetTex->Release();
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
54
Common/rendercheck_d3d9.h
Normal file
54
Common/rendercheck_d3d9.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/* Copyright (c) 2021, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef _RENDERCHECK_D3D9_H_
|
||||||
|
#define _RENDERCHECK_D3D9_H_
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <d3d9.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
class CheckRenderD3D9 {
|
||||||
|
public:
|
||||||
|
CheckRenderD3D9() {}
|
||||||
|
|
||||||
|
static HRESULT BackbufferToPPM(IDirect3DDevice9 *pDevice,
|
||||||
|
const char *zFileName);
|
||||||
|
static HRESULT SurfaceToPPM(IDirect3DDevice9 *pDevice,
|
||||||
|
IDirect3DSurface9 *pSurface,
|
||||||
|
const char *zFileName);
|
||||||
|
|
||||||
|
static bool PPMvsPPM(const char *src_file, const char *ref_file,
|
||||||
|
const char *exec_path, const float epsilon,
|
||||||
|
const float threshold = 0.0f);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
|
|||||||
69
Makefile
Normal file
69
Makefile
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019, 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.
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# CUDA Samples
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
TARGET_ARCH ?= $(shell uname -m)
|
||||||
|
|
||||||
|
# Project folders that contain CUDA samples
|
||||||
|
PROJECTS ?= $(shell find Samples -name Makefile)
|
||||||
|
|
||||||
|
FILTER_OUT :=
|
||||||
|
|
||||||
|
PROJECTS := $(filter-out $(FILTER_OUT),$(PROJECTS))
|
||||||
|
|
||||||
|
%.ph_build :
|
||||||
|
+@$(MAKE) -C $(dir $*) $(MAKECMDGOALS)
|
||||||
|
|
||||||
|
%.ph_clean :
|
||||||
|
+@$(MAKE) -C $(dir $*) clean $(USE_DEVICE)
|
||||||
|
|
||||||
|
%.ph_clobber :
|
||||||
|
+@$(MAKE) -C $(dir $*) clobber $(USE_DEVICE)
|
||||||
|
|
||||||
|
%.ph_run :
|
||||||
|
+@$(MAKE) -C $(dir $*) run
|
||||||
|
|
||||||
|
all: $(addsuffix .ph_build,$(PROJECTS))
|
||||||
|
@echo "Finished building CUDA samples"
|
||||||
|
|
||||||
|
build: $(addsuffix .ph_build,$(PROJECTS))
|
||||||
|
|
||||||
|
tidy:
|
||||||
|
@find * | egrep "#" | xargs rm -f
|
||||||
|
@find * | egrep "\~" | xargs rm -f
|
||||||
|
|
||||||
|
clean: tidy $(addsuffix .ph_clean,$(PROJECTS))
|
||||||
|
|
||||||
|
clobber: clean $(addsuffix .ph_clobber,$(PROJECTS))
|
||||||
|
|
||||||
|
run: $(addsuffix .ph_run,$(PROJECTS))
|
||||||
374
README.md
374
README.md
@@ -1,20 +1,130 @@
|
|||||||
# CUDA Samples
|
# CUDA Samples
|
||||||
|
|
||||||
Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 12.6](https://developer.nvidia.com/cuda-downloads).
|
Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 11.5](https://developer.nvidia.com/cuda-downloads).
|
||||||
|
|
||||||
## Release Notes
|
## Release Notes
|
||||||
|
|
||||||
This section describes the release notes for the CUDA Samples on GitHub only.
|
This section describes the release notes for the CUDA Samples on GitHub only.
|
||||||
|
|
||||||
### Change Log
|
### CUDA 11.5
|
||||||
|
* Added `cuDLAHybridMode`. Demonstrate usage of cuDLA in hybrid mode.
|
||||||
|
* Added `cuDLAStandaloneMode`. Demonstrate usage of cuDLA in standalone mode.
|
||||||
|
* Added `cuDLAErrorReporting`. Demonstrate DLA error detection via CUDA.
|
||||||
|
* Added `graphMemoryNodes`. Demonstrates memory allocations and frees within CUDA graphs using Graph APIs and Stream Capture APIs.
|
||||||
|
* Added `graphMemoryFootprint`. Demonstrates how graph memory nodes re-use virtual addresses and physical memory.
|
||||||
|
* All samples from CUDA toolkit are now available on [GitHub](https://github.com/nvidia/cuda-samples).
|
||||||
|
|
||||||
### [Revision History](./CHANGELOG.md)
|
### CUDA 11.4 update 1
|
||||||
|
* Added support for VS Code on linux platform.
|
||||||
|
|
||||||
|
### CUDA 11.4
|
||||||
|
* Added `cdpQuadtree`. Demonstrates Quad Trees implementation using CUDA Dynamic Parallelism.
|
||||||
|
* Updated `simpleVulkan`, `simpleVulkanMMAP` and `vulkanImageCUDA`. Demonstrates use of SPIR-V shaders.
|
||||||
|
|
||||||
|
### CUDA 11.3
|
||||||
|
* Added `streamOrderedAllocationIPC`. Demonstrates Inter Process Communication using one process per GPU for computation.
|
||||||
|
* Added `simpleCUBLAS_LU`. Demonstrates batched matrix LU decomposition using cuBLAS API `cublas<t>getrfBatched()`
|
||||||
|
* Updated `simpleVulkan`. Demonstrates use of timeline semaphore.
|
||||||
|
* Updated multiple samples to use pinned memory using `cudaMallocHost()`.
|
||||||
|
|
||||||
|
### CUDA 11.2
|
||||||
|
* Added `streamOrderedAllocation`. Demonstrates stream ordered memory allocation on a GPU using cudaMallocAsync and cudaMemPool family of APIs.
|
||||||
|
* Added `streamOrderedAllocationP2P`. Demonstrates peer-to-peer access of stream ordered memory allocated using cudaMallocAsync and cudaMemPool family of APIs.
|
||||||
|
* Dropped Visual Studio 2015 support from all the windows supported samples.
|
||||||
|
* FreeImage is no longer distributed with the CUDA Samples. On Windows, see the [Dependencies](#freeimage) section for more details on how to set up FreeImage. On Linux, it is recommended to install FreeImage with your distribution's package manager.
|
||||||
|
* All the samples using CUDA Pipeline & Arrive-wait barriers are been updated to use new `cuda::pipeline` and `cuda::barrier` interfaces.
|
||||||
|
* Updated all the samples to build with parallel build option `--threads` of `nvcc` cuda compiler.
|
||||||
|
* Added `cudaNvSciNvMedia`. Demonstrates CUDA-NvMedia interop via NvSciBuf/NvSciSync APIs.
|
||||||
|
* Added `simpleGL`. Demonstrates interoperability between CUDA and OpenGL.
|
||||||
|
|
||||||
|
### CUDA 11.1
|
||||||
|
* Added `watershedSegmentationNPP`. Demonstrates how to use the NPP watershed segmentation function.
|
||||||
|
* Added `batchedLabelMarkersAndLabelCompressionNPP`. Demonstrates how to use the NPP label markers generation and label compression functions based on a Union Find (UF) algorithm including both single image and batched image versions.
|
||||||
|
* Dropped Visual Studio 2012, 2013 support from all the windows supported samples.
|
||||||
|
* Added kernel performing warp aggregated atomic max in multi buckets using cg::labeled_partition & cg::reduce in `warpAggregatedAtomicsCG`.
|
||||||
|
* Added extended CG shuffle mechanics to `shfl_scan` sample.
|
||||||
|
* Added `cudaOpenMP`. Demonstrates how to use OpenMP API to write an application for multiple GPUs.
|
||||||
|
* Added `simpleZeroCopy`. Demonstrates how to use zero copy, kernels can read and write directly to pinned system memory.
|
||||||
|
|
||||||
|
### CUDA 11.0
|
||||||
|
* Added `dmmaTensorCoreGemm`. Demonstrates double precision GEMM computation using the Double precision Warp Matrix Multiply and Accumulate (WMMA) API introduced with CUDA 11 in Ampere chip family tensor cores.
|
||||||
|
* Added `bf16TensorCoreGemm`. Demonstrates __nv_bfloat16 (e8m7) GEMM computation using the __nv_bfloat16 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.
|
||||||
|
* Added `tf32TensorCoreGemm`. Demonstrates tf32 (e8m10) GEMM computation using the tf32 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.
|
||||||
|
* Added `globalToShmemAsyncCopy`. Demonstrates async copy of data from global to shared memory when on compute capability 8.0 or higher. Also demonstrates arrive-wait barrier for synchronization.
|
||||||
|
* Added `simpleAWBarrier`. Demonstrates arrive wait barriers.
|
||||||
|
* Added `simpleAttributes`. Demonstrates the stream attributes that affect L2 locality.
|
||||||
|
* Added warp aggregated atomic multi bucket increments kernel using labeled_partition cooperative groups in `warpAggregatedAtomicsCG` which can be used on compute capability 7.0 and above GPU architectures.
|
||||||
|
* Added `binaryPartitionCG`. Demonstrates binary partition cooperative groups and reduction within the thread block.
|
||||||
|
* Added two new reduction kernels in `reduction` one which demonstrates reduce_add_sync intrinstic supported on compute capability 8.0 and another which uses cooperative_groups::reduce function which does thread_block_tile level reduction introduced from CUDA 11.0.
|
||||||
|
* Added `cudaCompressibleMemory`. Demonstrates compressible memory allocation using cuMemMap API.
|
||||||
|
* Added `simpleVulkanMMAP`. Demonstrates Vulkan CUDA Interop via cuMemMap APIs.
|
||||||
|
* Added `concurrentKernels`. Demonstrates the use of CUDA streams for concurrent execution of several kernels on a GPU.
|
||||||
|
* Dropped Mac OSX support from all samples.
|
||||||
|
|
||||||
|
### CUDA 10.2
|
||||||
|
* Added `simpleD3D11`. Demonstrates CUDA-D3D11 External Resource Interoperability APIs for updating D3D11 buffers from CUDA and synchronization between D3D11 and CUDA with Keyed Mutexes.
|
||||||
|
* Added `simpleDrvRuntime`. Demonstrates CUDA Driver and Runtime APIs working together to load fatbinary of a CUDA kernel.
|
||||||
|
* Added `vectorAddMMAP`. Demonstrates how cuMemMap API allows the user to specify the physical properties of their memory while retaining the contiguous nature of their access.
|
||||||
|
* Added `memMapIPCDrv`. Demonstrates Inter Process Communication using cuMemMap APIs.
|
||||||
|
* Added `cudaNvSci`. Demonstrates CUDA-NvSciBuf/NvSciSync Interop.
|
||||||
|
* Added `jacobiCudaGraphs`. Demonstrates Instantiated CUDA Graph Update with Jacobi Iterative Method using different approaches.
|
||||||
|
* Added `cuSolverSp_LinearSolver`. Demonstrates cuSolverSP's LU, QR and Cholesky factorization.
|
||||||
|
* Added `MersenneTwisterGP11213`. Demonstrates the Mersenne Twister random number generator GP11213 in cuRAND.
|
||||||
|
|
||||||
|
### CUDA 10.1 Update 2
|
||||||
|
* Added `vulkanImageCUDA`. Demonstrates how to perform Vulkan image - CUDA Interop.
|
||||||
|
* Added `nvJPEG_encoder`. Demonstrates encoding of jpeg images using NVJPEG Library.
|
||||||
|
* Added Windows OS support to `nvJPEG` sample.
|
||||||
|
* Added `boxFilterNPP`. Demonstrates how to use NPP FilterBox function to perform a box filter.
|
||||||
|
* Added `cannyEdgeDetectorNPP`. Demonstrates the nppiFilterCannyBorder_8u_C1R Canny Edge Detection image filter function.
|
||||||
|
|
||||||
|
### CUDA 10.1 Update 1
|
||||||
|
* Added `NV12toBGRandResize`. Demonstrates how to convert and resize NV12 frames to BGR planars frames using CUDA in batch.
|
||||||
|
* Added `EGLStream_CUDA_Interop`. Demonstrates data exchange between CUDA and EGL Streams.
|
||||||
|
* Added `cuSolverDn_LinearSolver`. Demonstrates cuSolverDN's LU, QR and Cholesky factorization.
|
||||||
|
* Added support of Visual Studio 2019 to all samples supported on [Windows](#windows-1).
|
||||||
|
|
||||||
|
### CUDA 10.1
|
||||||
|
* Added `immaTensorCoreGemm`. Demonstrates integer GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API for integers employing the Tensor Cores.
|
||||||
|
* Added `simpleIPC`. Demonstrates Inter Process Communication with one process per GPU for computation.
|
||||||
|
* Added `nvJPEG`. Demonstrates single and batched decoding of jpeg images using NVJPEG Library.
|
||||||
|
* Added `bandwidthTest`. It measures the memcopy bandwidth of the GPU and memcpy bandwidth across PCI-e.
|
||||||
|
* Added `reduction`. Demonstrates several important optimization strategies for Data-Parallel Algorithms like reduction.
|
||||||
|
* Update all the samples to support CUDA 10.1.
|
||||||
|
|
||||||
|
### CUDA 10.0
|
||||||
|
* Added `simpleCudaGraphs`. Demonstrates CUDA Graphs creation, instantiation and launch using Graphs APIs and Stream Capture APIs.
|
||||||
|
* Added `conjugateGradientCudaGraphs`. Demonstrates conjugate gradient solver on GPU using CUBLAS and CUSPARSE library calls captured and called using CUDA Graph APIs.
|
||||||
|
* Added `simpleVulkan`. Demonstrates Vulkan - CUDA Interop.
|
||||||
|
* Added `simpleD3D12`. Demonstrates DX12 - CUDA Interop.
|
||||||
|
* Added `UnifiedMemoryPerf`. Demonstrates performance comparision of various memory types involved in system.
|
||||||
|
* Added `p2pBandwidthLatencyTest`. Demonstrates Peer-To-Peer (P2P) data transfers between pairs of GPUs and computes latency and bandwidth.
|
||||||
|
* Added `systemWideAtomics`. Demonstrates system wide atomic instructions.
|
||||||
|
* Added `simpleCUBLASXT`. Demonstrates CUBLAS-XT library which performs GEMM operations over multiple GPUs.
|
||||||
|
* Added Windows OS support to `conjugateGradientMultiDeviceCG` sample.
|
||||||
|
* Removed support of Visual Studio 2010 from all samples.
|
||||||
|
|
||||||
|
### CUDA 9.2
|
||||||
|
|
||||||
|
This is the first release of CUDA Samples on GitHub:
|
||||||
|
* Added `vectorAdd_nvrtc`. Demonstrates runtime compilation library using NVRTC of a simple vectorAdd kernel.
|
||||||
|
* Added `warpAggregatedAtomicsCG`. Demonstrates warp aggregated atomics using Cooperative Groups.
|
||||||
|
* Added `deviceQuery`. Enumerates the properties of the CUDA devices present in the system.
|
||||||
|
* Added `matrixMul`. Demonstrates a matrix multiplication using shared memory through tiled approach.
|
||||||
|
* Added `matrixMulDrv`. Demonstrates a matrix multiplication using shared memory through tiled approach, uses CUDA Driver API.
|
||||||
|
* Added `cudaTensorCoreGemm`. Demonstrates a GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API introduced in CUDA 9, as well as the new Tensor Cores introduced in the Volta chip family.
|
||||||
|
* Added `simpleVoteIntrinsics` which uses *_sync equivalent of the vote intrinsics _any, _all added since CUDA 9.0.
|
||||||
|
* Added `shfl_scan` which uses *_sync equivalent of the shfl intrinsics added since CUDA 9.0.
|
||||||
|
* Added `conjugateGradientMultiBlockCG`. Demonstrates a conjugate gradient solver on GPU using Multi Block Cooperative Groups.
|
||||||
|
* Added `conjugateGradientMultiDeviceCG`. Demonstrates a conjugate gradient solver on multiple GPUs using Multi Device Cooperative Groups, also uses unified memory prefetching and usage hints APIs.
|
||||||
|
* Added `simpleCUBLAS`. Demonstrates how perform GEMM operations using CUBLAS library.
|
||||||
|
* Added `simpleCUFFT`. Demonstrates how perform FFT operations using CUFFT library.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.8](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
Download and install the [CUDA Toolkit 11.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
For system requirements and installation instructions of cuda toolkit, please refer to the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/), and the [Windows Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html).
|
For system requirements and installation instructions of cuda toolkit, please refer to the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/), and the [Windows Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html).
|
||||||
|
|
||||||
### Getting the CUDA Samples
|
### Getting the CUDA Samples
|
||||||
@@ -28,131 +138,147 @@ Without using git the easiest way to use these samples is to download the zip fi
|
|||||||
|
|
||||||
## Building CUDA Samples
|
## Building CUDA Samples
|
||||||
|
|
||||||
### Building CUDA Samples
|
|
||||||
|
|
||||||
The CUDA Samples are built using CMake. Follow the instructions below for building on Linux, Windows, and for cross-compilation to Tegra devices.
|
|
||||||
|
|
||||||
### Linux
|
|
||||||
|
|
||||||
Ensure that CMake (version 3.20 or later) is installed. Install it using your package manager if necessary:
|
|
||||||
|
|
||||||
e.g.
|
|
||||||
```sudo apt install cmake```
|
|
||||||
|
|
||||||
Navigate to the root of the cloned repository and create a build directory:
|
|
||||||
```
|
|
||||||
mkdir build && cd build
|
|
||||||
```
|
|
||||||
Configure the project with CMake:
|
|
||||||
```
|
|
||||||
cmake ..
|
|
||||||
```
|
|
||||||
Build the samples:
|
|
||||||
```
|
|
||||||
make -j$(nproc)
|
|
||||||
```
|
|
||||||
Run the samples from their respective directories in the build folder. You can also follow this process from and subdirectory of the samples repo, or from within any individual sample.
|
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
Language services for CMake are available in Visual Studio 2019 version 16.5 or later, and you can directly import the CUDA samples repository from either the root level or from any
|
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
||||||
subdirectory or individual sample.
|
|
||||||
|
|
||||||
To build from the command line, open the `x64 Native Tools Command Prompt for VS` provided with your Visual Studio installation.
|
|
||||||
|
|
||||||
Navigate to the root of the cloned repository and create a build directory:
|
|
||||||
```
|
```
|
||||||
mkdir build && cd build
|
*_vs<version>.sln - for Visual Studio <version>
|
||||||
```
|
```
|
||||||
Configure the project with CMake - for example:
|
Complete samples solution files exist at parent directory of the repo:
|
||||||
|
|
||||||
|
Each individual sample has its own set of solution files at:
|
||||||
|
`<CUDA_SAMPLES_REPO>\Samples\<sample_dir>\`
|
||||||
|
|
||||||
|
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
||||||
```
|
```
|
||||||
cmake .. -G "Visual Studio 16 2019" -A x64
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
```
|
```
|
||||||
Open the generated solution file CUDA_Samples.sln in Visual Studio. Build the samples by selecting the desired configuration (e.g., Debug or Release) and pressing F7 (Build Solution).
|
The samples makefiles can take advantage of certain options:
|
||||||
|
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
|
||||||
|
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
||||||
|
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
||||||
|
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details on cross platform compilation of cuda samples.
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
||||||
|
```
|
||||||
|
$ make SMS="50 60"
|
||||||
|
```
|
||||||
|
|
||||||
Run the samples from the output directories specified in Visual Studio.
|
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
### Platform-Specific Samples
|
$ make HOST_COMPILER=g++
|
||||||
|
```
|
||||||
Some CUDA samples are specific to certain platforms, and require passing flags into CMake to enable. In particular, we define the following platform-specific flags:
|
|
||||||
|
|
||||||
* `BUILD_TEGRA` - for Tegra-specific samples
|
|
||||||
|
|
||||||
To build these samples, set the variables either on the command line or through your CMake GUI. For example:
|
|
||||||
|
|
||||||
```
|
|
||||||
cmake -DBUILD_TEGRA=True ..
|
|
||||||
```
|
|
||||||
|
|
||||||
### Cross-Compilation for Tegra Platforms
|
|
||||||
|
|
||||||
Install the NVIDIA toolchain and cross-compilation environment for Tegra devices as described in the Tegra Development Guide.
|
|
||||||
|
|
||||||
Ensure that CMake (version 3.20 or later) is installed.
|
|
||||||
|
|
||||||
Navigate to the root of the cloned repository and create a build directory:
|
|
||||||
```
|
|
||||||
mkdir build && cd build
|
|
||||||
```
|
|
||||||
Configure the project with CMake, specifying the Tegra toolchain file:
|
|
||||||
```
|
|
||||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/tegra/toolchain.cmake
|
|
||||||
```
|
|
||||||
Build the samples:
|
|
||||||
```
|
|
||||||
make -j$(nproc)
|
|
||||||
```
|
|
||||||
Transfer the built binaries to the Tegra device and execute them there.
|
|
||||||
|
|
||||||
### Building for Automotive Linux Platforms
|
|
||||||
|
|
||||||
These platforms require additional information to be passed to CMake on the command line to ensure proper resolution of all necessary include and library files.
|
|
||||||
Instead of being in the default location, `/usr/local/cuda/include` or `/usr/local/cuda/lib64`, you must point to architecture-specific paths:
|
|
||||||
|
|
||||||
`/usr/local/cuda/<ARCH>/targets/aarch64-linux/lib`
|
|
||||||
and
|
|
||||||
`/usr/local/cuda-12.8/<ARCH>/include`
|
|
||||||
|
|
||||||
An example build might look like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ mkdir build
|
|
||||||
$ cd build
|
|
||||||
|
|
||||||
$ cmake -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DCMAKE_LIBRARY_PATH=/usr/local/cuda/orin/lib64/ -DCMAKE_INCLUDE_PATH=/usr/local/cuda/orin/include -DBUILD_TEGRA=True ..
|
|
||||||
```
|
|
||||||
|
|
||||||
### QNX
|
|
||||||
|
|
||||||
Note that in the current branch sample cross-compilation for QNX is not fully validated. This placeholder will be updated in the
|
|
||||||
near future with QNX cross-compilation instructions. In the meantime, if you want to cross-compile for QNX please check out one
|
|
||||||
of the previous tags prior to the CMake build system transition in 12.8.
|
|
||||||
|
|
||||||
## Samples list
|
## Samples list
|
||||||
|
|
||||||
### [0. Introduction](./Samples/0_Introduction/README.md)
|
### Samples by OS
|
||||||
Basic CUDA samples for beginners that illustrate key concepts with using CUDA and CUDA runtime APIs.
|
|
||||||
|
|
||||||
### [1. Utilities](./Samples/1_Utilities/README.md)
|
#### Linux
|
||||||
Utility samples that demonstrate how to query device capabilities and measure GPU/CPU bandwidth.
|
**[simpleAssert_nvrtc](./Samples/simpleAssert_nvrtc)** | **[vectorAdd_nvrtc](./Samples/vectorAdd_nvrtc)** | **[graphMemoryFootprint](./Samples/graphMemoryFootprint)** | **[MC_EstimatePiQ](./Samples/MC_EstimatePiQ)** |
|
||||||
|
---|---|---|---|
|
||||||
|
**[reductionMultiBlockCG](./Samples/reductionMultiBlockCG)** | **[cuDLAStandaloneMode](./Samples/cuDLAStandaloneMode)** | **[conjugateGradientPrecond](./Samples/conjugateGradientPrecond)** | **[ptxjit](./Samples/ptxjit)** |
|
||||||
|
**[threadMigration](./Samples/threadMigration)** | **[EGLStream_CUDA_CrossGPU](./Samples/EGLStream_CUDA_CrossGPU)** | **[threadFenceReduction](./Samples/threadFenceReduction)** | **[simpleAtomicIntrinsics_nvrtc](./Samples/simpleAtomicIntrinsics_nvrtc)** |
|
||||||
|
**[shfl_scan](./Samples/shfl_scan)** | **[clock](./Samples/clock)** | **[binaryPartitionCG](./Samples/binaryPartitionCG)** | **[MC_EstimatePiP](./Samples/MC_EstimatePiP)** |
|
||||||
|
**[transpose](./Samples/transpose)** | **[simpleMultiCopy](./Samples/simpleMultiCopy)** | **[cuDLAErrorReporting](./Samples/cuDLAErrorReporting)** | **[concurrentKernels](./Samples/concurrentKernels)** |
|
||||||
|
**[streamOrderedAllocationIPC](./Samples/streamOrderedAllocationIPC)** | **[UnifiedMemoryPerf](./Samples/UnifiedMemoryPerf)** | **[cppIntegration](./Samples/cppIntegration)** | **[bf16TensorCoreGemm](./Samples/bf16TensorCoreGemm)** |
|
||||||
|
**[cuSolverSp_LinearSolver](./Samples/cuSolverSp_LinearSolver)** | **[nvJPEG](./Samples/nvJPEG)** | **[watershedSegmentationNPP](./Samples/watershedSegmentationNPP)** | **[MC_EstimatePiInlineP](./Samples/MC_EstimatePiInlineP)** |
|
||||||
|
**[vulkanImageCUDA](./Samples/vulkanImageCUDA)** | **[boxFilterNPP](./Samples/boxFilterNPP)** | **[simpleAssert](./Samples/simpleAssert)** | **[simpleTemplates](./Samples/simpleTemplates)** |
|
||||||
|
**[cuHook](./Samples/cuHook)** | **[simpleCUDA2GL](./Samples/simpleCUDA2GL)** | **[matrixMul](./Samples/matrixMul)** | **[quasirandomGenerator_nvrtc](./Samples/quasirandomGenerator_nvrtc)** |
|
||||||
|
**[nvJPEG_encoder](./Samples/nvJPEG_encoder)** | **[simpleCudaGraphs](./Samples/simpleCudaGraphs)** | **[simpleTextureDrv](./Samples/simpleTextureDrv)** | **[simpleCUFFT](./Samples/simpleCUFFT)** |
|
||||||
|
**[simpleCallback](./Samples/simpleCallback)** | **[batchCUBLAS](./Samples/batchCUBLAS)** | **[cudaTensorCoreGemm](./Samples/cudaTensorCoreGemm)** | **[simpleAtomicIntrinsics](./Samples/simpleAtomicIntrinsics)** |
|
||||||
|
**[newdelete](./Samples/newdelete)** | **[bicubicTexture](./Samples/bicubicTexture)** | **[dxtc](./Samples/dxtc)** | **[cudaOpenMP](./Samples/cudaOpenMP)** |
|
||||||
|
**[cdpBezierTessellation](./Samples/cdpBezierTessellation)** | **[randomFog](./Samples/randomFog)** | **[bilateralFilter](./Samples/bilateralFilter)** | **[conjugateGradient](./Samples/conjugateGradient)** |
|
||||||
|
**[particles](./Samples/particles)** | **[NV12toBGRandResize](./Samples/NV12toBGRandResize)** | **[Mandelbrot](./Samples/Mandelbrot)** | **[binomialOptions_nvrtc](./Samples/binomialOptions_nvrtc)** |
|
||||||
|
**[cudaNvSci](./Samples/cudaNvSci)** | **[mergeSort](./Samples/mergeSort)** | **[HSOpticalFlow](./Samples/HSOpticalFlow)** | **[immaTensorCoreGemm](./Samples/immaTensorCoreGemm)** |
|
||||||
|
**[convolutionTexture](./Samples/convolutionTexture)** | **[simpleVulkan](./Samples/simpleVulkan)** | **[simpleCUBLAS](./Samples/simpleCUBLAS)** | **[jacobiCudaGraphs](./Samples/jacobiCudaGraphs)** |
|
||||||
|
**[eigenvalues](./Samples/eigenvalues)** | **[streamOrderedAllocationP2P](./Samples/streamOrderedAllocationP2P)** | **[cuSolverSp_LowlevelCholesky](./Samples/cuSolverSp_LowlevelCholesky)** | **[topologyQuery](./Samples/topologyQuery)** |
|
||||||
|
**[dmmaTensorCoreGemm](./Samples/dmmaTensorCoreGemm)** | **[volumeRender](./Samples/volumeRender)** | **[stereoDisparity](./Samples/stereoDisparity)** | **[simpleTexture](./Samples/simpleTexture)** |
|
||||||
|
**[simpleStreams](./Samples/simpleStreams)** | **[smokeParticles](./Samples/smokeParticles)** | **[simpleMultiGPU](./Samples/simpleMultiGPU)** | **[deviceQueryDrv](./Samples/deviceQueryDrv)** |
|
||||||
|
**[fastWalshTransform](./Samples/fastWalshTransform)** | **[quasirandomGenerator](./Samples/quasirandomGenerator)** | **[vectorAddMMAP](./Samples/vectorAddMMAP)** | **[MersenneTwisterGP11213](./Samples/MersenneTwisterGP11213)** |
|
||||||
|
**[conjugateGradientUM](./Samples/conjugateGradientUM)** | **[simpleVoteIntrinsics_nvrtc](./Samples/simpleVoteIntrinsics_nvrtc)** | **[simpleLayeredTexture](./Samples/simpleLayeredTexture)** | **[streamOrderedAllocation](./Samples/streamOrderedAllocation)** |
|
||||||
|
**[cuSolverDn_LinearSolver](./Samples/cuSolverDn_LinearSolver)** | **[cudaCompressibleMemory](./Samples/cudaCompressibleMemory)** | **[matrixMulCUBLAS](./Samples/matrixMulCUBLAS)** | **[histEqualizationNPP](./Samples/histEqualizationNPP)** |
|
||||||
|
**[simpleAWBarrier](./Samples/simpleAWBarrier)** | **[recursiveGaussian](./Samples/recursiveGaussian)** | **[imageDenoising](./Samples/imageDenoising)** | **[FunctionPointers](./Samples/FunctionPointers)** |
|
||||||
|
**[simpleGL](./Samples/simpleGL)** | **[segmentationTreeThrust](./Samples/segmentationTreeThrust)** | **[scalarProd](./Samples/scalarProd)** | **[SobolQRNG](./Samples/SobolQRNG)** |
|
||||||
|
**[p2pBandwidthLatencyTest](./Samples/p2pBandwidthLatencyTest)** | **[conjugateGradientCudaGraphs](./Samples/conjugateGradientCudaGraphs)** | **[simplePitchLinearTexture](./Samples/simplePitchLinearTexture)** | **[freeImageInteropNPP](./Samples/freeImageInteropNPP)** |
|
||||||
|
**[template](./Samples/template)** | **[dwtHaar1D](./Samples/dwtHaar1D)** | **[postProcessGL](./Samples/postProcessGL)** | **[BlackScholes](./Samples/BlackScholes)** |
|
||||||
|
**[volumeFiltering](./Samples/volumeFiltering)** | **[simpleCUFFT_callback](./Samples/simpleCUFFT_callback)** | **[UnifiedMemoryStreams](./Samples/UnifiedMemoryStreams)** | **[globalToShmemAsyncCopy](./Samples/globalToShmemAsyncCopy)** |
|
||||||
|
**[deviceQuery](./Samples/deviceQuery)** | **[simpleHyperQ](./Samples/simpleHyperQ)** | **[systemWideAtomics](./Samples/systemWideAtomics)** | **[cuSolverSp_LowlevelQR](./Samples/cuSolverSp_LowlevelQR)** |
|
||||||
|
**[inlinePTX](./Samples/inlinePTX)** | **[matrixMulDrv](./Samples/matrixMulDrv)** | **[EGLStream_CUDA_Interop](./Samples/EGLStream_CUDA_Interop)** | **[cuDLAHybridMode](./Samples/cuDLAHybridMode)** |
|
||||||
|
**[asyncAPI](./Samples/asyncAPI)** | **[MC_EstimatePiInlineQ](./Samples/MC_EstimatePiInlineQ)** | **[scan](./Samples/scan)** | **[simpleCooperativeGroups](./Samples/simpleCooperativeGroups)** |
|
||||||
|
**[conjugateGradientMultiBlockCG](./Samples/conjugateGradientMultiBlockCG)** | **[simpleTemplates_nvrtc](./Samples/simpleTemplates_nvrtc)** | **[simpleTexture3D](./Samples/simpleTexture3D)** | **[lineOfSight](./Samples/lineOfSight)** |
|
||||||
|
**[simpleZeroCopy](./Samples/simpleZeroCopy)** | **[binomialOptions](./Samples/binomialOptions)** | **[simpleAttributes](./Samples/simpleAttributes)** | **[bindlessTexture](./Samples/bindlessTexture)** |
|
||||||
|
**[simpleCUFFT_2d_MGPU](./Samples/simpleCUFFT_2d_MGPU)** | **[simplePrintf](./Samples/simplePrintf)** | **[batchedLabelMarkersAndLabelCompressionNPP](./Samples/batchedLabelMarkersAndLabelCompressionNPP)** | **[histogram](./Samples/histogram)** |
|
||||||
|
**[matrixMulDynlinkJIT](./Samples/matrixMulDynlinkJIT)** | **[simpleP2P](./Samples/simpleP2P)** | **[conjugateGradientMultiDeviceCG](./Samples/conjugateGradientMultiDeviceCG)** | **[vectorAddDrv](./Samples/vectorAddDrv)** |
|
||||||
|
**[sortingNetworks](./Samples/sortingNetworks)** | **[alignedTypes](./Samples/alignedTypes)** | **[inlinePTX_nvrtc](./Samples/inlinePTX_nvrtc)** | **[simpleCubemapTexture](./Samples/simpleCubemapTexture)** |
|
||||||
|
**[simpleIPC](./Samples/simpleIPC)** | **[simpleVulkanMMAP](./Samples/simpleVulkanMMAP)** | **[radixSortThrust](./Samples/radixSortThrust)** | **[MonteCarloMultiGPU](./Samples/MonteCarloMultiGPU)** |
|
||||||
|
**[cudaNvSciNvMedia](./Samples/cudaNvSciNvMedia)** | **[vectorAdd](./Samples/vectorAdd)** | **[cdpSimplePrint](./Samples/cdpSimplePrint)** | **[FilterBorderControlNPP](./Samples/FilterBorderControlNPP)** |
|
||||||
|
**[simpleVoteIntrinsics](./Samples/simpleVoteIntrinsics)** | **[convolutionSeparable](./Samples/convolutionSeparable)** | **[nbody](./Samples/nbody)** | **[simpleCUBLAS_LU](./Samples/simpleCUBLAS_LU)** |
|
||||||
|
**[simpleSeparateCompilation](./Samples/simpleSeparateCompilation)** | **[c++11_cuda](./Samples/c++11_cuda)** | **[fluidsGL](./Samples/fluidsGL)** | **[bandwidthTest](./Samples/bandwidthTest)** |
|
||||||
|
**[clock_nvrtc](./Samples/clock_nvrtc)** | **[graphMemoryNodes](./Samples/graphMemoryNodes)** | **[cdpQuadtree](./Samples/cdpQuadtree)** | **[interval](./Samples/interval)** |
|
||||||
|
**[boxFilter](./Samples/boxFilter)** | **[matrixMul_nvrtc](./Samples/matrixMul_nvrtc)** | **[simpleCUBLASXT](./Samples/simpleCUBLASXT)** | **[cppOverload](./Samples/cppOverload)** |
|
||||||
|
**[marchingCubes](./Samples/marchingCubes)** | **[cuSolverRf](./Samples/cuSolverRf)** | **[BlackScholes_nvrtc](./Samples/BlackScholes_nvrtc)** | **[cdpAdvancedQuicksort](./Samples/cdpAdvancedQuicksort)** |
|
||||||
|
**[tf32TensorCoreGemm](./Samples/tf32TensorCoreGemm)** | **[cdpSimpleQuicksort](./Samples/cdpSimpleQuicksort)** | **[simpleOccupancy](./Samples/simpleOccupancy)** | **[simpleSurfaceWrite](./Samples/simpleSurfaceWrite)** |
|
||||||
|
**[simpleCUFFT_MGPU](./Samples/simpleCUFFT_MGPU)** | **[simpleDrvRuntime](./Samples/simpleDrvRuntime)** | **[convolutionFFT2D](./Samples/convolutionFFT2D)** | **[reduction](./Samples/reduction)** |
|
||||||
|
**[memMapIPCDrv](./Samples/memMapIPCDrv)** | **[SobelFilter](./Samples/SobelFilter)** | **[dct8x8](./Samples/dct8x8)** | **[fp16ScalarProduct](./Samples/fp16ScalarProduct)** |
|
||||||
|
**[FDTD3d](./Samples/FDTD3d)** | **[oceanFFT](./Samples/oceanFFT)** | **[warpAggregatedAtomicsCG](./Samples/warpAggregatedAtomicsCG)** | **[StreamPriorities](./Samples/StreamPriorities)** |
|
||||||
|
**[cannyEdgeDetectorNPP](./Samples/cannyEdgeDetectorNPP)** | **[MC_SingleAsianOptionP](./Samples/MC_SingleAsianOptionP)** | **[simpleMPI](./Samples/simpleMPI)** |
|
||||||
|
|
||||||
### [2. Concepts and Techniques](./Samples/2_Concepts_and_Techniques/README.md)
|
#### Windows
|
||||||
Samples that demonstrate CUDA related concepts and common problem solving techniques.
|
**[simpleAssert_nvrtc](./Samples/simpleAssert_nvrtc)** | **[vectorAdd_nvrtc](./Samples/vectorAdd_nvrtc)** | **[graphMemoryFootprint](./Samples/graphMemoryFootprint)** | **[MC_EstimatePiQ](./Samples/MC_EstimatePiQ)** |
|
||||||
|
---|---|---|---|
|
||||||
### [3. CUDA Features](./Samples/3_CUDA_Features/README.md)
|
**[reductionMultiBlockCG](./Samples/reductionMultiBlockCG)** | **[conjugateGradientPrecond](./Samples/conjugateGradientPrecond)** | **[ptxjit](./Samples/ptxjit)** | **[threadMigration](./Samples/threadMigration)** |
|
||||||
Samples that demonstrate CUDA Features (Cooperative Groups, CUDA Dynamic Parallelism, CUDA Graphs etc).
|
**[threadFenceReduction](./Samples/threadFenceReduction)** | **[simpleAtomicIntrinsics_nvrtc](./Samples/simpleAtomicIntrinsics_nvrtc)** | **[shfl_scan](./Samples/shfl_scan)** | **[clock](./Samples/clock)** |
|
||||||
|
**[binaryPartitionCG](./Samples/binaryPartitionCG)** | **[MC_EstimatePiP](./Samples/MC_EstimatePiP)** | **[transpose](./Samples/transpose)** | **[simpleMultiCopy](./Samples/simpleMultiCopy)** |
|
||||||
### [4. CUDA Libraries](./Samples/4_CUDA_Libraries/README.md)
|
**[concurrentKernels](./Samples/concurrentKernels)** | **[UnifiedMemoryPerf](./Samples/UnifiedMemoryPerf)** | **[cppIntegration](./Samples/cppIntegration)** | **[bf16TensorCoreGemm](./Samples/bf16TensorCoreGemm)** |
|
||||||
Samples that demonstrate how to use CUDA platform libraries (NPP, NVJPEG, NVGRAPH cuBLAS, cuFFT, cuSPARSE, cuSOLVER and cuRAND).
|
**[cuSolverSp_LinearSolver](./Samples/cuSolverSp_LinearSolver)** | **[nvJPEG](./Samples/nvJPEG)** | **[watershedSegmentationNPP](./Samples/watershedSegmentationNPP)** | **[MC_EstimatePiInlineP](./Samples/MC_EstimatePiInlineP)** |
|
||||||
|
**[simpleD3D10](./Samples/simpleD3D10)** | **[vulkanImageCUDA](./Samples/vulkanImageCUDA)** | **[fluidsD3D9](./Samples/fluidsD3D9)** | **[boxFilterNPP](./Samples/boxFilterNPP)** |
|
||||||
### [5. Domain Specific](./Samples/5_Domain_Specific/README.md)
|
**[simpleAssert](./Samples/simpleAssert)** | **[simpleTemplates](./Samples/simpleTemplates)** | **[simpleCUDA2GL](./Samples/simpleCUDA2GL)** | **[matrixMul](./Samples/matrixMul)** |
|
||||||
Samples that are specific to domain (Graphics, Finance, Image Processing).
|
**[quasirandomGenerator_nvrtc](./Samples/quasirandomGenerator_nvrtc)** | **[nvJPEG_encoder](./Samples/nvJPEG_encoder)** | **[simpleCudaGraphs](./Samples/simpleCudaGraphs)** | **[simpleTextureDrv](./Samples/simpleTextureDrv)** |
|
||||||
|
**[simpleCUFFT](./Samples/simpleCUFFT)** | **[simpleCallback](./Samples/simpleCallback)** | **[SLID3D10Texture](./Samples/SLID3D10Texture)** | **[batchCUBLAS](./Samples/batchCUBLAS)** |
|
||||||
### [6. Performance](./Samples/6_Performance/README.md)
|
**[cudaTensorCoreGemm](./Samples/cudaTensorCoreGemm)** | **[simpleAtomicIntrinsics](./Samples/simpleAtomicIntrinsics)** | **[newdelete](./Samples/newdelete)** | **[bicubicTexture](./Samples/bicubicTexture)** |
|
||||||
Samples that demonstrate performance optimization.
|
**[dxtc](./Samples/dxtc)** | **[cudaOpenMP](./Samples/cudaOpenMP)** | **[cdpBezierTessellation](./Samples/cdpBezierTessellation)** | **[randomFog](./Samples/randomFog)** |
|
||||||
|
**[bilateralFilter](./Samples/bilateralFilter)** | **[conjugateGradient](./Samples/conjugateGradient)** | **[particles](./Samples/particles)** | **[NV12toBGRandResize](./Samples/NV12toBGRandResize)** |
|
||||||
### [7. libNVVM](./Samples/7_libNVVM/README.md)
|
**[Mandelbrot](./Samples/Mandelbrot)** | **[binomialOptions_nvrtc](./Samples/binomialOptions_nvrtc)** | **[simpleD3D10RenderTarget](./Samples/simpleD3D10RenderTarget)** | **[mergeSort](./Samples/mergeSort)** |
|
||||||
Samples that demonstrate the use of libNVVVM and NVVM IR.
|
**[HSOpticalFlow](./Samples/HSOpticalFlow)** | **[immaTensorCoreGemm](./Samples/immaTensorCoreGemm)** | **[convolutionTexture](./Samples/convolutionTexture)** | **[simpleVulkan](./Samples/simpleVulkan)** |
|
||||||
|
**[simpleD3D9Texture](./Samples/simpleD3D9Texture)** | **[simpleCUBLAS](./Samples/simpleCUBLAS)** | **[jacobiCudaGraphs](./Samples/jacobiCudaGraphs)** | **[eigenvalues](./Samples/eigenvalues)** |
|
||||||
|
**[simpleD3D10Texture](./Samples/simpleD3D10Texture)** | **[streamOrderedAllocationP2P](./Samples/streamOrderedAllocationP2P)** | **[cuSolverSp_LowlevelCholesky](./Samples/cuSolverSp_LowlevelCholesky)** | **[topologyQuery](./Samples/topologyQuery)** |
|
||||||
|
**[dmmaTensorCoreGemm](./Samples/dmmaTensorCoreGemm)** | **[volumeRender](./Samples/volumeRender)** | **[stereoDisparity](./Samples/stereoDisparity)** | **[simpleTexture](./Samples/simpleTexture)** |
|
||||||
|
**[simpleStreams](./Samples/simpleStreams)** | **[smokeParticles](./Samples/smokeParticles)** | **[simpleMultiGPU](./Samples/simpleMultiGPU)** | **[deviceQueryDrv](./Samples/deviceQueryDrv)** |
|
||||||
|
**[fastWalshTransform](./Samples/fastWalshTransform)** | **[quasirandomGenerator](./Samples/quasirandomGenerator)** | **[vectorAddMMAP](./Samples/vectorAddMMAP)** | **[MersenneTwisterGP11213](./Samples/MersenneTwisterGP11213)** |
|
||||||
|
**[conjugateGradientUM](./Samples/conjugateGradientUM)** | **[simpleVoteIntrinsics_nvrtc](./Samples/simpleVoteIntrinsics_nvrtc)** | **[simpleLayeredTexture](./Samples/simpleLayeredTexture)** | **[streamOrderedAllocation](./Samples/streamOrderedAllocation)** |
|
||||||
|
**[cuSolverDn_LinearSolver](./Samples/cuSolverDn_LinearSolver)** | **[cudaCompressibleMemory](./Samples/cudaCompressibleMemory)** | **[matrixMulCUBLAS](./Samples/matrixMulCUBLAS)** | **[histEqualizationNPP](./Samples/histEqualizationNPP)** |
|
||||||
|
**[simpleAWBarrier](./Samples/simpleAWBarrier)** | **[recursiveGaussian](./Samples/recursiveGaussian)** | **[imageDenoising](./Samples/imageDenoising)** | **[FunctionPointers](./Samples/FunctionPointers)** |
|
||||||
|
**[simpleGL](./Samples/simpleGL)** | **[segmentationTreeThrust](./Samples/segmentationTreeThrust)** | **[scalarProd](./Samples/scalarProd)** | **[SobolQRNG](./Samples/SobolQRNG)** |
|
||||||
|
**[p2pBandwidthLatencyTest](./Samples/p2pBandwidthLatencyTest)** | **[conjugateGradientCudaGraphs](./Samples/conjugateGradientCudaGraphs)** | **[simplePitchLinearTexture](./Samples/simplePitchLinearTexture)** | **[freeImageInteropNPP](./Samples/freeImageInteropNPP)** |
|
||||||
|
**[template](./Samples/template)** | **[dwtHaar1D](./Samples/dwtHaar1D)** | **[simpleD3D11Texture](./Samples/simpleD3D11Texture)** | **[postProcessGL](./Samples/postProcessGL)** |
|
||||||
|
**[BlackScholes](./Samples/BlackScholes)** | **[simpleD3D11](./Samples/simpleD3D11)** | **[volumeFiltering](./Samples/volumeFiltering)** | **[UnifiedMemoryStreams](./Samples/UnifiedMemoryStreams)** |
|
||||||
|
**[globalToShmemAsyncCopy](./Samples/globalToShmemAsyncCopy)** | **[deviceQuery](./Samples/deviceQuery)** | **[simpleHyperQ](./Samples/simpleHyperQ)** | **[cuSolverSp_LowlevelQR](./Samples/cuSolverSp_LowlevelQR)** |
|
||||||
|
**[inlinePTX](./Samples/inlinePTX)** | **[matrixMulDrv](./Samples/matrixMulDrv)** | **[asyncAPI](./Samples/asyncAPI)** | **[MC_EstimatePiInlineQ](./Samples/MC_EstimatePiInlineQ)** |
|
||||||
|
**[scan](./Samples/scan)** | **[simpleCooperativeGroups](./Samples/simpleCooperativeGroups)** | **[conjugateGradientMultiBlockCG](./Samples/conjugateGradientMultiBlockCG)** | **[simpleTemplates_nvrtc](./Samples/simpleTemplates_nvrtc)** |
|
||||||
|
**[simpleTexture3D](./Samples/simpleTexture3D)** | **[lineOfSight](./Samples/lineOfSight)** | **[simpleZeroCopy](./Samples/simpleZeroCopy)** | **[binomialOptions](./Samples/binomialOptions)** |
|
||||||
|
**[simpleAttributes](./Samples/simpleAttributes)** | **[bindlessTexture](./Samples/bindlessTexture)** | **[simpleD3D12](./Samples/simpleD3D12)** | **[simpleCUFFT_2d_MGPU](./Samples/simpleCUFFT_2d_MGPU)** |
|
||||||
|
**[simplePrintf](./Samples/simplePrintf)** | **[batchedLabelMarkersAndLabelCompressionNPP](./Samples/batchedLabelMarkersAndLabelCompressionNPP)** | **[histogram](./Samples/histogram)** | **[matrixMulDynlinkJIT](./Samples/matrixMulDynlinkJIT)** |
|
||||||
|
**[simpleP2P](./Samples/simpleP2P)** | **[conjugateGradientMultiDeviceCG](./Samples/conjugateGradientMultiDeviceCG)** | **[vectorAddDrv](./Samples/vectorAddDrv)** | **[sortingNetworks](./Samples/sortingNetworks)** |
|
||||||
|
**[alignedTypes](./Samples/alignedTypes)** | **[inlinePTX_nvrtc](./Samples/inlinePTX_nvrtc)** | **[simpleCubemapTexture](./Samples/simpleCubemapTexture)** | **[simpleIPC](./Samples/simpleIPC)** |
|
||||||
|
**[simpleVulkanMMAP](./Samples/simpleVulkanMMAP)** | **[radixSortThrust](./Samples/radixSortThrust)** | **[MonteCarloMultiGPU](./Samples/MonteCarloMultiGPU)** | **[vectorAdd](./Samples/vectorAdd)** |
|
||||||
|
**[VFlockingD3D10](./Samples/VFlockingD3D10)** | **[simpleD3D9](./Samples/simpleD3D9)** | **[cdpSimplePrint](./Samples/cdpSimplePrint)** | **[FilterBorderControlNPP](./Samples/FilterBorderControlNPP)** |
|
||||||
|
**[simpleVoteIntrinsics](./Samples/simpleVoteIntrinsics)** | **[convolutionSeparable](./Samples/convolutionSeparable)** | **[nbody](./Samples/nbody)** | **[simpleCUBLAS_LU](./Samples/simpleCUBLAS_LU)** |
|
||||||
|
**[simpleSeparateCompilation](./Samples/simpleSeparateCompilation)** | **[c++11_cuda](./Samples/c++11_cuda)** | **[fluidsGL](./Samples/fluidsGL)** | **[bandwidthTest](./Samples/bandwidthTest)** |
|
||||||
|
**[clock_nvrtc](./Samples/clock_nvrtc)** | **[graphMemoryNodes](./Samples/graphMemoryNodes)** | **[cdpQuadtree](./Samples/cdpQuadtree)** | **[interval](./Samples/interval)** |
|
||||||
|
**[boxFilter](./Samples/boxFilter)** | **[matrixMul_nvrtc](./Samples/matrixMul_nvrtc)** | **[simpleCUBLASXT](./Samples/simpleCUBLASXT)** | **[cppOverload](./Samples/cppOverload)** |
|
||||||
|
**[marchingCubes](./Samples/marchingCubes)** | **[cuSolverRf](./Samples/cuSolverRf)** | **[BlackScholes_nvrtc](./Samples/BlackScholes_nvrtc)** | **[cdpAdvancedQuicksort](./Samples/cdpAdvancedQuicksort)** |
|
||||||
|
**[tf32TensorCoreGemm](./Samples/tf32TensorCoreGemm)** | **[cdpSimpleQuicksort](./Samples/cdpSimpleQuicksort)** | **[simpleOccupancy](./Samples/simpleOccupancy)** | **[simpleSurfaceWrite](./Samples/simpleSurfaceWrite)** |
|
||||||
|
**[simpleCUFFT_MGPU](./Samples/simpleCUFFT_MGPU)** | **[simpleDrvRuntime](./Samples/simpleDrvRuntime)** | **[convolutionFFT2D](./Samples/convolutionFFT2D)** | **[reduction](./Samples/reduction)** |
|
||||||
|
**[memMapIPCDrv](./Samples/memMapIPCDrv)** | **[SobelFilter](./Samples/SobelFilter)** | **[dct8x8](./Samples/dct8x8)** | **[fp16ScalarProduct](./Samples/fp16ScalarProduct)** |
|
||||||
|
**[FDTD3d](./Samples/FDTD3d)** | **[oceanFFT](./Samples/oceanFFT)** | **[warpAggregatedAtomicsCG](./Samples/warpAggregatedAtomicsCG)** | **[cannyEdgeDetectorNPP](./Samples/cannyEdgeDetectorNPP)** |
|
||||||
|
**[MC_SingleAsianOptionP](./Samples/MC_SingleAsianOptionP)** | **[simpleMPI](./Samples/simpleMPI)** |
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
@@ -170,7 +296,7 @@ These third-party dependencies are required by some CUDA samples. If available,
|
|||||||
|
|
||||||
FreeImage is an open source imaging library. FreeImage can usually be installed on Linux using your distribution's package manager system. FreeImage can also be downloaded from the FreeImage website.
|
FreeImage is an open source imaging library. FreeImage can usually be installed on Linux using your distribution's package manager system. FreeImage can also be downloaded from the FreeImage website.
|
||||||
|
|
||||||
To set up FreeImage on a Windows system, extract the FreeImage DLL distribution into the folder `../../../Common/FreeImage/Dist/x64` such that it contains the .h and .lib files. Copy the .dll file to the Release/ Debug/ execution folder or pass the FreeImage folder when cmake configuring with the `-DFREEIMAGE_INCLUDE_DIR` and `-DFREEIMAGE_LIBRARY` options.
|
To set up FreeImage on a Windows system, extract the FreeImage DLL distribution into the folder `../../Common/FreeImage/Dist/x64` such that it contains the .h, .dll, and .lib files.
|
||||||
|
|
||||||
#### Message Passing Interface
|
#### Message Passing Interface
|
||||||
|
|
||||||
@@ -200,11 +326,6 @@ OpenGL ES is an embedded systems graphics library used for 2D and 3D rendering.
|
|||||||
|
|
||||||
Vulkan is a low-overhead, cross-platform 3D graphics and compute API. Vulkan targets high-performance realtime 3D graphics applications such as video games and interactive media across all platforms. On systems which support Vulkan, NVIDIA's Vulkan implementation is provided with the CUDA Driver. For building and running Vulkan applications one needs to install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/).
|
Vulkan is a low-overhead, cross-platform 3D graphics and compute API. Vulkan targets high-performance realtime 3D graphics applications such as video games and interactive media across all platforms. On systems which support Vulkan, NVIDIA's Vulkan implementation is provided with the CUDA Driver. For building and running Vulkan applications one needs to install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/).
|
||||||
|
|
||||||
#### GLFW
|
|
||||||
GLFW is a lightweight, open-source library designed for managing OpenGL, OpenGL ES, and Vulkan contexts. It simplifies the process of creating and managing windows, handling user input (keyboard, mouse, and joystick), and working with multiple monitors in a cross-platform manner.
|
|
||||||
|
|
||||||
To set up GLFW on a Windows system, Download the pre-built binaries from [GLFW website](https://www.glfw.org/download.html) and extract the zip file into the folder, pass the GLFW include header as `-DGLFW_INCLUDE_DIR` for cmake configuring and follow the Build_instructions.txt in the sample folder to set up the t.
|
|
||||||
|
|
||||||
#### OpenMP
|
#### OpenMP
|
||||||
|
|
||||||
OpenMP is an API for multiprocessing programming. OpenMP can be installed using your Linux distribution's package manager system. It usually comes preinstalled with GCC. It can also be found at the [OpenMP website](http://openmp.org/).
|
OpenMP is an API for multiprocessing programming. OpenMP can be installed using your Linux distribution's package manager system. It usually comes preinstalled with GCC. It can also be found at the [OpenMP website](http://openmp.org/).
|
||||||
@@ -313,10 +434,6 @@ FP16 is a 16-bit floating-point format. One bit is used for the sign, five bits
|
|||||||
|
|
||||||
NVCC support of [C++11 features](https://en.wikipedia.org/wiki/C++11).
|
NVCC support of [C++11 features](https://en.wikipedia.org/wiki/C++11).
|
||||||
|
|
||||||
#### CMake
|
|
||||||
|
|
||||||
The libNVVM samples are built using [CMake](https://cmake.org/) 3.10 or later.
|
|
||||||
|
|
||||||
## Contributors Guide
|
## Contributors Guide
|
||||||
|
|
||||||
We welcome your input on issues and suggestions for samples. At this time we are not accepting contributions from the public, check back here as we evolve our contribution model.
|
We welcome your input on issues and suggestions for samples. At this time we are not accepting contributions from the public, check back here as we evolve our contribution model.
|
||||||
@@ -332,6 +449,3 @@ Answers to frequently asked questions about CUDA can be found at http://develope
|
|||||||
* [CUDA Programming Guide](http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html)
|
* [CUDA Programming Guide](http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html)
|
||||||
* [Accelerated Computing Blog](https://developer.nvidia.com/blog/?tags=accelerated-computing)
|
* [Accelerated Computing Blog](https://developer.nvidia.com/blog/?tags=accelerated-computing)
|
||||||
|
|
||||||
## Attributions
|
|
||||||
|
|
||||||
* Teapot image is obtained from [Wikimedia](https://en.wikipedia.org/wiki/File:Original_Utah_Teapot.jpg) and is licensed under the Creative Commons [Attribution-Share Alike 2.0](https://creativecommons.org/licenses/by-sa/2.0/deed.en) Generic license. The image is modified for samples use cases.
|
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(simpleCallback LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(UnifiedMemoryStreams)
|
|
||||||
add_subdirectory(asyncAPI)
|
|
||||||
add_subdirectory(clock)
|
|
||||||
add_subdirectory(clock_nvrtc)
|
|
||||||
add_subdirectory(cudaOpenMP)
|
|
||||||
add_subdirectory(fp16ScalarProduct)
|
|
||||||
add_subdirectory(matrixMul)
|
|
||||||
add_subdirectory(matrixMulDrv)
|
|
||||||
add_subdirectory(matrixMulDynlinkJIT)
|
|
||||||
add_subdirectory(matrixMul_nvrtc)
|
|
||||||
add_subdirectory(mergeSort)
|
|
||||||
add_subdirectory(simpleAWBarrier)
|
|
||||||
add_subdirectory(simpleAssert)
|
|
||||||
add_subdirectory(simpleAssert_nvrtc)
|
|
||||||
add_subdirectory(simpleAtomicIntrinsics)
|
|
||||||
add_subdirectory(simpleAtomicIntrinsics_nvrtc)
|
|
||||||
add_subdirectory(simpleAttributes)
|
|
||||||
add_subdirectory(simpleCUDA2GL)
|
|
||||||
add_subdirectory(simpleCallback)
|
|
||||||
add_subdirectory(simpleCooperativeGroups)
|
|
||||||
add_subdirectory(simpleCubemapTexture)
|
|
||||||
add_subdirectory(simpleDrvRuntime)
|
|
||||||
add_subdirectory(simpleHyperQ)
|
|
||||||
add_subdirectory(simpleIPC)
|
|
||||||
add_subdirectory(simpleLayeredTexture)
|
|
||||||
add_subdirectory(simpleMPI)
|
|
||||||
add_subdirectory(simpleMultiCopy)
|
|
||||||
add_subdirectory(simpleMultiGPU)
|
|
||||||
add_subdirectory(simpleOccupancy)
|
|
||||||
add_subdirectory(simpleP2P)
|
|
||||||
add_subdirectory(simplePitchLinearTexture)
|
|
||||||
add_subdirectory(simplePrintf)
|
|
||||||
add_subdirectory(simpleStreams)
|
|
||||||
add_subdirectory(simpleSurfaceWrite)
|
|
||||||
add_subdirectory(simpleTemplates)
|
|
||||||
add_subdirectory(simpleTexture)
|
|
||||||
add_subdirectory(simpleTexture3D)
|
|
||||||
add_subdirectory(simpleTextureDrv)
|
|
||||||
add_subdirectory(simpleVoteIntrinsics)
|
|
||||||
add_subdirectory(simpleZeroCopy)
|
|
||||||
add_subdirectory(systemWideAtomics)
|
|
||||||
add_subdirectory(vectorAdd)
|
|
||||||
add_subdirectory(vectorAddDrv)
|
|
||||||
add_subdirectory(vectorAddMMAP)
|
|
||||||
add_subdirectory(vectorAdd_nvrtc)
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
# 0. Introduction
|
|
||||||
|
|
||||||
|
|
||||||
### [asyncAPI](./asyncAPI)
|
|
||||||
This sample illustrates the usage of CUDA events for both GPU timing and overlapping CPU and GPU execution. Events are inserted into a stream of CUDA calls. Since CUDA stream calls are asynchronous, the CPU can perform computations while GPU is executing (including DMA memcopies between the host and device). CPU can query CUDA events to determine whether GPU has completed tasks.
|
|
||||||
|
|
||||||
### [clock](./clock)
|
|
||||||
This example shows how to use the clock function to measure the performance of block of threads of a kernel accurately.
|
|
||||||
|
|
||||||
### [clock_nvrtc](./clock_nvrtc)
|
|
||||||
This example shows how to use the clock function using libNVRTC to measure the performance of block of threads of a kernel accurately.
|
|
||||||
|
|
||||||
### [cudaOpenMP](./cudaOpenMP)
|
|
||||||
This sample demonstrates how to use OpenMP API to write an application for multiple GPUs.
|
|
||||||
|
|
||||||
### [fp16ScalarProduct](./fp16ScalarProduct)
|
|
||||||
Calculates scalar product of two vectors of FP16 numbers.
|
|
||||||
|
|
||||||
### [matrixMul](./matrixMul)
|
|
||||||
This sample implements matrix multiplication and is exactly the same as Chapter 6 of the programming guide. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. To illustrate GPU performance for matrix multiply, this sample also shows how to use the new CUDA 4.0 interface for CUBLAS to demonstrate high-performance performance for matrix multiplication.
|
|
||||||
|
|
||||||
### [matrixMul_nvrtc](./matrixMul_nvrtc)
|
|
||||||
This sample implements matrix multiplication and is exactly the same as Chapter 6 of the programming guide. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. To illustrate GPU performance for matrix multiply, this sample also shows how to use the new CUDA 4.0 interface for CUBLAS to demonstrate high-performance performance for matrix multiplication.
|
|
||||||
|
|
||||||
### [matrixMulDrv](./matrixMulDrv)
|
|
||||||
This sample implements matrix multiplication and uses the new CUDA 4.0 kernel launch Driver API. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. CUBLAS provides high-performance matrix multiplication.
|
|
||||||
|
|
||||||
### [matrixMulDynlinkJIT](./matrixMulDynlinkJIT)
|
|
||||||
This sample revisits matrix multiplication using the CUDA driver API. It demonstrates how to link to CUDA driver at runtime and how to use JIT (just-in-time) compilation from PTX code. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. CUBLAS provides high-performance matrix multiplication.
|
|
||||||
|
|
||||||
### [mergeSort](./mergeSort)
|
|
||||||
This sample implements a merge sort (also known as Batcher's sort), algorithms belonging to the class of sorting networks. While generally subefficient on large sequences compared to algorithms with better asymptotic algorithmic complexity (i.e. merge sort or radix sort), may be the algorithms of choice for sorting batches of short- to mid-sized (key, value) array pairs. Refer to the excellent tutorial by H. W. Lang http://www.iti.fh-flensburg.de/lang/algorithmen/sortieren/networks/indexen.htm
|
|
||||||
|
|
||||||
### [simpleAssert](./simpleAssert)
|
|
||||||
This CUDA Runtime API sample is a very basic sample that implements how to use the assert function in the device code. Requires Compute Capability 2.0 .
|
|
||||||
|
|
||||||
### [simpleAssert_nvrtc](./simpleAssert_nvrtc)
|
|
||||||
This CUDA Runtime API sample is a very basic sample that implements how to use the assert function in the device code. Requires Compute Capability 2.0 .
|
|
||||||
|
|
||||||
### [simpleAtomicIntrinsics](./simpleAtomicIntrinsics)
|
|
||||||
A simple demonstration of global memory atomic instructions.
|
|
||||||
|
|
||||||
### [simpleAtomicIntrinsics_nvrtc](./simpleAtomicIntrinsics_nvrtc)
|
|
||||||
A simple demonstration of global memory atomic instructions.This sample makes use of NVRTC for Runtime Compilation.
|
|
||||||
|
|
||||||
### [simpleAttributes](./simpleAttributes)
|
|
||||||
This CUDA Runtime API sample is a very basic example that implements how to use the stream attributes that affect L2 locality. Performance improvement due to use of L2 access policy window can only be noticed on Compute capability 8.0 or higher.
|
|
||||||
|
|
||||||
### [simpleAWBarrier](./simpleAWBarrier)
|
|
||||||
A simple demonstration of arrive wait barriers.
|
|
||||||
|
|
||||||
### [simpleCallback](./simpleCallback)
|
|
||||||
This sample implements multi-threaded heterogeneous computing workloads with the new CPU callbacks for CUDA streams and events introduced with CUDA 5.0.
|
|
||||||
|
|
||||||
### [simpleCooperativeGroups](./simpleCooperativeGroups)
|
|
||||||
This sample is a simple code that illustrates basic usage of cooperative groups within the thread block.
|
|
||||||
|
|
||||||
### [simpleCubemapTexture](./simpleCubemapTexture)
|
|
||||||
Simple example that demonstrates how to use a new CUDA 4.1 feature to support cubemap Textures in CUDA C.
|
|
||||||
|
|
||||||
### [simpleCUDA2GL](./simpleCUDA2GL)
|
|
||||||
This sample shows how to copy CUDA image back to OpenGL using the most efficient methods.
|
|
||||||
|
|
||||||
### [simpleDrvRuntime](./simpleDrvRuntime)
|
|
||||||
A simple example which demonstrates how CUDA Driver and Runtime APIs can work together to load cuda fatbinary of vector add kernel and performing vector addition.
|
|
||||||
|
|
||||||
### [simpleHyperQ](./simpleHyperQ)
|
|
||||||
This sample demonstrates the use of CUDA streams for concurrent execution of several kernels on devices which provide HyperQ (SM 3.5). Devices without HyperQ (SM 2.0 and SM 3.0) will run a maximum of two kernels concurrently.
|
|
||||||
|
|
||||||
### [simpleIPC](./simpleIPC)
|
|
||||||
This CUDA Runtime API sample is a very basic sample that demonstrates Inter Process Communication with one process per GPU for computation. Requires Compute Capability 3.0 or higher and a Linux Operating System, or a Windows Operating System with TCC enabled GPUs
|
|
||||||
|
|
||||||
### [simpleLayeredTexture](./simpleLayeredTexture)
|
|
||||||
Simple example that demonstrates how to use a new CUDA 4.0 feature to support layered Textures in CUDA C.
|
|
||||||
|
|
||||||
### [simpleMPI](./simpleMPI)
|
|
||||||
Simple example demonstrating how to use MPI in combination with CUDA.
|
|
||||||
|
|
||||||
### [simpleMultiCopy](./simpleMultiCopy)
|
|
||||||
Supported in GPUs with Compute Capability 1.1, overlapping compute with one memcopy is possible from the host system. For Quadro and Tesla GPUs with Compute Capability 2.0, a second overlapped copy operation in either direction at full speed is possible (PCI-e is symmetric). This sample illustrates the usage of CUDA streams to achieve overlapping of kernel execution with data copies to and from the device.
|
|
||||||
|
|
||||||
### [simpleMultiGPU](./simpleMultiGPU)
|
|
||||||
This application demonstrates how to use the new CUDA 4.0 API for CUDA context management and multi-threaded access to run CUDA kernels on multiple-GPUs.
|
|
||||||
|
|
||||||
### [simpleOccupancy](./simpleOccupancy)
|
|
||||||
This sample demonstrates the basic usage of the CUDA occupancy calculator and occupancy-based launch configurator APIs by launching a kernel with the launch configurator, and measures the utilization difference against a manually configured launch.
|
|
||||||
|
|
||||||
### [simpleP2P](./simpleP2P)
|
|
||||||
This application demonstrates CUDA APIs that support Peer-To-Peer (P2P) copies, Peer-To-Peer (P2P) addressing, and Unified Virtual Memory Addressing (UVA) between multiple GPUs. In general, P2P is supported between two same GPUs with some exceptions, such as some Tesla and Quadro GPUs.
|
|
||||||
|
|
||||||
### [simplePitchLinearTexture](./simplePitchLinearTexture)
|
|
||||||
Use of Pitch Linear Textures
|
|
||||||
|
|
||||||
### [simplePrintf](./simplePrintf)
|
|
||||||
This basic CUDA Runtime API sample demonstrates how to use the printf function in the device code.
|
|
||||||
|
|
||||||
### [simpleStreams](./simpleStreams)
|
|
||||||
This sample uses CUDA streams to overlap kernel executions with memory copies between the host and a GPU device. This sample uses a new CUDA 4.0 feature that supports pinning of generic host memory. Requires Compute Capability 2.0 or higher.
|
|
||||||
|
|
||||||
### [simpleSurfaceWrite](./simpleSurfaceWrite)
|
|
||||||
Simple example that demonstrates the use of 2D surface references (Write-to-Texture)
|
|
||||||
|
|
||||||
### [simpleTemplates](./simpleTemplates)
|
|
||||||
This sample is a templatized version of the template project. It also shows how to correctly templatize dynamically allocated shared memory arrays.
|
|
||||||
|
|
||||||
### [simpleTexture](./simpleTexture)
|
|
||||||
Simple example that demonstrates use of Textures in CUDA.
|
|
||||||
|
|
||||||
### [simpleTexture3D](./simpleTexture3D)
|
|
||||||
Simple example that demonstrates use of 3D Textures in CUDA.
|
|
||||||
|
|
||||||
### [simpleTextureDrv](./simpleTextureDrv)
|
|
||||||
Simple example that demonstrates use of Textures in CUDA. This sample uses the new CUDA 4.0 kernel launch Driver API.
|
|
||||||
|
|
||||||
### [simpleVoteIntrinsics](./simpleVoteIntrinsics)
|
|
||||||
Simple program which demonstrates how to use the Vote (__any_sync, __all_sync) intrinsic instruction in a CUDA kernel.
|
|
||||||
|
|
||||||
### [simpleZeroCopy](./simpleZeroCopy)
|
|
||||||
This sample illustrates how to use Zero MemCopy, kernels can read and write directly to pinned system memory.
|
|
||||||
|
|
||||||
### [systemWideAtomics](./systemWideAtomics)
|
|
||||||
A simple demonstration of system wide atomic instructions.
|
|
||||||
|
|
||||||
### [template](./template)
|
|
||||||
A trivial template project that can be used as a starting point to create new CUDA projects.
|
|
||||||
|
|
||||||
### [UnifiedMemoryStreams](./UnifiedMemoryStreams)
|
|
||||||
This sample demonstrates the use of OpenMP and streams with Unified Memory on a single GPU.
|
|
||||||
|
|
||||||
### [vectorAdd](./vectorAdd)
|
|
||||||
This CUDA Runtime API sample is a very basic sample that implements element by element vector addition. It is the same as the sample illustrating Chapter 3 of the programming guide with some additions like error checking.
|
|
||||||
|
|
||||||
### [vectorAdd_nvrtc](./vectorAdd_nvrtc)
|
|
||||||
This CUDA Driver API sample uses NVRTC for runtime compilation of vector addition kernel. Vector addition kernel demonstrated is the same as the sample illustrating Chapter 3 of the programming guide.
|
|
||||||
|
|
||||||
### [vectorAddDrv](./vectorAddDrv)
|
|
||||||
This Vector Addition sample is a basic sample that is implemented element by element. It is the same as the sample illustrating Chapter 3 of the programming guide with some additions like error checking. This sample also uses the new CUDA 4.0 kernel launch Driver API.
|
|
||||||
|
|
||||||
### [vectorAddMMAP](./vectorAddMMAP)
|
|
||||||
This sample replaces the device allocation in the vectorAddDrv sample with cuMemMap-ed allocations. This sample demonstrates that the cuMemMap api allows the user to specify the physical properties of their memory while retaining the contiguous nature of their access, thus not requiring a change in their program structure.
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(UnifiedMemoryStreams LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
find_package(OpenMP REQUIRED)
|
|
||||||
|
|
||||||
if(${OpenMP_FOUND})
|
|
||||||
# Add target for UnifiedMemoryStreams
|
|
||||||
add_executable(UnifiedMemoryStreams UnifiedMemoryStreams.cu)
|
|
||||||
|
|
||||||
target_compile_options(UnifiedMemoryStreams PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(UnifiedMemoryStreams PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
set_target_properties(UnifiedMemoryStreams PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
|
||||||
|
|
||||||
target_link_libraries(UnifiedMemoryStreams PUBLIC
|
|
||||||
CUDA::cublas
|
|
||||||
OpenMP::OpenMP_CXX
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
message(STATUS "OpenMP not found - will not build sample 'UnifiedMemoryStreams'")
|
|
||||||
endif()
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
# UnifiedMemoryStreams - Unified Memory Streams
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample demonstrates the use of OpenMP and streams with Unified Memory on a single GPU.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
CUDA Systems Integration, OpenMP, CUBLAS, Multithreading, Unified Memory, CUDA Streams and Events
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
|
||||||
cudaStreamDestroy, cudaFree, cudaMallocManaged, cudaStreamAttachMemAsync, cudaSetDevice, cudaDeviceSynchronize, cudaStreamSynchronize, cudaStreamCreate, cudaGetDeviceProperties
|
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
|
||||||
[OpenMP](../../../README.md#openmp), [UVM](../../../README.md#uvm), [CUBLAS](../../../README.md#cublas)
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](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)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(asyncAPI LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
# Add target for asyncAPI
|
|
||||||
add_executable(asyncAPI asyncAPI.cu)
|
|
||||||
|
|
||||||
target_compile_options(asyncAPI PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(asyncAPI PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
set_target_properties(asyncAPI PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# asyncAPI - asyncAPI
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample illustrates the usage of CUDA events for both GPU timing and overlapping CPU and GPU execution. Events are inserted into a stream of CUDA calls. Since CUDA stream calls are asynchronous, the CPU can perform computations while GPU is executing (including DMA memcopies between the host and device). CPU can query CUDA events to determine whether GPU has completed tasks.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
Asynchronous Data Transfers, CUDA Streams and Events
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
|
||||||
cudaProfilerStop, cudaMalloc, cudaMemcpyAsync, cudaFree, cudaMallocHost, cudaProfilerStart, cudaDeviceSynchronize, cudaEventRecord, cudaFreeHost, cudaMemset, cudaEventDestroy, cudaEventQuery, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
|
||||||
|
|
||||||
## References (for more details)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(clock LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
# Add target for asyncAPI
|
|
||||||
add_executable(clock clock.cu)
|
|
||||||
|
|
||||||
target_compile_options(clock PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(clock PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
set_target_properties(clock PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# clock - Clock
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This example shows how to use the clock function to measure the performance of block of threads of a kernel accurately.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
Performance Strategies
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
|
||||||
cudaMalloc, cudaMemcpy, cudaFree
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
|
||||||
|
|
||||||
## References (for more details)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(clock_nvrtc LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
# Add sample target executable
|
|
||||||
add_executable(clock_nvrtc clock.cpp)
|
|
||||||
|
|
||||||
target_compile_options(clock_nvrtc PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(clock_nvrtc PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
target_link_libraries(clock_nvrtc PRIVATE
|
|
||||||
CUDA::nvrtc
|
|
||||||
CUDA::cuda_driver
|
|
||||||
)
|
|
||||||
|
|
||||||
# Copy clock_kernel.cu to the output directory
|
|
||||||
add_custom_command(TARGET clock_nvrtc POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/clock_kernel.cu ${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
)
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
# clock_nvrtc - Clock libNVRTC
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This example shows how to use the clock function using libNVRTC to measure the performance of block of threads of a kernel accurately.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
Performance Strategies, Runtime Compilation
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows, QNX
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, aarch64
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Driver API](http://docs.nvidia.com/cuda/cuda-driver-api/index.html)
|
|
||||||
cuMemcpyDtoH, cuLaunchKernel, cuMemcpyHtoD, cuCtxSynchronize, cuMemAlloc, cuMemFree, cuModuleGetFunction
|
|
||||||
|
|
||||||
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
|
||||||
cudaBlockSize, cudaGridSize
|
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
|
||||||
[NVRTC](../../../README.md#nvrtc)
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](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)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(cudaOpenMP LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
find_package(OpenMP)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
if(OpenMP_CXX_FOUND)
|
|
||||||
# Add target for asyncAPI
|
|
||||||
add_executable(cudaOpenMP cudaOpenMP.cu)
|
|
||||||
|
|
||||||
target_compile_options(cudaOpenMP PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(cudaOpenMP PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
set_target_properties(cudaOpenMP PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
|
||||||
target_link_libraries(cudaOpenMP PUBLIC
|
|
||||||
OpenMP::OpenMP_CXX
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
message(STATUS "OpenMP not found - will not build sample 'cudaOpenMP'")
|
|
||||||
endif()
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# cudaOpenMP - cudaOpenMP
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample demonstrates how to use OpenMP API to write an application for multiple GPUs.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
CUDA Systems Integration, OpenMP, Multithreading
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
|
||||||
cudaMemcpy, cudaGetErrorString, cudaFree, cudaGetLastError, cudaSetDevice, cudaGetDeviceCount, cudaGetDevice, cudaMemset, cudaMalloc, cudaGetDeviceProperties
|
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
|
||||||
[OpenMP](../../../README.md#openmp)
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](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)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(fp16ScalarProduct LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
# Add target for asyncAPI
|
|
||||||
add_executable(fp16ScalarProduct fp16ScalarProduct.cu)
|
|
||||||
|
|
||||||
target_compile_options(fp16ScalarProduct PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(fp16ScalarProduct PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
set_target_properties(fp16ScalarProduct PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# fp16ScalarProduct - FP16 Scalar Product
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
Calculates scalar product of two vectors of FP16 numbers.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
CUDA Runtime API
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
|
||||||
cudaMemcpy, cudaFree, cudaMallocHost, cudaFreeHost, cudaMalloc, cudaGetDeviceProperties
|
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
|
||||||
[FP16](../../../README.md#fp16)
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](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)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(matrixMul LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
# Add target for asyncAPI
|
|
||||||
add_executable(matrixMul matrixMul.cu)
|
|
||||||
|
|
||||||
target_compile_options(matrixMul PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(matrixMul PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
set_target_properties(matrixMul PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# matrixMul - Matrix Multiplication (CUDA Runtime API Version)
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample implements matrix multiplication and is exactly the same as Chapter 6 of the programming guide. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. To illustrate GPU performance for matrix multiply, this sample also shows how to use the new CUDA 4.0 interface for CUBLAS to demonstrate high-performance performance for matrix multiplication.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
CUDA Runtime API, Linear Algebra
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l, aarch64
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
|
||||||
cudaStreamCreateWithFlags, cudaProfilerStop, cudaMalloc, cudaFree, cudaMallocHost, cudaProfilerStart, cudaEventSynchronize, cudaEventRecord, cudaFreeHost, cudaStreamSynchronize, cudaEventDestroy, cudaEventElapsedTime, cudaMemcpyAsync, cudaEventCreate
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
|
||||||
|
|
||||||
## References (for more details)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(matrixMulDrv LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
# Add target for matrixMulDrv
|
|
||||||
add_executable(matrixMulDrv matrixMulDrv.cpp)
|
|
||||||
|
|
||||||
target_compile_options(matrixMulDrv PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(matrixMulDrv PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
set_target_properties(matrixMulDrv PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
|
||||||
|
|
||||||
target_include_directories(matrixMulDrv PRIVATE
|
|
||||||
${CUDAToolkit_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(matrixMulDrv PUBLIC
|
|
||||||
CUDA::cuda_driver
|
|
||||||
)
|
|
||||||
|
|
||||||
set(CUDA_FATBIN_FILE "${CMAKE_CURRENT_BINARY_DIR}/matrixMul_kernel64.fatbin")
|
|
||||||
set(CUDA_KERNEL_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/matrixMul_kernel.cu")
|
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${CUDA_FATBIN_FILE}
|
|
||||||
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}
|
|
||||||
DEPENDS ${CUDA_KERNEL_SOURCE}
|
|
||||||
COMMENT "Building CUDA fatbin: ${CUDA_FATBIN_FILE}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create a dummy target for fatbin generation
|
|
||||||
add_custom_target(generate_fatbin_matmulDrv ALL DEPENDS ${CUDA_FATBIN_FILE})
|
|
||||||
|
|
||||||
# Ensure matrixMulDrv depends on the fatbin
|
|
||||||
add_dependencies(matrixMulDrv generate_fatbin_matmulDrv)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# matrixMulDrv - Matrix Multiplication (CUDA Driver API Version)
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample implements matrix multiplication and uses the new CUDA 4.0 kernel launch Driver API. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. CUBLAS provides high-performance matrix multiplication.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
CUDA Driver API, Matrix Multiply
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l, aarch64
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Driver API](http://docs.nvidia.com/cuda/cuda-driver-api/index.html)
|
|
||||||
cuMemcpyDtoH, cuLaunchKernel, cuMemcpyHtoD, cuDeviceGetName, cuDeviceTotalMem, cuDeviceGetAttribute, cuModuleLoadData, cuOccupancyMaxPotentialBlockSize, cuMemAlloc, cuMemFree, cuCtxDestroy, cuModuleGetFunction, cuCtxCreate
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
|
||||||
|
|
||||||
## References (for more details)
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
/* Copyright (c) 2022, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _MATRIXMUL_H_
|
|
||||||
#define _MATRIXMUL_H_
|
|
||||||
|
|
||||||
// Matrix dimensions
|
|
||||||
// (chosen as multiples of the thread block size for simplicity)
|
|
||||||
#define WA (4 * block_size) // Matrix A width
|
|
||||||
#define HA (6 * block_size) // Matrix A height
|
|
||||||
#define WB (4 * block_size) // Matrix B width
|
|
||||||
#define HB WA // Matrix B height
|
|
||||||
#define WC WB // Matrix C width
|
|
||||||
#define HC HA // Matrix C height
|
|
||||||
|
|
||||||
#endif // _MATRIXMUL_H_
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
/* Copyright (c) 2022, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Matrix multiplication: C = A * B.
|
|
||||||
* Device code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _MATRIXMUL_KERNEL_H_
|
|
||||||
#define _MATRIXMUL_KERNEL_H_
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define AS(i, j) As[i][j]
|
|
||||||
#define BS(i, j) Bs[i][j]
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//! Matrix multiplication on the device: C = A * B
|
|
||||||
//! wA is A's width and wB is B's width
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
template <int block_size, typename size_type>
|
|
||||||
__device__ void matrixMul(float *C, float *A, float *B, size_type wA,
|
|
||||||
size_type wB) {
|
|
||||||
// Block index
|
|
||||||
size_type bx = blockIdx.x;
|
|
||||||
size_type by = blockIdx.y;
|
|
||||||
|
|
||||||
// Thread index
|
|
||||||
size_type tx = threadIdx.x;
|
|
||||||
size_type ty = threadIdx.y;
|
|
||||||
|
|
||||||
// Index of the first sub-matrix of A processed by the block
|
|
||||||
size_type aBegin = wA * block_size * by;
|
|
||||||
|
|
||||||
// Index of the last sub-matrix of A processed by the block
|
|
||||||
size_type aEnd = aBegin + wA - 1;
|
|
||||||
|
|
||||||
// Step size used to iterate through the sub-matrices of A
|
|
||||||
size_type aStep = block_size;
|
|
||||||
|
|
||||||
// Index of the first sub-matrix of B processed by the block
|
|
||||||
size_type bBegin = block_size * bx;
|
|
||||||
|
|
||||||
// Step size used to iterate through the sub-matrices of B
|
|
||||||
size_type bStep = block_size * wB;
|
|
||||||
|
|
||||||
// Csub is used to store the element of the block sub-matrix
|
|
||||||
// that is computed by the thread
|
|
||||||
float Csub = 0;
|
|
||||||
|
|
||||||
// Loop over all the sub-matrices of A and B
|
|
||||||
// required to compute the block sub-matrix
|
|
||||||
for (size_type a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep) {
|
|
||||||
// Declaration of the shared memory array As used to
|
|
||||||
// store the sub-matrix of A
|
|
||||||
__shared__ float As[block_size][block_size];
|
|
||||||
|
|
||||||
// Declaration of the shared memory array Bs used to
|
|
||||||
// store the sub-matrix of B
|
|
||||||
__shared__ float Bs[block_size][block_size];
|
|
||||||
|
|
||||||
// Load the matrices from device memory
|
|
||||||
// to shared memory; each thread loads
|
|
||||||
// one element of each matrix
|
|
||||||
AS(ty, tx) = A[a + wA * ty + tx];
|
|
||||||
BS(ty, tx) = B[b + wB * ty + tx];
|
|
||||||
|
|
||||||
// Synchronize to make sure the matrices are loaded
|
|
||||||
__syncthreads();
|
|
||||||
|
|
||||||
// Multiply the two matrices together;
|
|
||||||
// each thread computes one element
|
|
||||||
// of the block sub-matrix
|
|
||||||
#pragma unroll
|
|
||||||
|
|
||||||
for (size_type k = 0; k < block_size; ++k) Csub += AS(ty, k) * BS(k, tx);
|
|
||||||
|
|
||||||
// Synchronize to make sure that the preceding
|
|
||||||
// computation is done before loading two new
|
|
||||||
// sub-matrices of A and B in the next iteration
|
|
||||||
__syncthreads();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the block sub-matrix to device memory;
|
|
||||||
// each thread writes one element
|
|
||||||
size_type c = wB * block_size * by + block_size * bx;
|
|
||||||
C[c + wB * ty + tx] = Csub;
|
|
||||||
}
|
|
||||||
|
|
||||||
// C wrappers around our template kernel
|
|
||||||
extern "C" __global__ void matrixMul_bs8_64bit(float *C, float *A, float *B,
|
|
||||||
size_t wA, size_t wB) {
|
|
||||||
matrixMul<8, size_t>(C, A, B, wA, wB);
|
|
||||||
}
|
|
||||||
extern "C" __global__ void matrixMul_bs16_64bit(float *C, float *A, float *B,
|
|
||||||
size_t wA, size_t wB) {
|
|
||||||
matrixMul<16, size_t>(C, A, B, wA, wB);
|
|
||||||
}
|
|
||||||
extern "C" __global__ void matrixMul_bs32_64bit(float *C, float *A, float *B,
|
|
||||||
size_t wA, size_t wB) {
|
|
||||||
matrixMul<32, size_t>(C, A, B, wA, wB);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // #ifndef _MATRIXMUL_KERNEL_H_
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(matrixMulDynlinkJIT LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
# Add target for matrixMulDynlinkJIT
|
|
||||||
add_executable(matrixMulDynlinkJIT cuda_drvapi_dynlink.c matrixMulDynlinkJIT.cpp matrixMul_gold.cpp matrixMul_kernel_32_ptxdump.c matrixMul_kernel_64_ptxdump.c)
|
|
||||||
|
|
||||||
target_compile_options(matrixMulDynlinkJIT PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(matrixMulDynlinkJIT PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
set_target_properties(matrixMulDynlinkJIT PROPERTIES
|
|
||||||
CUDA_SEPARABLE_COMPILATION ON
|
|
||||||
POSITION_INDEPENDENT_CODE OFF
|
|
||||||
)
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
|
|
||||||
target_link_libraries(matrixMulDynlinkJIT PUBLIC
|
|
||||||
CUDA::cudart
|
|
||||||
CUDA::cuda_driver
|
|
||||||
)
|
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
target_link_libraries(matrixMulDynlinkJIT PUBLIC dl)
|
|
||||||
endif()
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# matrixMulDynlinkJIT - Matrix Multiplication (CUDA Driver API version with Dynamic Linking Version)
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample revisits matrix multiplication using the CUDA driver API. It demonstrates how to link to CUDA driver at runtime and how to use JIT (just-in-time) compilation from PTX code. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. CUBLAS provides high-performance matrix multiplication.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
CUDA Driver API, CUDA Dynamically Linked Library
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Driver API](http://docs.nvidia.com/cuda/cuda-driver-api/index.html)
|
|
||||||
cuMemcpyDtoH, cuDeviceGetName, cuParamSeti, cuModuleLoadDataEx, cuModuleGetFunction, cuLaunchGrid, cuFuncSetSharedSize, cuMemFree, cuParamSetSize, cuParamSetv, cuInit, cuMemcpyHtoD, cuLaunchKernel, cuDeviceGet, cuFuncSetBlockShape, cuCtxDestroy, cuDeviceGetCount, cuDeviceComputeCapability, cuCtxSynchronize, cuMemAlloc, cuCtxCreate
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
|
||||||
|
|
||||||
## References (for more details)
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
/* Copyright (c) 2022, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _MATRIXMUL_H_
|
|
||||||
#define _MATRIXMUL_H_
|
|
||||||
|
|
||||||
// Matrix dimensions
|
|
||||||
// (chosen as multiples of the thread block size for simplicity)
|
|
||||||
#define WA (4 * block_size) // Matrix A width
|
|
||||||
#define HA (6 * block_size) // Matrix A height
|
|
||||||
#define WB (4 * block_size) // Matrix B width
|
|
||||||
#define HB WA // Matrix B height
|
|
||||||
#define WC WB // Matrix C width
|
|
||||||
#define HC HA // Matrix C height
|
|
||||||
|
|
||||||
#endif // _MATRIXMUL_H_
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(matrixMul_nvrtc LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
# Add sample target executable
|
|
||||||
add_executable(matrixMul_nvrtc matrixMul.cpp)
|
|
||||||
|
|
||||||
target_compile_options(matrixMul_nvrtc PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(matrixMul_nvrtc PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
target_link_libraries(matrixMul_nvrtc PRIVATE
|
|
||||||
CUDA::nvrtc
|
|
||||||
CUDA::cuda_driver
|
|
||||||
)
|
|
||||||
|
|
||||||
# Copy clock_kernel.cu to the output directory
|
|
||||||
add_custom_command(TARGET matrixMul_nvrtc POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/matrixMul_kernel.cu ${CUDAToolkit_BIN_DIR}/../include/cooperative_groups.h ${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command(TARGET matrixMul_nvrtc POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
||||||
${CUDAToolkit_BIN_DIR}/../include/cooperative_groups ${CMAKE_CURRENT_BINARY_DIR}/cooperative_groups
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command(TARGET matrixMul_nvrtc POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
||||||
${CUDAToolkit_BIN_DIR}/../include/nv ${CMAKE_CURRENT_BINARY_DIR}/nv
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command(TARGET matrixMul_nvrtc POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
||||||
${CUDAToolkit_BIN_DIR}/../include/cuda ${CMAKE_CURRENT_BINARY_DIR}/cuda
|
|
||||||
)
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# matrixMul_nvrtc - Matrix Multiplication with libNVRTC
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample implements matrix multiplication and is exactly the same as Chapter 6 of the programming guide. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. To illustrate GPU performance for matrix multiply, this sample also shows how to use the new CUDA 4.0 interface for CUBLAS to demonstrate high-performance performance for matrix multiplication.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
CUDA Runtime API, Linear Algebra, Runtime Compilation
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows, QNX
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, aarch64
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Driver API](http://docs.nvidia.com/cuda/cuda-driver-api/index.html)
|
|
||||||
cuMemcpyDtoH, cuLaunchKernel, cuMemcpyHtoD, cuCtxSynchronize, cuMemAlloc, cuMemFree, cuModuleGetFunction
|
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
|
||||||
[NVRTC](../../../README.md#nvrtc)
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](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)
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
/* Copyright (c) 2022, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Matrix multiplication: C = A * B.
|
|
||||||
* Host code.
|
|
||||||
*
|
|
||||||
* This sample implements matrix multiplication as described in Chapter 3
|
|
||||||
* of the programming guide.
|
|
||||||
* It has been written for clarity of exposition to illustrate various CUDA
|
|
||||||
* programming principles, not with the goal of providing the most
|
|
||||||
* performant generic kernel for matrix multiplication.
|
|
||||||
*
|
|
||||||
* See also:
|
|
||||||
* V. Volkov and J. Demmel, "Benchmarking GPUs to tune dense linear algebra,"
|
|
||||||
* in Proc. 2008 ACM/IEEE Conf. on Supercomputing (SC '08),
|
|
||||||
* Piscataway, NJ: IEEE Press, 2008, pp. Art. 31:1-11.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Matrix multiplication (CUDA Kernel) on the device: C = A * B
|
|
||||||
* wA is A's width and wB is B's width
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cooperative_groups.h>
|
|
||||||
|
|
||||||
template <int BLOCK_SIZE>
|
|
||||||
__device__ void matrixMulCUDA(float *C, float *A, float *B, int wA, int wB) {
|
|
||||||
// Handle to thread block group
|
|
||||||
cooperative_groups::thread_block cta =
|
|
||||||
cooperative_groups::this_thread_block();
|
|
||||||
// Block index
|
|
||||||
int bx = blockIdx.x;
|
|
||||||
int by = blockIdx.y;
|
|
||||||
|
|
||||||
// Thread index
|
|
||||||
int tx = threadIdx.x;
|
|
||||||
int ty = threadIdx.y;
|
|
||||||
|
|
||||||
// Index of the first sub-matrix of A processed by the block
|
|
||||||
int aBegin = wA * BLOCK_SIZE * by;
|
|
||||||
|
|
||||||
// Index of the last sub-matrix of A processed by the block
|
|
||||||
int aEnd = aBegin + wA - 1;
|
|
||||||
|
|
||||||
// Step size used to iterate through the sub-matrices of A
|
|
||||||
int aStep = BLOCK_SIZE;
|
|
||||||
|
|
||||||
// Index of the first sub-matrix of B processed by the block
|
|
||||||
int bBegin = BLOCK_SIZE * bx;
|
|
||||||
|
|
||||||
// Step size used to iterate through the sub-matrices of B
|
|
||||||
int bStep = BLOCK_SIZE * wB;
|
|
||||||
|
|
||||||
// Csub is used to store the element of the block sub-matrix
|
|
||||||
// that is computed by the thread
|
|
||||||
float Csub = 0;
|
|
||||||
|
|
||||||
// Loop over all the sub-matrices of A and B
|
|
||||||
// required to compute the block sub-matrix
|
|
||||||
for (int a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep) {
|
|
||||||
// Declaration of the shared memory array As used to
|
|
||||||
// store the sub-matrix of A
|
|
||||||
__shared__ float As[BLOCK_SIZE][BLOCK_SIZE];
|
|
||||||
|
|
||||||
// Declaration of the shared memory array Bs used to
|
|
||||||
// store the sub-matrix of B
|
|
||||||
__shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE];
|
|
||||||
|
|
||||||
// Load the matrices from device memory
|
|
||||||
// to shared memory; each thread loads
|
|
||||||
// one element of each matrix
|
|
||||||
As[ty][tx] = A[a + wA * ty + tx];
|
|
||||||
Bs[ty][tx] = B[b + wB * ty + tx];
|
|
||||||
|
|
||||||
// Synchronize to make sure the matrices are loaded
|
|
||||||
cooperative_groups::sync(cta);
|
|
||||||
|
|
||||||
// Multiply the two matrices together;
|
|
||||||
// each thread computes one element
|
|
||||||
// of the block sub-matrix
|
|
||||||
#pragma unroll
|
|
||||||
for (int k = 0; k < BLOCK_SIZE; ++k) {
|
|
||||||
Csub += As[ty][k] * Bs[k][tx];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Synchronize to make sure that the preceding
|
|
||||||
// computation is done before loading two new
|
|
||||||
// sub-matrices of A and B in the next iteration
|
|
||||||
cooperative_groups::sync(cta);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the block sub-matrix to device memory;
|
|
||||||
// each thread writes one element
|
|
||||||
int c = wB * BLOCK_SIZE * by + BLOCK_SIZE * bx;
|
|
||||||
C[c + wB * ty + tx] = Csub;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __global__ void matrixMulCUDA_block16(float *C, float *A, float *B,
|
|
||||||
int wA, int wB) {
|
|
||||||
matrixMulCUDA<16>(C, A, B, wA, wB);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __global__ void matrixMulCUDA_block32(float *C, float *A, float *B,
|
|
||||||
int wA, int wB) {
|
|
||||||
matrixMulCUDA<32>(C, A, B, wA, wB);
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
|
||||||
|
|
||||||
project(mergeSort LANGUAGES C CXX CUDA)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90 100 101 120)
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include directories and libraries
|
|
||||||
include_directories(../../../Common)
|
|
||||||
|
|
||||||
# Source file
|
|
||||||
# Add target for mergeSort
|
|
||||||
add_executable(mergeSort mergeSort.cu main.cpp mergeSort_host.cpp mergeSort_validate.cpp)
|
|
||||||
|
|
||||||
target_compile_options(mergeSort PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
|
||||||
|
|
||||||
target_compile_features(mergeSort PRIVATE cxx_std_17 cuda_std_17)
|
|
||||||
|
|
||||||
set_target_properties(mergeSort PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
|
||||||
target_include_directories(mergeSort PRIVATE
|
|
||||||
${CUDAToolkit_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# mergeSort - Merge Sort
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample implements a merge sort (also known as Batcher's sort), algorithms belonging to the class of sorting networks. While generally subefficient on large sequences compared to algorithms with better asymptotic algorithmic complexity (i.e. merge sort or radix sort), may be the algorithms of choice for sorting batches of short- to mid-sized (key, value) array pairs. Refer to the excellent tutorial by H. W. Lang http://www.iti.fh-flensburg.de/lang/algorithmen/sortieren/networks/indexen.htm
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
Data-Parallel Algorithms
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](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.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
|
||||||
cudaMalloc, cudaDeviceSynchronize, cudaMemcpy, cudaFree
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
|
||||||
|
|
||||||
## References (for more details)
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
/* Copyright (c) 2022, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <cuda_runtime.h>
|
|
||||||
#include <helper_functions.h>
|
|
||||||
#include <helper_cuda.h>
|
|
||||||
#include "mergeSort_common.h"
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Test driver
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
uint *h_SrcKey, *h_SrcVal, *h_DstKey, *h_DstVal;
|
|
||||||
uint *d_SrcKey, *d_SrcVal, *d_BufKey, *d_BufVal, *d_DstKey, *d_DstVal;
|
|
||||||
StopWatchInterface *hTimer = NULL;
|
|
||||||
|
|
||||||
const uint N = 4 * 1048576;
|
|
||||||
const uint DIR = 1;
|
|
||||||
const uint numValues = 65536;
|
|
||||||
|
|
||||||
printf("%s Starting...\n\n", argv[0]);
|
|
||||||
|
|
||||||
int dev = findCudaDevice(argc, (const char **)argv);
|
|
||||||
|
|
||||||
if (dev == -1) {
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Allocating and initializing host arrays...\n\n");
|
|
||||||
sdkCreateTimer(&hTimer);
|
|
||||||
h_SrcKey = (uint *)malloc(N * sizeof(uint));
|
|
||||||
h_SrcVal = (uint *)malloc(N * sizeof(uint));
|
|
||||||
h_DstKey = (uint *)malloc(N * sizeof(uint));
|
|
||||||
h_DstVal = (uint *)malloc(N * sizeof(uint));
|
|
||||||
|
|
||||||
srand(2009);
|
|
||||||
|
|
||||||
for (uint i = 0; i < N; i++) {
|
|
||||||
h_SrcKey[i] = rand() % numValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
fillValues(h_SrcVal, N);
|
|
||||||
|
|
||||||
printf("Allocating and initializing CUDA arrays...\n\n");
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_DstKey, N * sizeof(uint)));
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_DstVal, N * sizeof(uint)));
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_BufKey, N * sizeof(uint)));
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_BufVal, N * sizeof(uint)));
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_SrcKey, N * sizeof(uint)));
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_SrcVal, N * sizeof(uint)));
|
|
||||||
checkCudaErrors(
|
|
||||||
cudaMemcpy(d_SrcKey, h_SrcKey, N * sizeof(uint), cudaMemcpyHostToDevice));
|
|
||||||
checkCudaErrors(
|
|
||||||
cudaMemcpy(d_SrcVal, h_SrcVal, N * sizeof(uint), cudaMemcpyHostToDevice));
|
|
||||||
|
|
||||||
printf("Initializing GPU merge sort...\n");
|
|
||||||
initMergeSort();
|
|
||||||
|
|
||||||
printf("Running GPU merge sort...\n");
|
|
||||||
checkCudaErrors(cudaDeviceSynchronize());
|
|
||||||
sdkResetTimer(&hTimer);
|
|
||||||
sdkStartTimer(&hTimer);
|
|
||||||
mergeSort(d_DstKey, d_DstVal, d_BufKey, d_BufVal, d_SrcKey, d_SrcVal, N, DIR);
|
|
||||||
checkCudaErrors(cudaDeviceSynchronize());
|
|
||||||
sdkStopTimer(&hTimer);
|
|
||||||
printf("Time: %f ms\n", sdkGetTimerValue(&hTimer));
|
|
||||||
|
|
||||||
printf("Reading back GPU merge sort results...\n");
|
|
||||||
checkCudaErrors(
|
|
||||||
cudaMemcpy(h_DstKey, d_DstKey, N * sizeof(uint), cudaMemcpyDeviceToHost));
|
|
||||||
checkCudaErrors(
|
|
||||||
cudaMemcpy(h_DstVal, d_DstVal, N * sizeof(uint), cudaMemcpyDeviceToHost));
|
|
||||||
|
|
||||||
printf("Inspecting the results...\n");
|
|
||||||
uint keysFlag = validateSortedKeys(h_DstKey, h_SrcKey, 1, N, numValues, DIR);
|
|
||||||
|
|
||||||
uint valuesFlag = validateSortedValues(h_DstKey, h_DstVal, h_SrcKey, 1, N);
|
|
||||||
|
|
||||||
printf("Shutting down...\n");
|
|
||||||
closeMergeSort();
|
|
||||||
sdkDeleteTimer(&hTimer);
|
|
||||||
checkCudaErrors(cudaFree(d_SrcVal));
|
|
||||||
checkCudaErrors(cudaFree(d_SrcKey));
|
|
||||||
checkCudaErrors(cudaFree(d_BufVal));
|
|
||||||
checkCudaErrors(cudaFree(d_BufKey));
|
|
||||||
checkCudaErrors(cudaFree(d_DstVal));
|
|
||||||
checkCudaErrors(cudaFree(d_DstKey));
|
|
||||||
free(h_DstVal);
|
|
||||||
free(h_DstKey);
|
|
||||||
free(h_SrcVal);
|
|
||||||
free(h_SrcKey);
|
|
||||||
|
|
||||||
exit((keysFlag && valuesFlag) ? EXIT_SUCCESS : EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user