68 Commits
v13.0 ... v13.2

Author SHA1 Message Date
Rob Armstrong
a4526d5229 Merge branch 'shawnz_bug_fix' into 'master'
Fixing Bug 3570274, 3570274, 5952280, 5970525 and 5970583

See merge request cuda-samples/cuda-samples!150
2026-03-30 08:09:12 -07:00
Shawn Zeng
f69622b6b6 Bug 5970583: Update the incorrect links of dependencies for Samples 2026-03-12 16:51:36 +08:00
Shawn Zeng
722c5dd069 Bug 5970525: Update a minor issue of Samples/0_Introduction/fp16ScalarProduct 2026-03-11 16:22:10 +08:00
Shawn Zeng
e32d17e67e Bug 5952280: Add cuModuleUnload(Module) to release resource for 6 samples 2026-03-10 16:05:27 +08:00
Shawn Zeng
5cf83b5a98 Bug 3570274 and 3570274: Check Unified Memory is supported or not for executing Unified Memory samples 2026-03-03 12:20:07 +08:00
Rob Armstrong
191900a7b4 Update CUDA Programming Guide URL 2026-02-04 09:21:29 -08:00
Rob Armstrong
338df69d0f Merge branch 'Bug_5809031' into 'master'
Bug 5809031: Explicitly adding P2H2P fallback as cudaMemcpyPeerAsync...

See merge request cuda-samples/cuda-samples!148
2026-01-29 12:50:46 -08:00
Shawn Zeng
9b7a6f907a Bug 5809031: Explicitly ensure P2P is disabled before fallback detecting 2026-01-26 11:37:52 +08:00
Shawn Zeng
5bbae96fd3 Bug 5809031: Explicitly adding P2H2P fallback as cudaMemcpyPeerAsync automatically fallback not supported with P2P off and CC mode on 2026-01-23 18:56:38 +08:00
Rob Armstrong
ce9407c240 Merge branch 'master_bug_fix' into 'master'
Bug fix for CUDA 13.2 samples

See merge request cuda-samples/cuda-samples!146
2026-01-21 09:07:07 -08:00
Rob Armstrong
cdedff42d2 Merge branch 'make_install' into 'master'
Make_install: enable setting CUDA_SAMPLES_INSTALL_DIR

See merge request cuda-samples/cuda-samples!145
2026-01-21 09:06:50 -08:00
Shawn Zeng
6c4d183ba3 Bug 5812203: Replace thrust::make_tuple,tuple,get with the cuda::std ones 2026-01-21 15:48:47 +08:00
Shawn Zeng
af49216f0c Modify CUDA Toolkit version to 13.2 2026-01-21 15:48:47 +08:00
Shawn Zeng
17113ea87e Bug 5701423: Add MSVC-specific flag /Zc:preprocessor as CCCL change the warning of this flag to error 2026-01-21 15:48:47 +08:00
Shawn Zeng
70fcdd353f Bug 5742096: Using uint32_t instead of int to fix the overflow undefine dehavior issue of the sample 0_Introduction/simpleOccupancy 2026-01-21 15:48:47 +08:00
Shawn Zeng
5b2dd19a21 Bug 5056041: Fix the VUID-vkAcquireNextImageKHR-semaphore-01779 error of simpleVulkan 2026-01-21 15:48:47 +08:00
Shawn Zeng
37dcb9b61d Bug 5671906: Enable vulkan validaitonLayers for Vulkan samples with Debug build only 2026-01-21 15:48:47 +08:00
Shawn Zeng
1bc6774795 Make_install: enable setting CUDA_SAMPLES_INSTALL_DIR 2026-01-21 14:51:36 +08:00
Rob Armstrong
4f735616ba Update documentation for 13.1 2026-01-06 08:37:20 -08:00
Rob Armstrong
4ff552244d Merge branch 'make_install' into 'master'
Add make install feature and fix some minor bugs

See merge request cuda-samples/cuda-samples!138
2025-11-14 08:41:33 -08:00
Shawn Zeng
df6edf644e Bug 5659370: Update the README.md of sample subfolder according to the latest structure of the sample folder 2025-11-14 18:18:09 +08:00
Shawn Zeng
85231cd1b6 Bug 5631118: Modify the socket create folder for QNX as per filesystems change in QNX SDP 8.0.3 2025-11-14 15:30:24 +08:00
Shawn Zeng
46a782fb44 Bug 5591814: Update README.md for make install 2025-11-11 21:23:20 +08:00
Shawn Zeng
d5dedb24d6 Bug 5591814: Update Samples/7_libNVVM/CMakeLists.txt for libNVVM samples install on Windows 2025-11-11 21:19:44 +08:00
Shawn Zeng
9600b04a3c Bug 5591814: Support "make install" for Windows 2025-11-07 22:34:56 +08:00
Shawn Zeng
4eae2ccc04 Bug 5591814: Support "make install" in single sample folder 2025-11-04 16:21:23 +08:00
Shawn Zeng
d759a16c4b Update 7_libNVVM to enhance the .ll test file coping and installing 2025-10-31 17:01:18 +08:00
Shawn Zeng
b8191f860a Update CMakeLists.txt of boxFilter and FuctionPointers, copy the data files to data/ folder as other samples did 2025-10-31 17:00:20 +08:00
Shawn Zeng
547f65851f Bug 5591814: Update CMakeLists.txt and add cmake/InstallSamples.cmake to support make install 2025-10-31 16:57:26 +08:00
Rob Armstrong
9df0ef6411 Merge branch 'shawnz_bug_fix' into 'master'
Bug 5538217: Add X11 and other libraries for Debian13 or later explicitly

See merge request cuda-samples/cuda-samples!136
2025-10-14 08:18:29 -07:00
Shawn Zeng
1411d243a6 Bug 5538217: Add X11 and other libraries for Debian13 or later explicitly 2025-10-14 00:23:23 -07:00
Rob Armstrong
57e870596c Merge branch 'shawnz_bug_fix' into 'master'
Shawnz bug fix

See merge request cuda-samples/cuda-samples!134
2025-09-24 12:19:02 -07:00
shawnz
fd6707ccaa Bug 5532074 Modify the filesystem compatibility from GCC 7.x to 8.x for RHEL 8.10 2025-09-23 14:48:54 +08:00
shawnz
cf01c5bb28 Bug 5519400: Add /Zc:preprocessor for new change of CUDA 13.1 CCCL include aligned_alloc.h 2025-09-22 15:35:45 +08:00
Rob Armstrong
1165d53ddf Merge branch 'shawnz_bug_fix' into 'master'
Fixed new bug reported during CUDA 13.1 test: 5514725 and 5518076

See merge request cuda-samples/cuda-samples!133
2025-09-18 10:12:12 -07:00
shawnz
8c324afd63 Bug 5518076: Remove the redundant space of $<CONFIGURATION> 2025-09-16 17:31:55 +08:00
shawnz
0fae54dcd6 Bug 5514725: Modify the socket folder for systems that have GCC < 8 by default such as SLES 2025-09-16 17:29:36 +08:00
Rob Armstrong
320c7e6392 Resolve merge between 13.0 and 13.1 branches 2025-09-05 09:39:09 -07:00
Nikhil Talpallikar
22fafb0a7c fixed formatting 2025-09-05 09:36:40 -07:00
Nikhil Talpallikar
cccbf2c284 Fixed dlopen on linux with lazy load flag 2025-09-05 09:36:40 -07:00
Nikhil Talpallikar
69186dc51e Fixed the error path to initialize error path function pointers. Exit with error in case of LOADLIBRARY failureas initialize of function pointers in case of LOADLIBRARY failure will fail 2025-09-05 09:36:40 -07:00
Nikhil Talpallikar
d298bf3e6f Clean implementation for failure path when cuInit fails. Removed CHECKED_CALL macro which returned prematurely 2025-09-05 09:36:40 -07:00
Nikhil Talpallikar
27c7e19849 Clean implementation for failure path when cuInit fails 2025-09-05 09:36:40 -07:00
Nikhil Talpallikar
7c190dde53 Fix null pointer refrence issue with cuda driver API function pointers in case cuInit fails 2025-09-05 09:36:40 -07:00
Rob Armstrong
5e9d44634b Merge branch 'shawnz_bug_fix' into 'master'
Bug 5502937 and  5502929: Fixing 2 sample issue on WSL

See merge request cuda-samples/cuda-samples!131
2025-09-05 09:12:40 -07:00
shawnz
b0a2f2049f Bug 5502937: Set TEMPDIR as socket create dir to avoid socket create permission isue on systems like WSL 2025-09-05 12:01:37 +08:00
shawnz
3e6d1858af Bug 5502929: Update systemWideAtomics to add device sync for WSL 2025-09-05 11:55:32 +08:00
Rob Armstrong
12b046a80e Merge branch 'shawnz_bug_fix' into 'master'
Fix bug 5150289, 5454390 and 5456523

See merge request cuda-samples/cuda-samples!130
2025-08-22 09:29:59 -07:00
shawnz
036638b713 Revert the change for LargeKernelParameter and update code format check 2025-08-22 10:48:02 +08:00
Shawn Zeng
9d703d090b Bug 5456523: Cross compile and execution for 7_libNVVM on Tegra Linux Platforms 2025-08-20 15:59:27 +08:00
shawnz
cbc075ef59 Bug 5454390: Add specific glfw3/X11 link for vulkan samples 2025-08-15 17:35:10 +08:00
shawnz
6e23a98575 Bug 5150289: Waive the sample for unsupported SM arch 2025-08-12 19:18:23 +08:00
Rob Armstrong
5fc7a4c897 Version released - merge 13.1 changes to ToT 2025-08-06 11:26:25 -07:00
Rob Armstrong
775d1b4dd3 Merge 13.0 changes into 13.1 dev branch 2025-07-29 14:14:27 -07:00
Rob Armstrong
eb8891b839 Merge branch 'shawnz_bug_fix_cuda_a' into 'cuda_a_dev'
Bug 5376426: Update README and CMakeLists.txt for freeglut and glew on WOA

See merge request cuda-samples/cuda-samples!120
2025-07-11 10:04:29 -07:00
shawnz
688fff15b2 Update README for freeglut and glew 2025-07-11 11:05:18 +08:00
shawnz
555353b4b5 Bug 5376426: Update README and CMakeLists.txt for freeglut and glew on WOA 2025-07-11 10:50:57 +08:00
Rob Armstrong
1a35902577 Update 13.0 changes into 13.1 dev branch 2025-07-10 13:46:04 -07:00
Rob Armstrong
7c8fccc0d4 Merge 13.0 changes into 13.1 development branch 2025-06-24 12:44:35 -07:00
Rob Armstrong
859debae1b Merge 13.0 changes into 13.1 dev 2025-05-28 08:33:12 -07:00
Rob Armstrong
c1166d3298 Merge 13.0 changes into 13.1 dev 2025-05-23 08:30:39 -07:00
Rob Armstrong
f19d33ddbc Merge 13.0 changes into 13.1 dev 2025-05-22 11:45:37 -07:00
Rob Armstrong
bf25251720 Merge 13.0 changes into 13.1 dev 2025-05-22 08:34:21 -07:00
Rob Armstrong
5a1f5008ed Merge branch 'master' into cuda_a_dev 2025-05-21 10:51:48 -07:00
Rob Armstrong
5ce8b512ea Merge branch 'master' into cuda_a_dev 2025-05-21 09:29:30 -07:00
Rob Armstrong
dd1a11f648 Merge branch 'master' into cuda_a_dev 2025-05-07 09:56:50 -07:00
Francesco Rizzi
f288b2e261 Fix bug in 6_Performance/transpose: copy sharedmem kernel (#363)
Update kernel loop bounds handling, main loop data copy to avoid incorrect reuse of output results.

---------

Authored-by: Francesco Rizzi <francesco.rizzi@ng-analytics.com>
2025-05-05 08:46:45 -07:00
Rob Armstrong
b63fd83b6c Update README for 13.1 2025-05-01 15:24:57 -07:00
291 changed files with 2052 additions and 302 deletions

View File

@@ -1,5 +1,11 @@
## Changelog ## Changelog
### CUDA 13.2
* Added the MSVC compile flag `-Xcompiler=/Zc:preprocessor` in CMakeLists.txt to comply with CUDA13.2 CCCL. Previously, using the traditional preprocessor triggered the warning “MSVC/cl.exe with traditional preprocessor is used…”, which now leads to a build error.
### CUDA 13.1
* Minor bug fixes and enhancements, no structural or functional changes
### CUDA 13.0 ### CUDA 13.0
* Updated the samples using the cudaDeviceProp fields which are deprecated and removed in CUDA 13.0, replacing the fields with the equivalents in "cudaDeviceGetAttribute": * Updated the samples using the cudaDeviceProp fields which are deprecated and removed in CUDA 13.0, replacing the fields with the equivalents in "cudaDeviceGetAttribute":
* Deprecated "cudaDeviceProp" fields * Deprecated "cudaDeviceProp" fields

View File

@@ -22,4 +22,12 @@ endif()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda")
# Add MSVC-specific flags for standard-conforming preprocessor (required for CCCL)
if(MSVC)
add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/Zc:preprocessor>)
endif()
# Include installation configuration before processing samples
include(cmake/InstallSamples.cmake)
add_subdirectory(Samples) add_subdirectory(Samples)

View File

@@ -188,7 +188,7 @@ int ipcCreateSocket(ipcHandle *&handle, const char *name,
char path_name[50]; char path_name[50];
// Create unique name for the socket with path if SOCK_FOLDER is set. // Create unique name for the socket with path if SOCK_FOLDER is set.
sprintf(path_name, "%s%u", SOCK_FOLDER, getpid()); sprintf(path_name, "%s/%u", getSocketFolder().c_str(), getpid());
unlink(path_name); unlink(path_name);
memset(&servaddr, 0, sizeof(servaddr)); memset(&servaddr, 0, sizeof(servaddr));
@@ -230,7 +230,7 @@ int ipcOpenSocket(ipcHandle *&handle) {
char temp[50]; char temp[50];
// Create unique name for the socket with path if SOCK_FOLDER is set. // Create unique name for the socket with path if SOCK_FOLDER is set.
sprintf(temp, "%s%u", SOCK_FOLDER, getpid()); sprintf(temp, "%s/%u", getSocketFolder().c_str(), getpid());
strcpy(cliaddr.sun_path, temp); strcpy(cliaddr.sun_path, temp);
if (bind(sock, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) { if (bind(sock, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
@@ -367,7 +367,7 @@ int ipcSendShareableHandle(ipcHandle *handle,
memset(&cliaddr, 0, sizeof(cliaddr)); memset(&cliaddr, 0, sizeof(cliaddr));
cliaddr.sun_family = AF_UNIX; cliaddr.sun_family = AF_UNIX;
char temp[20]; char temp[20];
sprintf(temp, "%s%u", SOCK_FOLDER, process); sprintf(temp, "%s/%u", getSocketFolder().c_str(), process);
strcpy(cliaddr.sun_path, temp); strcpy(cliaddr.sun_path, temp);
len = sizeof(cliaddr); len = sizeof(cliaddr);

View File

@@ -54,11 +54,25 @@
#endif #endif
#include <vector> #include <vector>
// Define "/tmp" as socket creating folder for QNX // The Unix domain sockets creating folder on QNX has been restricted to qnx6-mounted directories since QNX SDP 8.0.3.
#if defined(__QNX__) #if defined(__QNX__)
#define SOCK_FOLDER "/tmp/" #include <string>
inline std::string getSocketFolder() {
return "/storage";
}
// Simple filesystem compatibility for GCC 8.x
#elif defined(__GNUC__) && __GNUC__ < 9
#include <cstdlib>
#include <string>
inline std::string getSocketFolder() {
const char* tmpdir = std::getenv("TMPDIR");
return tmpdir ? std::string(tmpdir) : "/tmp";
}
#else #else
#define SOCK_FOLDER "" #include <filesystem>
inline std::string getSocketFolder() {
return std::filesystem::temp_directory_path().string();
}
#endif #endif
typedef struct sharedMemoryInfo_st { typedef struct sharedMemoryInfo_st {

View File

@@ -1,6 +1,6 @@
# CUDA Samples # CUDA Samples
Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 13.0](https://developer.nvidia.com/cuda-downloads). Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 13.2](https://developer.nvidia.com/cuda-downloads).
## Release Notes ## Release Notes
@@ -142,8 +142,8 @@ $ cmake .. -DBUILD_TEGRA=True \
-DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/toolchain-aarch64-linux.cmake \ -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/toolchain-aarch64-linux.cmake \
-DTARGET_FS=/drive/temp \ -DTARGET_FS=/drive/temp \
-DCMAKE_LIBRARY_PATH=/drive/temp/usr/local/cuda-13.0/thor/lib64/ \ -DCMAKE_LIBRARY_PATH=/drive/temp/usr/local/cuda-13.1/thor/lib64/ \
-DCMAKE_INCLUDE_PATH=/drive/temp/usr/local/cuda-13.0/thor/include/ -DCMAKE_INCLUDE_PATH=/drive/temp/usr/local/cuda-13.1/thor/include/
``` ```
Please note that the following libraries are not pre-installed in the DriveOS dev-nsr target filesystem: Please note that the following libraries are not pre-installed in the DriveOS dev-nsr target filesystem:
@@ -195,6 +195,72 @@ To build samples with new CUDA Toolkit(CUDA 13.0 or later) and UMD(Version 580 o
cmake -DCMAKE_PREFIX_PATH=/usr/local/cuda/lib64/stubs/ .. cmake -DCMAKE_PREFIX_PATH=/usr/local/cuda/lib64/stubs/ ..
``` ```
## Install Samples
### Installation Path Structure
The installation system automatically organizes samples into a structured directory layout based on:
- **Target Architecture**: ${CMAKE_SYSTEM_PROCESSOR}, e.g. `x64`, `aarch64`, `amd64`, etc.
- **Target OS**: `linux`, `windows`, `darwin`, `qnx`
- **Build Type**: `release`, `debug`, etc.
The default installation path is: `build/bin/${TARGET_ARCH}/${TARGET_OS}/${BUILD_TYPE}`
**Examples:**
- Linux x86_64 Release: `build/bin/x64/linux/release`
- Linux aarch64 Release: `build/bin/aarch64/linux/release`
- Windows amd64 Release: `build/bin/amd64/windows/release`
### Customizing Installation Paths
You can customize the installation location using CMake variables during the configuration step:
- `CMAKE_INSTALL_PREFIX`: Changes the root installation directory (default: `build/bin`)
```
cmake -DCMAKE_INSTALL_PREFIX=/custom/path ..
```
This will install to: `/custom/path/${TARGET_ARCH}/${TARGET_OS}/${BUILD_TYPE}`
- `CUDA_SAMPLES_INSTALL_DIR`: Specifies the exact final installation directory (overrides the structured path)
```
cmake -DCUDA_SAMPLES_INSTALL_DIR=/exact/install/path ..
```
### Install Samples on Linux
**Prerequisites:** You must first configure the project with CMake as described in the [Building CUDA Samples - Linux](#linux) or [Building]section.
After configuring and building, install the samples:
```
cd build/
make install
```
### Install Samples on Windows
**Prerequisites:** You must first configure the project with CMake as described in the [Building CUDA Samples - Windows](#windows) section.
#### Using Command Line
After configuring with CMake, build and install from the `x64 Native Tools Command Prompt for VS`:
```cmd
cd build
cmake --build . --config Release
cmake --install . --config Release
```
**Note:** Replace `Release` with `Debug` if you want to install debug builds. For multi-configuration generators (like Visual Studio), the `--config` flag determines which build type to install.
#### Using Visual Studio IDE
Alternatively, open the generated solution file `CUDA_Samples.sln` in Visual Studio:
1. Select the desired configuration (`Release` or `Debug`)
2. Build the solution (F7 or Build > Build Solution)
3. Right-click on the `INSTALL` target under `CMakePredefinedTargets` in Solution Explorer
4. Select "Build"
## Running All Samples as Tests ## Running All Samples as Tests
It's important to note that the CUDA samples are _not_ intended as a validation suite for CUDA. They do not cover corner cases, they do not completely cover the It's important to note that the CUDA samples are _not_ intended as a validation suite for CUDA. They do not cover corner cases, they do not completely cover the
@@ -383,6 +449,9 @@ Samples that demonstrate performance optimization.
### [7. libNVVM](./Samples/7_libNVVM/README.md) ### [7. libNVVM](./Samples/7_libNVVM/README.md)
Samples that demonstrate the use of libNVVVM and NVVM IR. Samples that demonstrate the use of libNVVVM and NVVM IR.
### [8. Platform Specific](./Samples/8_Platform_Specific/Tegra/README.md)
Samples that are specific to certain platforms (Tegra, cuDLA, NvMedia, NvSci, OpenGL ES).
## Dependencies ## Dependencies
Some CUDA Samples rely on third-party applications and/or libraries, or features provided by the CUDA Toolkit and Driver, to either build or execute. These dependencies are listed below. Some CUDA Samples rely on third-party applications and/or libraries, or features provided by the CUDA Toolkit and Driver, to either build or execute. These dependencies are listed below.
@@ -425,11 +494,20 @@ OpenGL is a graphics library used for 2D and 3D rendering. On systems which supp
OpenGL ES is an embedded systems graphics library used for 2D and 3D rendering. On systems which support OpenGL ES, NVIDIA's OpenGL ES implementation is provided with the CUDA Driver. OpenGL ES is an embedded systems graphics library used for 2D and 3D rendering. On systems which support OpenGL ES, NVIDIA's OpenGL ES implementation is provided with the CUDA Driver.
#### Freeglut
Freeglut is an open-source software library that serves as a replacement for the original OpenGL Utility Toolkit (GLUT). Its primary purpose is to make it easier for developers to create and manage windows containing OpenGL contexts, as well as handle input from devices like the mouse, keyboard, and joystick, across a wide range of platforms. To set up Freeglut on a Windowson on ARM system, you need to download the source from [Freeglut website](https://freeglut.sourceforge.net/), build freeglut on your system, and copy the freeglut.lib into the folder `./Common/lib/x64` and copy the freeglut.dll file into the `./bin/win64/${BUILD_TYPE}` execution folder.
#### Vulkan #### Vulkan
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/).
#### GLEW
GLEW (OpenGL Extension Wrangler Library) is a cross-platform, open-source C/C++ library designed to simplify the process of using modern OpenGL features and extensions. Its main function is to dynamically load OpenGL function pointers at runtime, allowing developers to access both core OpenGL functions and additional features provided by hardware vendors, known as extensions. To set up GLEW on a Windows on ARM system, you need to download the source from [GLEW website](https://glew.sourceforge.net/), build GLEW on your system, and copy the glew32.lib into the folder `./Common/lib/x64` and the glew32.dll into the `./bin/win64/${BUILD_TYPE}` execution folder.
#### GLFW #### 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. 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 folder as `-DGLFW_INCLUDE_DIR` and lib folder as `-DGLFW_LIB_DIR` for cmake configuring. 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 folder as `-DGLFW_INCLUDE_DIR` and lib folder as `-DGLFW_LIB_DIR` for cmake configuring.
@@ -526,6 +604,11 @@ NVJPEG library provides high-performance, GPU accelerated JPEG decoding function
NVRTC (CUDA RunTime Compilation) is a runtime compilation library for CUDA C++. NVRTC (CUDA RunTime Compilation) is a runtime compilation library for CUDA C++.
#### NVJITLINK
NVJITLINK is a CUDA runtime library that links multiple GPU device code objects at runtime and enables just‑in‑time link‑time optimization (JIT LTO).
It can take device code from tools such as NVCC and NVRTC, link and optimize it on the fly, and produce the final GPU binary.For more details, see: https://docs.nvidia.com/cuda/nvjitlink/index.html
#### Stream Priorities #### Stream Priorities
Stream Priorities allows the creation of streams with specified priorities. Stream Priorities is only available on GPUs with SM architecture of 3.5 or above. Stream Priorities allows the creation of streams with specified priorities. Stream Priorities is only available on GPUs with SM architecture of 3.5 or above.
@@ -558,7 +641,7 @@ Answers to frequently asked questions about CUDA can be found at http://develope
## References ## References
* [CUDA Programming Guide](http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html) * [CUDA Programming Guide](https://docs.nvidia.com/cuda/cuda-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 ## Attributions

View File

@@ -49,3 +49,7 @@ target_compile_features(UnifiedMemoryStreams PRIVATE cxx_std_17 cuda_std_17)
else() else()
message(STATUS "OpenMP not found - will not build sample 'UnifiedMemoryStreams'") message(STATUS "OpenMP not found - will not build sample 'UnifiedMemoryStreams'")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -24,7 +24,7 @@ x86_64, armv7l
cudaStreamDestroy, cudaFree, cudaMallocManaged, cudaStreamAttachMemAsync, cudaSetDevice, cudaDeviceSynchronize, cudaStreamSynchronize, cudaStreamCreate, cudaGetDeviceProperties cudaStreamDestroy, cudaFree, cudaMallocManaged, cudaStreamAttachMemAsync, cudaSetDevice, cudaDeviceSynchronize, cudaStreamSynchronize, cudaStreamCreate, cudaGetDeviceProperties
## Dependencies needed to build/run ## Dependencies needed to build/run
[OpenMP](../../../README.md#openmp), [UVM](../../../README.md#uvm), [CUBLAS](../../../README.md#cublas) [OpenMP](../../../README.md#openmp), [UVM](../../../README.md#unified-virtual-memory), [CUBLAS](../../../README.md#cublas)
## Prerequisites ## Prerequisites

View File

@@ -28,3 +28,7 @@ target_compile_options(asyncAPI PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-la
target_compile_features(asyncAPI PRIVATE cxx_std_17 cuda_std_17) target_compile_features(asyncAPI PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(asyncAPI PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(asyncAPI PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(clock PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambd
target_compile_features(clock PRIVATE cxx_std_17 cuda_std_17) target_compile_features(clock PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(clock PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(clock PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -37,3 +37,7 @@ add_custom_command(TARGET clock_nvrtc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/clock_kernel.cu ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/clock_kernel.cu ${CMAKE_CURRENT_BINARY_DIR}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -37,3 +37,7 @@ target_compile_features(cudaOpenMP PRIVATE cxx_std_17 cuda_std_17)
else() else()
message(STATUS "OpenMP not found - will not build sample 'cudaOpenMP'") message(STATUS "OpenMP not found - will not build sample 'cudaOpenMP'")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -27,3 +27,7 @@ target_compile_options(fp16ScalarProduct PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--ex
target_compile_features(fp16ScalarProduct PRIVATE cxx_std_17 cuda_std_17) target_compile_features(fp16ScalarProduct PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(fp16ScalarProduct PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(fp16ScalarProduct PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64, armv7l
cudaMemcpy, cudaFree, cudaMallocHost, cudaFreeHost, cudaMalloc, cudaGetDeviceProperties cudaMemcpy, cudaFree, cudaMallocHost, cudaFreeHost, cudaMalloc, cudaGetDeviceProperties
## Dependencies needed to build/run ## Dependencies needed to build/run
[FP16](../../../README.md#fp16) [FP16](../../../README.md#16-bit-floating-point)
## Prerequisites ## Prerequisites

View File

@@ -94,7 +94,7 @@ scalarProductKernel_intrinsics(half2 const *const a, half2 const *const b, float
shArray[threadIdx.x] = __float2half2_rn(0.f); shArray[threadIdx.x] = __float2half2_rn(0.f);
half2 value = __float2half2_rn(0.f); half2 value = __float2half2_rn(0.f);
for (int i = threadIdx.x + blockDim.x + blockIdx.x; i < size; i += stride) { for (int i = threadIdx.x + blockDim.x * blockIdx.x; i < size; i += stride) {
value = __hfma2(a[i], b[i], value); value = __hfma2(a[i], b[i], value);
} }
@@ -118,7 +118,7 @@ scalarProductKernel_native(half2 const *const a, half2 const *const b, float *co
half2 value(0.f, 0.f); half2 value(0.f, 0.f);
shArray[threadIdx.x] = value; shArray[threadIdx.x] = value;
for (int i = threadIdx.x + blockDim.x + blockIdx.x; i < size; i += stride) { for (int i = threadIdx.x + blockDim.x * blockIdx.x; i < size; i += stride) {
value = a[i] * b[i] + value; value = a[i] * b[i] + value;
} }

View File

@@ -28,3 +28,7 @@ target_compile_options(matrixMul PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-l
target_compile_features(matrixMul PRIVATE cxx_std_17 cuda_std_17) target_compile_features(matrixMul PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(matrixMul PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(matrixMul PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -66,3 +66,7 @@ add_custom_target(generate_fatbin_matmulDrv ALL DEPENDS ${CUDA_FATBIN_FILE})
# Ensure matrixMulDrv depends on the fatbin # Ensure matrixMulDrv depends on the fatbin
add_dependencies(matrixMulDrv generate_fatbin_matmulDrv) add_dependencies(matrixMulDrv generate_fatbin_matmulDrv)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -255,6 +255,7 @@ void runTest(int argc, char **argv)
checkCudaErrors(cuMemFree(d_A)); checkCudaErrors(cuMemFree(d_A));
checkCudaErrors(cuMemFree(d_B)); checkCudaErrors(cuMemFree(d_B));
checkCudaErrors(cuMemFree(d_C)); checkCudaErrors(cuMemFree(d_C));
checkCudaErrors(cuModuleUnload(cuModule));
checkCudaErrors(cuCtxDestroy(cuContext)); checkCudaErrors(cuCtxDestroy(cuContext));
} }

View File

@@ -45,3 +45,7 @@ target_link_libraries(matrixMulDynlinkJIT PUBLIC
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(matrixMulDynlinkJIT PUBLIC dl) target_link_libraries(matrixMulDynlinkJIT PUBLIC dl)
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -242,12 +242,23 @@ static CUresult LOAD_LIBRARY(CUDADRIVER *pInstance)
if (*pInstance == NULL) { if (*pInstance == NULL) {
printf("LoadLibrary \"%s\" failed!\n", __CudaLibName); printf("LoadLibrary \"%s\" failed!\n", __CudaLibName);
return CUDA_ERROR_UNKNOWN; exit(EXIT_FAILURE);
} }
return CUDA_SUCCESS; return CUDA_SUCCESS;
} }
CUresult GET_DRIVER_HANDLE(CUDADRIVER *pInstance)
{
*pInstance = GetModuleHandle(__CudaLibName);
if (*pInstance) {
return CUDA_SUCCESS;
}
else {
return CUDA_ERROR_UNKNOWN;
}
}
#define GET_PROC_EX(name, alias, required) \ #define GET_PROC_EX(name, alias, required) \
alias = (t##name *)GetProcAddress(CudaDrvLib, #name); \ alias = (t##name *)GetProcAddress(CudaDrvLib, #name); \
if (alias == NULL && required) { \ if (alias == NULL && required) { \
@@ -269,6 +280,13 @@ static CUresult LOAD_LIBRARY(CUDADRIVER *pInstance)
return CUDA_ERROR_UNKNOWN; \ return CUDA_ERROR_UNKNOWN; \
} }
#define GET_PROC_ERROR_FUNCTIONS(name, alias, required) \
alias = (t##name *)GetProcAddress(CudaDrvLib, #name); \
if (alias == NULL && required) { \
printf("Failed to find error function \"%s\" in %s\n", #name, __CudaLibName); \
exit(EXIT_FAILURE); \
}
#elif defined(__unix__) || defined(__QNX__) || defined(__APPLE__) || defined(__MACOSX) #elif defined(__unix__) || defined(__QNX__) || defined(__APPLE__) || defined(__MACOSX)
#include <dlfcn.h> #include <dlfcn.h>
@@ -293,12 +311,23 @@ static CUresult LOAD_LIBRARY(CUDADRIVER *pInstance)
if (*pInstance == NULL) { if (*pInstance == NULL) {
printf("dlopen \"%s\" failed!\n", __CudaLibName); printf("dlopen \"%s\" failed!\n", __CudaLibName);
return CUDA_ERROR_UNKNOWN; exit(EXIT_FAILURE);
} }
return CUDA_SUCCESS; return CUDA_SUCCESS;
} }
CUresult GET_DRIVER_HANDLE(CUDADRIVER *pInstance)
{
*pInstance = dlopen(__CudaLibName, RTLD_LAZY);
if (*pInstance) {
return CUDA_SUCCESS;
}
else {
return CUDA_ERROR_UNKNOWN;
}
}
#define GET_PROC_EX(name, alias, required) \ #define GET_PROC_EX(name, alias, required) \
alias = (t##name *)dlsym(CudaDrvLib, #name); \ alias = (t##name *)dlsym(CudaDrvLib, #name); \
if (alias == NULL && required) { \ if (alias == NULL && required) { \
@@ -320,6 +349,13 @@ static CUresult LOAD_LIBRARY(CUDADRIVER *pInstance)
return CUDA_ERROR_UNKNOWN; \ return CUDA_ERROR_UNKNOWN; \
} }
#define GET_PROC_ERROR_FUNCTIONS(name, alias, required) \
alias = (t##name *)dlsym(CudaDrvLib, #name); \
if (alias == NULL && required) { \
printf("Failed to find error function \"%s\" in %s\n", #name, __CudaLibName); \
exit(EXIT_FAILURE); \
}
#else #else
#error unsupported platform #error unsupported platform
#endif #endif
@@ -338,6 +374,15 @@ static CUresult LOAD_LIBRARY(CUDADRIVER *pInstance)
#define GET_PROC_V2(name) GET_PROC_EX_V2(name, name, 1) #define GET_PROC_V2(name) GET_PROC_EX_V2(name, name, 1)
#define GET_PROC_V3(name) GET_PROC_EX_V3(name, name, 1) #define GET_PROC_V3(name) GET_PROC_EX_V3(name, name, 1)
CUresult INIT_ERROR_FUNCTIONS(void)
{
CUDADRIVER CudaDrvLib;
CUresult result = CUDA_SUCCESS;
result = GET_DRIVER_HANDLE(&CudaDrvLib);
GET_PROC_ERROR_FUNCTIONS(cuGetErrorString, cuGetErrorString, 1);
return result;
}
CUresult CUDAAPI cuInit(unsigned int Flags, int cudaVersion) CUresult CUDAAPI cuInit(unsigned int Flags, int cudaVersion)
{ {
CUDADRIVER CudaDrvLib; CUDADRIVER CudaDrvLib;
@@ -619,6 +664,5 @@ CUresult CUDAAPI cuInit(unsigned int Flags, int cudaVersion)
GET_PROC(cuGraphicsD3D9RegisterResource); GET_PROC(cuGraphicsD3D9RegisterResource);
#endif #endif
} }
return CUDA_SUCCESS; return CUDA_SUCCESS;
} }

View File

@@ -42,11 +42,21 @@ inline int ftoi(float value) { return (value >= 0 ? static_cast<int>(value + 0.5
#ifndef checkCudaErrors #ifndef checkCudaErrors
#define checkCudaErrors(err) __checkCudaErrors(err, __FILE__, __LINE__) #define checkCudaErrors(err) __checkCudaErrors(err, __FILE__, __LINE__)
extern "C" CUresult INIT_ERROR_FUNCTIONS(void);
// These are the inline versions for all of the SDK helper functions // These are the inline versions for all of the SDK helper functions
inline void __checkCudaErrors(CUresult err, const char *file, const int line) inline void __checkCudaErrors(CUresult err, const char *file, const int line)
{ {
if (CUDA_SUCCESS != err) { if (CUDA_SUCCESS != err) {
const char *errorStr = NULL; const char *errorStr = NULL;
if (!cuGetErrorString) {
CUresult result = INIT_ERROR_FUNCTIONS();
if (result != CUDA_SUCCESS) {
printf("CUDA driver API failed");
exit(EXIT_FAILURE);
}
}
cuGetErrorString(err, &errorStr); cuGetErrorString(err, &errorStr);
fprintf(stderr, fprintf(stderr,
"checkCudaErrors() Driver API error = %04d \"%s\" from file <%s>, " "checkCudaErrors() Driver API error = %04d \"%s\" from file <%s>, "

View File

@@ -68,6 +68,7 @@ extern "C" void computeGold(float *, const float *, const float *, unsigned int,
// Globals // Globals
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CUcontext g_cuContext; CUcontext g_cuContext;
CUmodule g_cuModule;
bool noprompt = false; bool noprompt = false;
static const char *sSDKsample = "matrixMulDynlinkJIT (CUDA dynamic linking)"; static const char *sSDKsample = "matrixMulDynlinkJIT (CUDA dynamic linking)";
@@ -90,7 +91,6 @@ CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul, int *block_size
{ {
CUresult status; CUresult status;
CUdevice cuDevice; CUdevice cuDevice;
CUmodule cuModule;
CUfunction cuFunction; CUfunction cuFunction;
int major, minor, block_size, devID = 0; int major, minor, block_size, devID = 0;
char deviceName[256]; char deviceName[256];
@@ -184,11 +184,11 @@ CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul, int *block_size
printf("> Compiling CUDA module\n"); printf("> Compiling CUDA module\n");
#if defined(_WIN64) || defined(__LP64__) #if defined(_WIN64) || defined(__LP64__)
status = status = cuModuleLoadDataEx(
cuModuleLoadDataEx(&cuModule, matrixMul_kernel_64_ptxdump, jitNumOptions, jitOptions, (void **)jitOptVals); &g_cuModule, matrixMul_kernel_64_ptxdump, jitNumOptions, jitOptions, (void **)jitOptVals);
#else #else
status = status = cuModuleLoadDataEx(
cuModuleLoadDataEx(&cuModule, matrixMul_kernel_32_ptxdump, jitNumOptions, jitOptions, (void **)jitOptVals); &g_cuModule, matrixMul_kernel_32_ptxdump, jitNumOptions, jitOptions, (void **)jitOptVals);
#endif #endif
printf("> PTX JIT log:\n%s\n", jitLogBuffer); printf("> PTX JIT log:\n%s\n", jitLogBuffer);
@@ -206,9 +206,10 @@ CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul, int *block_size
// retrieve CUDA function from the compiled module // retrieve CUDA function from the compiled module
status = cuModuleGetFunction( status = cuModuleGetFunction(
&cuFunction, cuModule, (block_size == 16) ? "matrixMul_bs16_32bit" : "matrixMul_bs32_32bit"); &cuFunction, g_cuModule, (block_size == 16) ? "matrixMul_bs16_32bit" : "matrixMul_bs32_32bit");
if (CUDA_SUCCESS != status) { if (CUDA_SUCCESS != status) {
cuModuleUnload(g_cuModule);
cuCtxDestroy(g_cuContext); cuCtxDestroy(g_cuContext);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@@ -337,6 +338,7 @@ int main(int argc, char **argv)
checkCudaErrors(cuMemFree(d_A)); checkCudaErrors(cuMemFree(d_A));
checkCudaErrors(cuMemFree(d_B)); checkCudaErrors(cuMemFree(d_B));
checkCudaErrors(cuMemFree(d_C)); checkCudaErrors(cuMemFree(d_C));
checkCudaErrors(cuModuleUnload(g_cuModule));
checkCudaErrors(cuCtxDestroy(g_cuContext)); checkCudaErrors(cuCtxDestroy(g_cuContext));
printf("Test run %s\n", (1 == res) ? "success!" : "failed!"); printf("Test run %s\n", (1 == res) ? "success!" : "failed!");

View File

@@ -55,3 +55,7 @@ add_custom_command(TARGET matrixMul_nvrtc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory COMMAND ${CMAKE_COMMAND} -E copy_directory
${CUDA_INCLUDE_DIR}/cccl/cuda ${CMAKE_CURRENT_BINARY_DIR}/cuda ${CUDA_INCLUDE_DIR}/cccl/cuda ${CMAKE_CURRENT_BINARY_DIR}/cuda
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -31,3 +31,7 @@ set_target_properties(mergeSort PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(mergeSort PRIVATE target_include_directories(mergeSort PRIVATE
${CUDAToolkit_INCLUDE_DIRS} ${CUDAToolkit_INCLUDE_DIRS}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -35,3 +35,7 @@ target_compile_options(simpleAWBarrier PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--exte
target_compile_features(simpleAWBarrier PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleAWBarrier PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleAWBarrier PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleAWBarrier PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64, armv7l, aarch64
cudaStreamCreateWithFlags, cudaFree, cudaDeviceGetAttribute, cudaMallocHost, cudaFreeHost, cudaStreamSynchronize, cudaLaunchCooperativeKernel, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaMemcpyAsync, cudaOccupancyMaxPotentialBlockSize cudaStreamCreateWithFlags, cudaFree, cudaDeviceGetAttribute, cudaMallocHost, cudaFreeHost, cudaStreamSynchronize, cudaLaunchCooperativeKernel, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaMemcpyAsync, cudaOccupancyMaxPotentialBlockSize
## Dependencies needed to build/run ## Dependencies needed to build/run
[CPP11](../../../README.md#cpp11), [MBCG](../../../README.md#mbcg) [C++11 CUDA](../../../README.md#c11-cuda), [MBCG](../../../README.md#multi-block-cooperative-groups)
## Prerequisites ## Prerequisites

View File

@@ -31,3 +31,7 @@ target_compile_options(simpleAssert PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extende
target_compile_features(simpleAssert PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleAssert PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleAssert PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleAssert PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -37,3 +37,7 @@ add_custom_command(TARGET simpleAssert_nvrtc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/simpleAssert_kernel.cu ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/simpleAssert_kernel.cu ${CMAKE_CURRENT_BINARY_DIR}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -29,3 +29,7 @@ target_compile_options(simpleAtomicIntrinsics PRIVATE $<$<COMPILE_LANGUAGE:CUDA>
target_compile_features(simpleAtomicIntrinsics PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleAtomicIntrinsics PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleAtomicIntrinsics PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleAtomicIntrinsics PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -38,3 +38,7 @@ add_custom_command(TARGET simpleAtomicIntrinsics_nvrtc POST_BUILD
${CMAKE_CURRENT_SOURCE_DIR}/simpleAtomicIntrinsics_kernel.cuh ${CMAKE_CURRENT_SOURCE_DIR}/simpleAtomicIntrinsics_kernel.cuh
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleAttributes PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--ext
target_compile_features(simpleAttributes PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleAttributes PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleAttributes PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleAttributes PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -22,6 +22,12 @@ include_directories(../../../Common)
if(WIN32) if(WIN32)
set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common") set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common")
set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64") set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64")
# The GLEW library built on Windows on Arm system is named as glew32.lib/glew32.dll by default.
if(EXISTS "${PC_GLUT_LIBRARY_DIRS}/glew32.lib")
set(GLEW_LIB_NAME "glew32")
else()
set(GLEW_LIB_NAME "glew64")
endif()
endif() endif()
@@ -56,7 +62,7 @@ if(${OpenGL_FOUND})
if(WIN32) if(WIN32)
target_link_libraries(simpleCUDA2GL target_link_libraries(simpleCUDA2GL
${PC_GLUT_LIBRARY_DIRS}/freeglut.lib ${PC_GLUT_LIBRARY_DIRS}/freeglut.lib
${PC_GLUT_LIBRARY_DIRS}/glew64.lib ${PC_GLUT_LIBRARY_DIRS}/${GLEW_LIB_NAME}.lib
) )
add_custom_command(TARGET simpleCUDA2GL add_custom_command(TARGET simpleCUDA2GL
@@ -69,7 +75,7 @@ if(${OpenGL_FOUND})
add_custom_command(TARGET simpleCUDA2GL add_custom_command(TARGET simpleCUDA2GL
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E COMMAND ${CMAKE_COMMAND} -E
copy ${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/glew64.dll copy ${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/${GLEW_LIB_NAME}.dll
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION> ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>
) )
endif() endif()
@@ -80,3 +86,7 @@ if(${OpenGL_FOUND})
else() else()
message(STATUS "OpenGL not found - will not build sample 'simpleCUDA2GL'") message(STATUS "OpenGL not found - will not build sample 'simpleCUDA2GL'")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64
cudaHostAlloc, cudaGraphicsUnmapResources, cudaMalloc, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaMemcpyToArray, cudaDeviceSynchronize, cudaProcess, cudaGraphicsUnregisterResource, cudaGraphicsSubResourceGetMappedArray, cudaGraphicsGLRegisterBuffer, cudaGraphicsGLRegisterImage cudaHostAlloc, cudaGraphicsUnmapResources, cudaMalloc, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaMemcpyToArray, cudaDeviceSynchronize, cudaProcess, cudaGraphicsUnregisterResource, cudaGraphicsSubResourceGetMappedArray, cudaGraphicsGLRegisterBuffer, cudaGraphicsGLRegisterImage
## Dependencies needed to build/run ## Dependencies needed to build/run
[X11](../../../README.md#x11), [GL](../../../README.md#gl) [X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
## Prerequisites ## Prerequisites

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleCallback PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--exten
target_compile_features(simpleCallback PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleCallback PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleCallback PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleCallback PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleCooperativeGroups PRIVATE $<$<COMPILE_LANGUAGE:CUDA
target_compile_features(simpleCooperativeGroups PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleCooperativeGroups PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleCooperativeGroups PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleCooperativeGroups PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleCubemapTexture PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-
target_compile_features(simpleCubemapTexture PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleCubemapTexture PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleCubemapTexture PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleCubemapTexture PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -68,3 +68,7 @@ add_custom_target(generate_fatbin_simpleDrv ALL DEPENDS ${CUDA_FATBIN_FILE})
# Ensure simpleDrvRuntime depends on the fatbin # Ensure simpleDrvRuntime depends on the fatbin
add_dependencies(simpleDrvRuntime generate_fatbin_simpleDrv) add_dependencies(simpleDrvRuntime generate_fatbin_simpleDrv)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleHyperQ PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extende
target_compile_features(simpleHyperQ PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleHyperQ PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleHyperQ PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleHyperQ PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -32,3 +32,7 @@ else()
set_target_properties(simpleIPC PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleIPC PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64, ppc64le
cudaSetDevice, cudaIpcCloseMemHandle, cudaEventDestroy, cudaGetDeviceCount, cudaMemcpyAsync, cudaDeviceCanAccessPeer, cudaStreamCreateWithFlags, cudaStreamDestroy, cudaGetLastError, cudaIpcOpenEventHandle, cudaIpcOpenMemHandle, cudaIpcGetEventHandle, cudaStreamWaitEvent, cudaEventCreate, cudaFree, cudaEventSynchronize, cudaEventRecord, cudaIpcGetMemHandle, cudaStreamSynchronize, cudaDeviceEnablePeerAccess, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties cudaSetDevice, cudaIpcCloseMemHandle, cudaEventDestroy, cudaGetDeviceCount, cudaMemcpyAsync, cudaDeviceCanAccessPeer, cudaStreamCreateWithFlags, cudaStreamDestroy, cudaGetLastError, cudaIpcOpenEventHandle, cudaIpcOpenMemHandle, cudaIpcGetEventHandle, cudaStreamWaitEvent, cudaEventCreate, cudaFree, cudaEventSynchronize, cudaEventRecord, cudaIpcGetMemHandle, cudaStreamSynchronize, cudaDeviceEnablePeerAccess, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties
## Dependencies needed to build/run ## Dependencies needed to build/run
[IPC](../../../README.md#ipc) [IPC](../../../README.md#cuda-interprocess-communication)
## Prerequisites ## Prerequisites

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleLayeredTexture PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-
target_compile_features(simpleLayeredTexture PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleLayeredTexture PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleLayeredTexture PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleLayeredTexture PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -44,3 +44,7 @@ target_compile_features(simpleMPI PRIVATE cxx_std_17 cuda_std_17)
else() else()
message(STATUS "MPI not found - will not build sample 'simpleMPI'") message(STATUS "MPI not found - will not build sample 'simpleMPI'")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64, aarch64
cudaMalloc, cudaGetLastError, cudaMemcpy, cudaFree cudaMalloc, cudaGetLastError, cudaMemcpy, cudaFree
## Dependencies needed to build/run ## Dependencies needed to build/run
[MPI](../../../README.md#mpi) [MPI](../../../README.md#message-passing-interface)
## Prerequisites ## Prerequisites

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleMultiCopy PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--exte
target_compile_features(simpleMultiCopy PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleMultiCopy PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleMultiCopy PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleMultiCopy PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleMultiGPU PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--exten
target_compile_features(simpleMultiGPU PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleMultiGPU PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleMultiGPU PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleMultiGPU PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleOccupancy PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--exte
target_compile_features(simpleOccupancy PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleOccupancy PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleOccupancy PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleOccupancy PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cstdint>
#include <helper_cuda.h> // helper functions for CUDA error check #include <helper_cuda.h> // helper functions for CUDA error check
#include <iostream> #include <iostream>
@@ -38,7 +39,7 @@ const int manualBlockSize = 32;
// execution configuration, including anything the launch configurator // execution configuration, including anything the launch configurator
// API suggests. // API suggests.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
__global__ void square(int *array, int arrayCount) __global__ void square(uint32_t *array, int arrayCount)
{ {
extern __shared__ int dynamicSmem[]; extern __shared__ int dynamicSmem[];
int idx = threadIdx.x + blockIdx.x * blockDim.x; int idx = threadIdx.x + blockIdx.x * blockDim.x;
@@ -99,7 +100,7 @@ static double reportPotentialOccupancy(void *kernel, int blockSize, size_t dynam
// This function configures the launch based on the "automatic" // This function configures the launch based on the "automatic"
// argument, records the runtime, and reports occupancy and runtime. // argument, records the runtime, and reports occupancy and runtime.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static int launchConfig(int *array, int arrayCount, bool automatic) static int launchConfig(uint32_t *array, int arrayCount, bool automatic)
{ {
int blockSize; int blockSize;
int minGridSize; int minGridSize;
@@ -166,20 +167,20 @@ static int launchConfig(int *array, int arrayCount, bool automatic)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static int test(bool automaticLaunchConfig, const int count = 1000000) static int test(bool automaticLaunchConfig, const int count = 1000000)
{ {
int *array; uint32_t *array;
int *dArray; uint32_t *dArray;
int size = count * sizeof(int); int size = count * sizeof(uint32_t);
array = new int[count]; array = new uint32_t[count];
for (int i = 0; i < count; i += 1) { for (uint32_t i = 0; i < count; i += 1) {
array[i] = i; array[i] = i;
} }
checkCudaErrors(cudaMalloc(&dArray, size)); checkCudaErrors(cudaMalloc(&dArray, size));
checkCudaErrors(cudaMemcpy(dArray, array, size, cudaMemcpyHostToDevice)); checkCudaErrors(cudaMemcpy(dArray, array, size, cudaMemcpyHostToDevice));
for (int i = 0; i < count; i += 1) { for (uint32_t i = 0; i < count; i += 1) {
array[i] = 0; array[i] = 0;
} }
@@ -189,8 +190,9 @@ static int test(bool automaticLaunchConfig, const int count = 1000000)
checkCudaErrors(cudaFree(dArray)); checkCudaErrors(cudaFree(dArray));
// Verify the return data // Verify the return data
// Both GPU and CPU use uint32_t * uint32_t, which has well-defined overflow behavior (modulo 2^32)
// //
for (int i = 0; i < count; i += 1) { for (uint32_t i = 0; i < count; i += 1) {
if (array[i] != i * i) { if (array[i] != i * i) {
std::cout << "element " << i << " expected " << i * i << " actual " << array[i] << std::endl; std::cout << "element " << i << " expected " << i * i << " actual " << array[i] << std::endl;
return 1; return 1;

View File

@@ -32,3 +32,7 @@ else()
set_target_properties(simpleP2P PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleP2P PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simplePitchLinearTexture PRIVATE $<$<COMPILE_LANGUAGE:CUD
target_compile_features(simplePitchLinearTexture PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simplePitchLinearTexture PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simplePitchLinearTexture PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simplePitchLinearTexture PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simplePrintf PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extende
target_compile_features(simplePrintf PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simplePrintf PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simplePrintf PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simplePrintf PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleStreams PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extend
target_compile_features(simpleStreams PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleStreams PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleStreams PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleStreams PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -35,3 +35,7 @@ add_custom_command(TARGET simpleSurfaceWrite POST_BUILD
${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_SOURCE_DIR}/data
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleTemplates PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--exte
target_compile_features(simpleTemplates PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleTemplates PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleTemplates PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleTemplates PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -42,3 +42,7 @@ add_custom_command(TARGET simpleTexture POST_BUILD
${CMAKE_CURRENT_SOURCE_DIR}/data/ref_rotated.pgm ${CMAKE_CURRENT_SOURCE_DIR}/data/ref_rotated.pgm
${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -22,6 +22,12 @@ include_directories(../../../Common)
if(WIN32) if(WIN32)
set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common") set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common")
set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64") set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64")
# The GLEW library built on Windows on Arm system is named as glew32.lib/glew32.dll by default.
if(EXISTS "${PC_GLUT_LIBRARY_DIRS}/glew32.lib")
set(GLEW_LIB_NAME "glew32")
else()
set(GLEW_LIB_NAME "glew64")
endif()
endif() endif()
find_package(OpenGL) find_package(OpenGL)
@@ -60,7 +66,7 @@ if(${OpenGL_FOUND})
if(WIN32) if(WIN32)
target_link_libraries(simpleTexture3D target_link_libraries(simpleTexture3D
${PC_GLUT_LIBRARY_DIRS}/freeglut.lib ${PC_GLUT_LIBRARY_DIRS}/freeglut.lib
${PC_GLUT_LIBRARY_DIRS}/glew64.lib ${PC_GLUT_LIBRARY_DIRS}/${GLEW_LIB_NAME}.lib
) )
add_custom_command(TARGET simpleTexture3D add_custom_command(TARGET simpleTexture3D
@@ -73,7 +79,7 @@ if(${OpenGL_FOUND})
add_custom_command(TARGET simpleTexture3D add_custom_command(TARGET simpleTexture3D
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/glew64.dll ${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/${GLEW_LIB_NAME}.dll
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION> ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>
) )
endif() endif()
@@ -84,3 +90,7 @@ if(${OpenGL_FOUND})
else() else()
message(STATUS "OpenGL not found - will not build sample 'simpleTexture3D'") message(STATUS "OpenGL not found - will not build sample 'simpleTexture3D'")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64, armv7l
cudaGraphicsUnmapResources, cudaMemcpy, cudaFreeArray, cudaFree, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaExtent, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer cudaGraphicsUnmapResources, cudaMemcpy, cudaFreeArray, cudaFree, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaExtent, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
## Dependencies needed to build/run ## Dependencies needed to build/run
[X11](../../../README.md#x11), [GL](../../../README.md#gl) [X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
## Prerequisites ## Prerequisites

View File

@@ -79,3 +79,7 @@ add_custom_target(generate_fatbin_textureDrv ALL DEPENDS ${CUDA_FATBIN_FILE})
# Ensure simpleTextureDrv depends on the fatbin # Ensure simpleTextureDrv depends on the fatbin
add_dependencies(simpleTextureDrv generate_fatbin_textureDrv) add_dependencies(simpleTextureDrv generate_fatbin_textureDrv)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -297,6 +297,7 @@ void runTest(int argc, char **argv)
free(image_path); free(image_path);
free(ref_path); free(ref_path);
checkCudaErrors(cuModuleUnload(cuModule));
checkCudaErrors(cuCtxDestroy(cuContext)); checkCudaErrors(cuCtxDestroy(cuContext));
exit(bTestResults ? EXIT_SUCCESS : EXIT_FAILURE); exit(bTestResults ? EXIT_SUCCESS : EXIT_FAILURE);

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleVoteIntrinsics PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-
target_compile_features(simpleVoteIntrinsics PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleVoteIntrinsics PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleVoteIntrinsics PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleVoteIntrinsics PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(simpleZeroCopy PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--exten
target_compile_features(simpleZeroCopy PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleZeroCopy PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleZeroCopy PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleZeroCopy PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -36,3 +36,7 @@ else()
message(STATUS "Will not build sample systemWideAtomics - requires Linux OS") message(STATUS "Will not build sample systemWideAtomics - requires Linux OS")
endif() endif()
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64, ppc64le
cudaDeviceSynchronize, cudaMallocManaged, cudaGetDeviceProperties, cudaFree cudaDeviceSynchronize, cudaMallocManaged, cudaGetDeviceProperties, cudaFree
## Dependencies needed to build/run ## Dependencies needed to build/run
[UVM](../../../README.md#uvm) [UVM](../../../README.md#unified-virtual-memory)
## Prerequisites ## Prerequisites

View File

@@ -297,6 +297,9 @@ int main(int argc, char **argv)
exit(EXIT_WAIVED); exit(EXIT_WAIVED);
} }
int concurrentManagedAccess;
checkCudaErrors(cudaDeviceGetAttribute(&concurrentManagedAccess, cudaDevAttrConcurrentManagedAccess, dev_id));
if (device_prop.major < 6) { if (device_prop.major < 6) {
printf("%s: requires a minimum CUDA compute 6.0 capability, waiving " printf("%s: requires a minimum CUDA compute 6.0 capability, waiving "
"testing.\n", "testing.\n",
@@ -326,6 +329,12 @@ int main(int argc, char **argv)
atom_arr[7] = atom_arr[9] = 0xff; atom_arr[7] = atom_arr[9] = 0xff;
atomicKernel<<<numBlocks, numThreads>>>(atom_arr); atomicKernel<<<numBlocks, numThreads>>>(atom_arr);
// Do device synchronize for devices that don't support concurrent managed access such as WSL.
if (!concurrentManagedAccess) {
checkCudaErrors(cudaDeviceSynchronize());
}
atomicKernel_CPU(atom_arr, numBlocks * numThreads); atomicKernel_CPU(atom_arr, numBlocks * numThreads);
checkCudaErrors(cudaDeviceSynchronize()); checkCudaErrors(cudaDeviceSynchronize());

View File

@@ -29,3 +29,7 @@ target_compile_options(template PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-la
target_compile_features(template PRIVATE cxx_std_17 cuda_std_17) target_compile_features(template PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(template PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(template PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -28,3 +28,7 @@ target_compile_options(vectorAdd PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-l
target_compile_features(vectorAdd PRIVATE cxx_std_17 cuda_std_17) target_compile_features(vectorAdd PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(vectorAdd PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(vectorAdd PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -65,3 +65,7 @@ add_custom_target(generate_fatbin_vectorAdd ALL DEPENDS ${CUDA_FATBIN_FILE})
# Ensure matrixMulDrv depends on the fatbin # Ensure matrixMulDrv depends on the fatbin
add_dependencies(vectorAddDrv generate_fatbin_vectorAdd) add_dependencies(vectorAddDrv generate_fatbin_vectorAdd)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -211,6 +211,7 @@ int CleanupNoFailure()
free(h_C); free(h_C);
} }
checkCudaErrors(cuModuleUnload(cuModule));
checkCudaErrors(cuCtxDestroy(cuContext)); checkCudaErrors(cuCtxDestroy(cuContext));
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@@ -61,3 +61,7 @@ else()
# Ensure matrixMulDrv depends on the fatbin # Ensure matrixMulDrv depends on the fatbin
add_dependencies(vectorAddMMAP generate_fatbin_vectorAddMMAP) add_dependencies(vectorAddMMAP generate_fatbin_vectorAddMMAP)
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -247,6 +247,7 @@ int CleanupNoFailure()
free(h_C); free(h_C);
} }
checkCudaErrors(cuModuleUnload(cuModule));
checkCudaErrors(cuCtxDestroy(cuContext)); checkCudaErrors(cuCtxDestroy(cuContext));
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@@ -37,3 +37,7 @@ add_custom_command(TARGET vectorAdd_nvrtc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/vectorAdd_kernel.cu ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/vectorAdd_kernel.cu ${CMAKE_CURRENT_BINARY_DIR}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -36,3 +36,7 @@ target_include_directories(deviceQuery PRIVATE
target_link_libraries(deviceQuery PUBLIC target_link_libraries(deviceQuery PUBLIC
CUDA::cudart CUDA::cudart
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -35,3 +35,7 @@ target_include_directories(deviceQueryDrv PRIVATE
target_link_libraries(deviceQueryDrv PUBLIC target_link_libraries(deviceQueryDrv PUBLIC
CUDA::cuda_driver CUDA::cuda_driver
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -32,3 +32,7 @@ else()
set_target_properties(topologyQuery PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(topologyQuery PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -48,3 +48,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
else() else()
message(STATUS "Will not build sample EGLStream_CUDA_CrossGPU - requires Linux OS") message(STATUS "Will not build sample EGLStream_CUDA_CrossGPU - requires Linux OS")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -49,3 +49,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
else() else()
message(STATUS "Will not build sample EGLStream_CUDA_Interop - requires Linux OS") message(STATUS "Will not build sample EGLStream_CUDA_Interop - requires Linux OS")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -22,6 +22,12 @@ include_directories(../../../Common)
if(WIN32) if(WIN32)
set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common") set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common")
set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64") set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64")
# The GLEW library built on Windows on Arm system is named as glew32.lib/glew32.dll by default.
if(EXISTS "${PC_GLUT_LIBRARY_DIRS}/glew32.lib")
set(GLEW_LIB_NAME "glew32")
else()
set(GLEW_LIB_NAME "glew64")
endif()
endif() endif()
find_package(OpenGL) find_package(OpenGL)
@@ -54,13 +60,13 @@ if(${OpenGL_FOUND})
add_custom_command(TARGET FunctionPointers POST_BUILD add_custom_command(TARGET FunctionPointers POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_SOURCE_DIR}/data
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/data
) )
if(WIN32) if(WIN32)
target_link_libraries(FunctionPointers target_link_libraries(FunctionPointers
${PC_GLUT_LIBRARY_DIRS}/freeglut.lib ${PC_GLUT_LIBRARY_DIRS}/freeglut.lib
${PC_GLUT_LIBRARY_DIRS}/glew64.lib ${PC_GLUT_LIBRARY_DIRS}/${GLEW_LIB_NAME}.lib
) )
add_custom_command(TARGET FunctionPointers add_custom_command(TARGET FunctionPointers
@@ -73,7 +79,7 @@ if(${OpenGL_FOUND})
add_custom_command(TARGET FunctionPointers add_custom_command(TARGET FunctionPointers
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/glew64.dll ${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/${GLEW_LIB_NAME}.dll
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION> ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>
) )
endif() endif()
@@ -84,3 +90,7 @@ if(${OpenGL_FOUND})
else() else()
message(STATUS "OpenGL not found - will not build sample 'FunctionPointers'") message(STATUS "OpenGL not found - will not build sample 'FunctionPointers'")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64, armv7l
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaMemcpyFromSymbol, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaMemcpyToSymbol, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaMemcpyFromSymbol, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaMemcpyToSymbol, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
## Dependencies needed to build/run ## Dependencies needed to build/run
[X11](../../../README.md#x11), [GL](../../../README.md#gl) [X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
## Prerequisites ## Prerequisites

View File

@@ -33,3 +33,7 @@ target_include_directories(MC_EstimatePiInlineP PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/inc
${CUDAToolkit_INCLUDE_DIRS} ${CUDAToolkit_INCLUDE_DIRS}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -37,3 +37,7 @@ target_include_directories(MC_EstimatePiInlineQ PUBLIC
target_link_libraries(MC_EstimatePiInlineQ PUBLIC target_link_libraries(MC_EstimatePiInlineQ PUBLIC
CUDA::curand CUDA::curand
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -37,3 +37,7 @@ target_include_directories(MC_EstimatePiP PUBLIC
target_link_libraries(MC_EstimatePiP PUBLIC target_link_libraries(MC_EstimatePiP PUBLIC
CUDA::curand CUDA::curand
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -37,3 +37,7 @@ target_include_directories(MC_EstimatePiQ PUBLIC
target_link_libraries(MC_EstimatePiQ PUBLIC target_link_libraries(MC_EstimatePiQ PUBLIC
CUDA::curand CUDA::curand
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -33,3 +33,7 @@ target_include_directories(MC_SingleAsianOptionP PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/inc
${CUDAToolkit_INCLUDE_DIRS} ${CUDAToolkit_INCLUDE_DIRS}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -10,9 +10,6 @@ This sample implements a separable convolution filter of a 2D signal with a gaus
### [convolutionTexture](./convolutionTexture) ### [convolutionTexture](./convolutionTexture)
Texture-based implementation of a separable 2D convolution with a gaussian kernel. Used for performance comparison against convolutionSeparable. Texture-based implementation of a separable 2D convolution with a gaussian kernel. Used for performance comparison against convolutionSeparable.
### [cuHook](./cuHook)
This sample demonstrates how to build and use an intercept library with CUDA. The library has to be loaded via LD_PRELOAD, e.g. LD_PRELOAD=<full_path>/libcuhook.so.1 ./cuHook
### [dct8x8](./dct8x8) ### [dct8x8](./dct8x8)
This sample demonstrates how Discrete Cosine Transform (DCT) for blocks of 8 by 8 pixels can be performed using CUDA: a naive implementation by definition and a more traditional approach used in many libraries. As opposed to implementing DCT in a fragment shader, CUDA allows for an easier and more efficient implementation. This sample demonstrates how Discrete Cosine Transform (DCT) for blocks of 8 by 8 pixels can be performed using CUDA: a naive implementation by definition and a more traditional approach used in many libraries. As opposed to implementing DCT in a fragment shader, CUDA allows for an easier and more efficient implementation.
@@ -22,9 +19,6 @@ Demonstrates CUDA and EGL Streams interop, where consumer's EGL Stream is on one
### [EGLStream_CUDA_Interop](./EGLStream_CUDA_Interop) ### [EGLStream_CUDA_Interop](./EGLStream_CUDA_Interop)
Demonstrates data exchange between CUDA and EGL Streams. Demonstrates data exchange between CUDA and EGL Streams.
### [EGLSync_CUDAEvent_Interop](./EGLSync_CUDAEvent_Interop)
Demonstrates interoperability between CUDA Event and EGL Sync/EGL Image using which one can achieve synchronization on GPU itself for GL-EGL-CUDA operations instead of blocking CPU for synchronization.
### [eigenvalues](./eigenvalues) ### [eigenvalues](./eigenvalues)
The computation of all or a subset of all eigenvalues is an important problem in Linear Algebra, statistics, physics, and many other fields. This sample demonstrates a parallel implementation of a bisection algorithm for the computation of all eigenvalues of a tridiagonal symmetric matrix of arbitrary size with CUDA. The computation of all or a subset of all eigenvalues is an important problem in Linear Algebra, statistics, physics, and many other fields. This sample demonstrates a parallel implementation of a bisection algorithm for the computation of all eigenvalues of a tridiagonal symmetric matrix of arbitrary size with CUDA.

View File

@@ -22,6 +22,12 @@ include_directories(../../../Common)
if(WIN32) if(WIN32)
set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common") set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common")
set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64") set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64")
# The GLEW library built on Windows on Arm system is named as glew32.lib/glew32.dll by default.
if(EXISTS "${PC_GLUT_LIBRARY_DIRS}/glew32.lib")
set(GLEW_LIB_NAME "glew32")
else()
set(GLEW_LIB_NAME "glew64")
endif()
endif() endif()
find_package(OpenGL) find_package(OpenGL)
@@ -52,29 +58,15 @@ if(${OpenGL_FOUND})
# Copy data files to output directory # Copy data files to output directory
add_custom_command(TARGET boxFilter POST_BUILD add_custom_command(TARGET boxFilter POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/data/teapot1024.ppm ${CMAKE_CURRENT_SOURCE_DIR}/data
${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/data
)
# Copy data files to output directory
add_custom_command(TARGET boxFilter POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/ref_14.ppm
${CMAKE_CURRENT_BINARY_DIR}/
)
# Copy data files to output directory
add_custom_command(TARGET boxFilter POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/data/ref_22.ppm
${CMAKE_CURRENT_BINARY_DIR}/
) )
if(WIN32) if(WIN32)
target_link_libraries(boxFilter target_link_libraries(boxFilter
${PC_GLUT_LIBRARY_DIRS}/freeglut.lib ${PC_GLUT_LIBRARY_DIRS}/freeglut.lib
${PC_GLUT_LIBRARY_DIRS}/glew64.lib ${PC_GLUT_LIBRARY_DIRS}/${GLEW_LIB_NAME}.lib
) )
add_custom_command(TARGET boxFilter add_custom_command(TARGET boxFilter
@@ -87,7 +79,7 @@ if(${OpenGL_FOUND})
add_custom_command(TARGET boxFilter add_custom_command(TARGET boxFilter
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/glew64.dll ${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/${GLEW_LIB_NAME}.dll
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION> ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>
) )
endif() endif()
@@ -98,3 +90,7 @@ if(${OpenGL_FOUND})
else() else()
message(STATUS "OpenGL not found - will not build sample 'boxFilter'") message(STATUS "OpenGL not found - will not build sample 'boxFilter'")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64, armv7l
cudaGraphicsUnmapResources, cudaCreateChannelDesc, cudaMallocArray, cudaFreeArray, cudaFree, cudaGetErrorString, cudaMemcpy, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer cudaGraphicsUnmapResources, cudaCreateChannelDesc, cudaMallocArray, cudaFreeArray, cudaFree, cudaGetErrorString, cudaMemcpy, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
## Dependencies needed to build/run ## Dependencies needed to build/run
[X11](../../../README.md#x11), [GL](../../../README.md#gl) [X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
## Prerequisites ## Prerequisites

View File

@@ -32,3 +32,7 @@ set_target_properties(convolutionSeparable PROPERTIES CUDA_SEPARABLE_COMPILATION
target_include_directories(convolutionSeparable PUBLIC target_include_directories(convolutionSeparable PUBLIC
${CUDAToolkit_INCLUDE_DIRS} ${CUDAToolkit_INCLUDE_DIRS}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -32,3 +32,7 @@ set_target_properties(convolutionTexture PROPERTIES CUDA_SEPARABLE_COMPILATION O
target_include_directories(convolutionTexture PUBLIC target_include_directories(convolutionTexture PUBLIC
${CUDAToolkit_INCLUDE_DIRS} ${CUDAToolkit_INCLUDE_DIRS}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -53,3 +53,7 @@ add_custom_command(TARGET dct8x8 POST_BUILD
${CMAKE_CURRENT_SOURCE_DIR}/data/teapot512.bmp ${CMAKE_CURRENT_SOURCE_DIR}/data/teapot512.bmp
${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -49,3 +49,7 @@ add_custom_command(TARGET eigenvalues POST_BUILD
${CMAKE_CURRENT_SOURCE_DIR}/data/reference.dat ${CMAKE_CURRENT_SOURCE_DIR}/data/reference.dat
${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -32,3 +32,7 @@ set_target_properties(histogram PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(histogram PUBLIC target_include_directories(histogram PUBLIC
${CUDAToolkit_INCLUDE_DIRS} ${CUDAToolkit_INCLUDE_DIRS}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -22,6 +22,12 @@ include_directories(../../../Common)
if(WIN32) if(WIN32)
set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common") set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common")
set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64") set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64")
# The GLEW library built on Windows on Arm system is named as glew32.lib/glew32.dll by default.
if(EXISTS "${PC_GLUT_LIBRARY_DIRS}/glew32.lib")
set(GLEW_LIB_NAME "glew32")
else()
set(GLEW_LIB_NAME "glew64")
endif()
endif() endif()
@@ -61,7 +67,7 @@ if(${OpenGL_FOUND})
if(WIN32) if(WIN32)
target_link_libraries(imageDenoising target_link_libraries(imageDenoising
${PC_GLUT_LIBRARY_DIRS}/freeglut.lib ${PC_GLUT_LIBRARY_DIRS}/freeglut.lib
${PC_GLUT_LIBRARY_DIRS}/glew64.lib ${PC_GLUT_LIBRARY_DIRS}/${GLEW_LIB_NAME}.lib
) )
add_custom_command(TARGET imageDenoising add_custom_command(TARGET imageDenoising
@@ -74,7 +80,7 @@ if(${OpenGL_FOUND})
add_custom_command(TARGET imageDenoising add_custom_command(TARGET imageDenoising
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/glew64.dll ${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/${GLEW_LIB_NAME}.dll
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION> ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>
) )
endif() endif()
@@ -85,3 +91,7 @@ if(${OpenGL_FOUND})
else() else()
message(STATUS "OpenGL not found - will not build sample 'imageDenoising'") message(STATUS "OpenGL not found - will not build sample 'imageDenoising'")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,8 +26,7 @@ x86_64, armv7l
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGLRegisterBufferObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGLRegisterBufferObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
## Dependencies needed to build/run ## Dependencies needed to build/run
[X11](../../../README.md#x11), [GL](../../../README.md#gl) [X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
## Prerequisites ## Prerequisites
Download and install the [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) for your corresponding platform. Download and install the [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.

View File

@@ -28,3 +28,7 @@ target_compile_options(inlinePTX PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-l
target_compile_features(inlinePTX PRIVATE cxx_std_17 cuda_std_17) target_compile_features(inlinePTX PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(inlinePTX PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(inlinePTX PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -39,3 +39,7 @@ add_custom_command(TARGET inlinePTX_nvrtc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/inlinePTX_kernel.cu ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inlinePTX_kernel.cu ${CMAKE_CURRENT_BINARY_DIR}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -32,3 +32,7 @@ set_target_properties(interval PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(interval PUBLIC target_include_directories(interval PUBLIC
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -22,6 +22,12 @@ include_directories(../../../Common)
if(WIN32) if(WIN32)
set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common") set(PC_GLUT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common")
set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64") set(PC_GLUT_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Common/lib/x64")
# The GLEW library built on Windows on Arm system is named as glew32.lib/glew32.dll by default.
if(EXISTS "${PC_GLUT_LIBRARY_DIRS}/glew32.lib")
set(GLEW_LIB_NAME "glew32")
else()
set(GLEW_LIB_NAME "glew64")
endif()
endif() endif()
find_package(OpenGL) find_package(OpenGL)
@@ -60,7 +66,7 @@ target_compile_features(particles PRIVATE cxx_std_17 cuda_std_17)
if(WIN32) if(WIN32)
target_link_libraries(particles target_link_libraries(particles
${PC_GLUT_LIBRARY_DIRS}/freeglut.lib ${PC_GLUT_LIBRARY_DIRS}/freeglut.lib
${PC_GLUT_LIBRARY_DIRS}/glew64.lib ${PC_GLUT_LIBRARY_DIRS}/${GLEW_LIB_NAME}.lib
) )
add_custom_command(TARGET particles add_custom_command(TARGET particles
@@ -73,7 +79,7 @@ target_compile_features(particles PRIVATE cxx_std_17 cuda_std_17)
add_custom_command(TARGET particles add_custom_command(TARGET particles
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/glew64.dll ${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/win64/$<CONFIGURATION>/${GLEW_LIB_NAME}.dll
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION> ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>
) )
endif() endif()
@@ -84,3 +90,7 @@ target_compile_features(particles PRIVATE cxx_std_17 cuda_std_17)
else() else()
message(STATUS "OpenGL not found - will not build sample 'particles'") message(STATUS "OpenGL not found - will not build sample 'particles'")
endif() endif()
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -26,7 +26,7 @@ x86_64, armv7l
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaMemset, cudaMemcpyToSymbol, cudaGraphicsGLRegisterBuffer, cudaGraphicsUnregisterResource, cudaMalloc, cudaInit, cudaGLInit cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaMemset, cudaMemcpyToSymbol, cudaGraphicsGLRegisterBuffer, cudaGraphicsUnregisterResource, cudaMalloc, cudaInit, cudaGLInit
## Dependencies needed to build/run ## Dependencies needed to build/run
[X11](../../../README.md#x11), [GL](../../../README.md#gl) [X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
## Prerequisites ## Prerequisites

View File

@@ -135,8 +135,8 @@ extern "C"
thrust::device_ptr<float4> d_pos4((float4 *)pos); thrust::device_ptr<float4> d_pos4((float4 *)pos);
thrust::device_ptr<float4> d_vel4((float4 *)vel); thrust::device_ptr<float4> d_vel4((float4 *)vel);
thrust::for_each(thrust::make_zip_iterator(thrust::make_tuple(d_pos4, d_vel4)), thrust::for_each(thrust::make_zip_iterator(d_pos4, d_vel4),
thrust::make_zip_iterator(thrust::make_tuple(d_pos4 + numParticles, d_vel4 + numParticles)), thrust::make_zip_iterator(d_pos4 + numParticles, d_vel4 + numParticles),
integrate_functor(deltaTime)); integrate_functor(deltaTime));
} }

View File

@@ -41,6 +41,9 @@
#include "thrust/iterator/zip_iterator.h" #include "thrust/iterator/zip_iterator.h"
#include "thrust/sort.h" #include "thrust/sort.h"
// for cuda::std::get
#include <cuda/std/utility>
namespace cg = cooperative_groups; namespace cg = cooperative_groups;
#include "helper_math.h" #include "helper_math.h"
#include "math_constants.h" #include "math_constants.h"
@@ -60,8 +63,8 @@ struct integrate_functor
template <typename Tuple> __device__ void operator()(Tuple t) template <typename Tuple> __device__ void operator()(Tuple t)
{ {
volatile float4 posData = thrust::get<0>(t); volatile float4 posData = cuda::std::get<0>(t);
volatile float4 velData = thrust::get<1>(t); volatile float4 velData = cuda::std::get<1>(t);
float3 pos = make_float3(posData.x, posData.y, posData.z); float3 pos = make_float3(posData.x, posData.y, posData.z);
float3 vel = make_float3(velData.x, velData.y, velData.z); float3 vel = make_float3(velData.x, velData.y, velData.z);
@@ -107,8 +110,8 @@ struct integrate_functor
} }
// store new position and velocity // store new position and velocity
thrust::get<0>(t) = make_float4(pos, posData.w); cuda::std::get<0>(t) = make_float4(pos, posData.w);
thrust::get<1>(t) = make_float4(vel, velData.w); cuda::std::get<1>(t) = make_float4(vel, velData.w);
} }
}; };

View File

@@ -28,3 +28,7 @@ target_compile_options(radixSortThrust PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--exte
target_compile_features(radixSortThrust PRIVATE cxx_std_17 cuda_std_17) target_compile_features(radixSortThrust PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(radixSortThrust PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(radixSortThrust PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

View File

@@ -32,3 +32,7 @@ set_target_properties(reduction PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(reduction PUBLIC target_include_directories(reduction PUBLIC
${CUDAToolkit_INCLUDE_DIRS} ${CUDAToolkit_INCLUDE_DIRS}
) )
# Include installation configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
setup_samples_install()

Some files were not shown because too many files have changed in this diff Show More