Merge branch 'master' into cuda_a_dev

This commit is contained in:
Rob Armstrong
2025-04-09 08:33:37 -07:00
24 changed files with 389 additions and 1279 deletions

View File

@@ -99,8 +99,21 @@ static void childProcess(int id)
std::vector<void *> ptrs;
std::vector<cudaEvent_t> events;
std::vector<char> verification_buffer(DATA_SIZE);
char pidString[20] = {0};
char lshmName[40] = {0};
if (sharedMemoryOpen(shmName, sizeof(shmStruct), &info) != 0) {
// Use parent process ID to create a unique shared memory name for Linux multi-process
#ifdef __linux__
pid_t pid;
pid = getppid();
snprintf(pidString, sizeof(pidString), "%d", pid);
#endif
strcat(lshmName, shmName);
strcat(lshmName, pidString);
printf("CP: lshmName = %s\n", lshmName);
if (sharedMemoryOpen(lshmName, sizeof(shmStruct), &info) != 0) {
printf("Failed to create shared memory slab\n");
exit(EXIT_FAILURE);
}
@@ -195,10 +208,23 @@ static void parentProcess(char *app)
std::vector<void *> ptrs;
std::vector<cudaEvent_t> events;
std::vector<Process> processes;
char pidString[20] = {0};
char lshmName[40] = {0};
// Use current process ID to create a unique shared memory name for Linux multi-process
#ifdef __linux__
pid_t pid;
pid = getpid();
snprintf(pidString, sizeof(pidString), "%d", pid);
#endif
strcat(lshmName, shmName);
strcat(lshmName, pidString);
printf("PP: lshmName = %s\n", lshmName);
checkCudaErrors(cudaGetDeviceCount(&devCount));
if (sharedMemoryCreate(shmName, sizeof(*shm), &info) != 0) {
if (sharedMemoryCreate(lshmName, sizeof(*shm), &info) != 0) {
printf("Failed to create shared memory slab\n");
exit(EXIT_FAILURE);
}

View File

@@ -1,4 +1,3 @@
add_subdirectory(bandwidthTest)
add_subdirectory(deviceQuery)
add_subdirectory(deviceQueryDrv)
add_subdirectory(topologyQuery)

View File

@@ -1,18 +0,0 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/../../../Common"
],
"defines": [],
"compilerPath": "/usr/local/cuda/bin/nvcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64",
"configurationProvider": "ms-vscode.makefile-tools"
}
],
"version": 4
}

View File

@@ -1,7 +0,0 @@
{
"recommendations": [
"nvidia.nsight-vscode-edition",
"ms-vscode.cpptools",
"ms-vscode.makefile-tools"
]
}

View File

@@ -1,10 +0,0 @@
{
"configurations": [
{
"name": "CUDA C++: Launch",
"type": "cuda-gdb",
"request": "launch",
"program": "${workspaceFolder}/bandwidthTest"
}
]
}

View File

@@ -1,15 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "sample",
"type": "shell",
"command": "make dbg=1",
"problemMatcher": ["$nvcc"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

View File

@@ -1,30 +0,0 @@
cmake_minimum_required(VERSION 3.20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
project(bandwidthTest LANGUAGES C CXX CUDA)
find_package(CUDAToolkit REQUIRED)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CUDA_ARCHITECTURES 75 80 86 87 89 90 100 101 120)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
if(ENABLE_CUDA_DEBUG)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (may significantly affect performance on some targets)
else()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -lineinfo") # add line information to all builds for debug tools (exclusive to -G option)
endif()
# Include directories and libraries
include_directories(../../../Common)
# Source file
# Add target for bandwidthTest
add_executable(bandwidthTest bandwidthTest.cu)
target_compile_options(bandwidthTest PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
target_compile_features(bandwidthTest PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(bandwidthTest PROPERTIES CUDA_SEPARABLE_COMPILATION ON)

View File

@@ -1,32 +0,0 @@
# bandwidthTest - Bandwidth Test
## Description
This is a simple test program to measure the memcopy bandwidth of the GPU and memcpy bandwidth across PCI-e. This test application is capable of measuring device to device copy bandwidth, host to device copy bandwidth for pageable and page-locked memory, and device to host copy bandwidth for pageable and page-locked memory.
## Key Concepts
CUDA Streams and Events, Performance Strategies
## Supported SM Architectures
[SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 5.3 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](https://developer.nvidia.com/cuda-gpus) [SM 7.5 ](https://developer.nvidia.com/cuda-gpus) [SM 8.0 ](https://developer.nvidia.com/cuda-gpus) [SM 8.6 ](https://developer.nvidia.com/cuda-gpus) [SM 8.7 ](https://developer.nvidia.com/cuda-gpus) [SM 8.9 ](https://developer.nvidia.com/cuda-gpus) [SM 9.0 ](https://developer.nvidia.com/cuda-gpus)
## Supported OSes
Linux, Windows
## Supported CPU Architecture
x86_64, armv7l
## CUDA APIs involved
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
cudaHostAlloc, cudaMemcpy, cudaMalloc, cudaMemcpyAsync, cudaFree, cudaGetErrorString, cudaMallocHost, cudaSetDevice, cudaGetDeviceProperties, cudaDeviceSynchronize, cudaEventRecord, cudaFreeHost, cudaEventDestroy, cudaEventElapsedTime, cudaGetDeviceCount, cudaEventCreate
## Prerequisites
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
## References (for more details)

File diff suppressed because it is too large Load Diff

View File

@@ -102,13 +102,23 @@ static void childProcess(int id)
int threads = 128;
cudaDeviceProp prop;
std::vector<void *> ptrs;
pid_t pid;
char pidString[20] = {0};
char lshmName[40] = {0};
std::vector<char> verification_buffer(DATA_SIZE);
pid = getppid();
snprintf(pidString, sizeof(pidString), "%d", pid);
strcat(lshmName, shmName);
strcat(lshmName, pidString);
printf("CP: lshmName = %s\n", lshmName);
ipcHandle *ipcChildHandle = NULL;
checkIpcErrors(ipcOpenSocket(ipcChildHandle));
if (sharedMemoryOpen(shmName, sizeof(shmStruct), &info) != 0) {
if (sharedMemoryOpen(lshmName, sizeof(shmStruct), &info) != 0) {
printf("Failed to create shared memory slab\n");
exit(EXIT_FAILURE);
}
@@ -245,6 +255,16 @@ static void parentProcess(char *app)
std::vector<void *> ptrs;
std::vector<Process> processes;
cudaMemAllocationHandleType handleType = cudaMemHandleTypeNone;
pid_t pid;
char pidString[20] = {0};
char lshmName[40] = {0};
pid = getpid();
snprintf(pidString, sizeof(pidString), "%d", pid);
strcat(lshmName, shmName);
strcat(lshmName, pidString);
printf("PP: lshmName = %s\n", lshmName);
checkCudaErrors(cudaGetDeviceCount(&devCount));
std::vector<CUdevice> devices(devCount);
@@ -252,7 +272,7 @@ static void parentProcess(char *app)
cuDeviceGet(&devices[i], i);
}
if (sharedMemoryCreate(shmName, sizeof(*shm), &info) != 0) {
if (sharedMemoryCreate(lshmName, sizeof(*shm), &info) != 0) {
printf("Failed to create shared memory slab\n");
exit(EXIT_FAILURE);
}

View File

@@ -310,10 +310,24 @@ static void childProcess(int devId, int id, char **argv)
ipcHandle *ipcChildHandle = NULL;
int blocks = 0;
int threads = 128;
char pidString[20] = {0};
char lshmName[40] = {0};
// Use parent process ID to create a unique shared memory name for Linux multi-process
#ifdef __linux__
pid_t pid;
pid = getppid();
snprintf(pidString, sizeof(pidString), "%d", pid);
#endif
strcat(lshmName, shmName);
strcat(lshmName, pidString);
printf("CP: lshmName = %s\n", lshmName);
checkIpcErrors(ipcOpenSocket(ipcChildHandle));
if (sharedMemoryOpen(shmName, sizeof(shmStruct), &info) != 0) {
if (sharedMemoryOpen(lshmName, sizeof(shmStruct), &info) != 0) {
printf("Failed to create shared memory slab\n");
exit(EXIT_FAILURE);
}
@@ -421,11 +435,24 @@ static void parentProcess(char *app)
volatile shmStruct *shm = NULL;
sharedMemoryInfo info;
std::vector<Process> processes;
char pidString[20] = {0};
char lshmName[40] = {0};
// Use current process ID to create a unique shared memory name for Linux multi-process
#ifdef __linux__
pid_t pid;
pid = getpid();
snprintf(pidString, sizeof(pidString), "%d", pid);
#endif
strcat(lshmName, shmName);
strcat(lshmName, pidString);
printf("PP: lshmName = %s\n", lshmName);
checkCudaErrors(cuDeviceGetCount(&devCount));
std::vector<CUdevice> devices(devCount);
if (sharedMemoryCreate(shmName, sizeof(*shm), &info) != 0) {
if (sharedMemoryCreate(lshmName, sizeof(*shm), &info) != 0) {
printf("Failed to create shared memory slab\n");
exit(EXIT_FAILURE);
}

View File

@@ -25,8 +25,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cuda_runtime.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <helper_cuda.h>
#include <helper_image.h>
#include <vector>

View File

@@ -45,13 +45,15 @@
#include <windows.h>
#endif
// includes for OpenGL
#include <helper_gl.h>
// includes
#include <cuda_gl_interop.h>
#include <cuda_runtime.h>
#include <cufft.h>
#include <helper_cuda.h>
#include <helper_functions.h>
#include <helper_gl.h>
#include <math.h>
#include <math_constants.h>
#include <stdio.h>

View File

@@ -86,12 +86,14 @@
#include <windows.h>
#endif
// includes for OpenGL
#include <helper_gl.h>
// includes
#include <cuda_gl_interop.h>
#include <cuda_runtime.h>
#include <helper_cuda.h> // includes cuda.h and cuda_runtime_api.h
#include <helper_functions.h>
#include <helper_gl.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

View File

@@ -28,11 +28,15 @@
#include "render_particles.h"
#define HELPERGL_EXTERN_GL_FUNC_IMPLEMENTATION
// includes for OpenGL
#include <helper_gl.h>
// includes
#include <assert.h>
#include <cuda_gl_interop.h>
#include <cuda_runtime.h>
#include <helper_cuda.h>
#include <helper_gl.h>
#include <math.h>
#define GL_POINT_SPRITE_ARB 0x8861

View File

@@ -31,9 +31,12 @@
#pragma warning(disable : 4312)
#include <mmsystem.h>
// includes for Windows
#include <windows.h>
// includes for multimedia
#include <mmsystem.h>
// This header inclues all the necessary D3D11 and CUDA includes
#include <cuda_d3d11_interop.h>
#include <cuda_runtime_api.h>

View File

@@ -31,9 +31,12 @@
#pragma warning(disable : 4312)
#include <mmsystem.h>
// includes for Windows
#include <windows.h>
// includes for multimedia
#include <mmsystem.h>
// This header inclues all the necessary D3D11 and CUDA includes
#include <cuda_d3d11_interop.h>
#include <cuda_runtime_api.h>

View File

@@ -33,11 +33,15 @@
#include <memory.h>
#define HELPERGL_EXTERN_GL_FUNC_IMPLEMENTATION
// includes for OpenGL
#include <helper_gl.h>
// includes
#include <cuda_gl_interop.h>
#include <cuda_runtime.h>
#include <helper_cuda.h>
#include <helper_functions.h>
#include <helper_gl.h>
#include "ParticleSystem.cuh"
#include "ParticleSystem.h"

View File

@@ -29,11 +29,15 @@
This file contains simple wrapper functions that call the CUDA kernels
*/
#define HELPERGL_EXTERN_GL_FUNC_IMPLEMENTATION
// includes for OpenGL
#include <helper_gl.h>
// includes
#include <cstdio>
#include <cstdlib>
#include <cuda_gl_interop.h>
#include <helper_cuda.h>
#include <helper_gl.h>
#include <string.h>
#include "ParticleSystem.cuh"

View File

@@ -1,11 +1,33 @@
# This layer of CMakeLists.txt adds folders, for better organization in Visual Studio
# and other IDEs that support this feature.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_FOLDER "0_Introduction")
add_subdirectory(0_Introduction)
set(CMAKE_FOLDER "1_Utilities")
add_subdirectory(1_Utilities)
set(CMAKE_FOLDER "2_Concepts_and_Techniques")
add_subdirectory(2_Concepts_and_Techniques)
set(CMAKE_FOLDER "3_CUDA_Features")
add_subdirectory(3_CUDA_Features)
set(CMAKE_FOLDER "4_CUDA_Libraries")
add_subdirectory(4_CUDA_Libraries)
set(CMAKE_FOLDER "5_Domain_Specific")
add_subdirectory(5_Domain_Specific)
set(CMAKE_FOLDER "6_Performance")
add_subdirectory(6_Performance)
set(CMAKE_FOLDER "7_libNVVM")
add_subdirectory(7_libNVVM)
if(BUILD_TEGRA)
set(CMAKE_FOLDER "8_Platform_Specific/Tegra")
add_subdirectory(8_Platform_Specific/Tegra)
endif()