Skip to content

Commit

Permalink
Updating samples for CUDA 12.5
Browse files Browse the repository at this point in the history
  • Loading branch information
rnertney committed Jul 25, 2024
1 parent 5f97d7d commit 9c688d7
Show file tree
Hide file tree
Showing 997 changed files with 5,284 additions and 1,393 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Changelog

### CUDA 12.5

### CUDA 12.4
* Added graphConditionalNodes Sample

Expand Down
26 changes: 19 additions & 7 deletions Common/helper_multiprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int waitProcess(Process *process) {
#endif
}

#if defined(__linux__)
#if defined(__linux__) || defined(__QNX__)
int ipcCreateSocket(ipcHandle *&handle, const char *name,
const std::vector<Process> &processes) {
int server_fd;
Expand Down Expand Up @@ -262,41 +262,48 @@ int ipcRecvShareableHandle(ipcHandle *handle, ShareableHandle *shHandle) {
// Union to guarantee alignment requirements for control array
union {
struct cmsghdr cm;
char control[CMSG_SPACE(sizeof(int))];
// This will not work on QNX as QNX CMSG_SPACE calls __cmsg_alignbytes
// And __cmsg_alignbytes is a runtime function instead of compile-time macros
// char control[CMSG_SPACE(sizeof(int))]
char* control;
} control_un;

size_t sizeof_control = CMSG_SPACE(sizeof(int)) * sizeof(char);
control_un.control = (char*) malloc(sizeof_control);
struct cmsghdr *cmptr;
ssize_t n;
int receivedfd;
char dummy_buffer[1];
ssize_t sendResult;

msg.msg_control = control_un.control;
msg.msg_controllen = sizeof(control_un.control);
msg.msg_controllen = sizeof_control;

iov[0].iov_base = (void *)dummy_buffer;
iov[0].iov_len = sizeof(dummy_buffer);

msg.msg_iov = iov;
msg.msg_iovlen = 1;

if ((n = recvmsg(handle->socket, &msg, 0)) <= 0) {
perror("IPC failure: Receiving data over socket failed");
free(control_un.control);
return -1;
}

if (((cmptr = CMSG_FIRSTHDR(&msg)) != NULL) &&
(cmptr->cmsg_len == CMSG_LEN(sizeof(int)))) {
if ((cmptr->cmsg_level != SOL_SOCKET) || (cmptr->cmsg_type != SCM_RIGHTS)) {
free(control_un.control);
return -1;
}

memmove(&receivedfd, CMSG_DATA(cmptr), sizeof(receivedfd));
*(int *)shHandle = receivedfd;
} else {
free(control_un.control);
return -1;
}

free(control_un.control);
return 0;
}

Expand Down Expand Up @@ -340,9 +347,12 @@ int ipcSendShareableHandle(ipcHandle *handle,

union {
struct cmsghdr cm;
char control[CMSG_SPACE(sizeof(int))];
char* control;
} control_un;

size_t sizeof_control = CMSG_SPACE(sizeof(int)) * sizeof(char);
control_un.control = (char*) malloc(sizeof_control);

struct cmsghdr *cmptr;
ssize_t readResult;
struct sockaddr_un cliaddr;
Expand All @@ -360,7 +370,7 @@ int ipcSendShareableHandle(ipcHandle *handle,
int sendfd = (int)shareableHandles[data];

msg.msg_control = control_un.control;
msg.msg_controllen = sizeof(control_un.control);
msg.msg_controllen = sizeof_control;

cmptr = CMSG_FIRSTHDR(&msg);
cmptr->cmsg_len = CMSG_LEN(sizeof(int));
Expand All @@ -380,9 +390,11 @@ int ipcSendShareableHandle(ipcHandle *handle,
ssize_t sendResult = sendmsg(handle->socket, &msg, 0);
if (sendResult <= 0) {
perror("IPC failure: Sending data over socket failed");
free(control_un.control);
return -1;
}

free(control_un.control);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion Common/helper_multiprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int waitProcess(Process *process);
#define checkIpcErrors(ipcFuncResult) \
if (ipcFuncResult == -1) { fprintf(stderr, "Failure at %u %s\n", __LINE__, __FILE__); exit(EXIT_FAILURE); }

#if defined(__linux__)
#if defined(__linux__) || defined(__QNX__)
struct ipcHandle_st {
int socket;
char *socketName;
Expand Down
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
# CUDA Samples

Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 12.4](https://developer.nvidia.com/cuda-downloads).
Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads).

## Release Notes

This section describes the release notes for the CUDA Samples on GitHub only.

### CUDA 12.4

- Hopper Confidential Computing Modes do not support Video samples, nor do they support host-pinned memory due to the restrictions created by CPU IOMMUs. The following Samples are affected:
- convolutionTexture
- cudaNvSci
- dct8x8
- lineOfSight
- simpleCubemapTexture
- simpleIPC
- simpleLayeredTexture
- simplePitchLinearTexture
- simpleStream
- simpleTexture
- simpleTextureDrv
- watershedSegmentationNPP

### CUDA 12.5

### [older versions...](./CHANGELOG.md)

## Getting Started

### Prerequisites

Download and install the [CUDA Toolkit 12.4](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
For system requirements and installation instructions of cuda toolkit, please refer to the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/), and the [Windows Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html).

### Getting the CUDA Samples
Expand Down
13 changes: 13 additions & 0 deletions Samples/0_Introduction/UnifiedMemoryStreams/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ CCFLAGS :=
LDFLAGS :=

# build flags

# Link flag for customized HOST_COMPILER with gcc realpath
GCC_PATH := $(shell which gcc)
ifeq ($(CUSTOM_HOST_COMPILER),1)
ifneq ($(filter /%,$(HOST_COMPILER)),)
ifneq ($(findstring gcc,$(HOST_COMPILER)),)
ifneq ($(GCC_PATH),$(HOST_COMPILER))
LDFLAGS += -lstdc++
endif
endif
endif
endif

ifeq ($(TARGET_OS),darwin)
LDFLAGS += -rpath $(CUDA_PATH)/lib
CCFLAGS += -arch $(HOST_ARCH)
Expand Down
2 changes: 1 addition & 1 deletion Samples/0_Introduction/UnifiedMemoryStreams/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cudaStreamDestroy, cudaFree, cudaMallocManaged, cudaStreamAttachMemAsync, cudaSe

## Prerequisites

Download and install the [CUDA Toolkit 12.4](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
Make sure the dependencies mentioned in [Dependencies]() section above are installed.

## Build and Run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.props" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
Expand Down Expand Up @@ -108,6 +108,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.targets" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.targets" />
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.props" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
Expand Down Expand Up @@ -104,6 +104,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.targets" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.targets" />
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.props" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
Expand Down Expand Up @@ -104,6 +104,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.targets" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.targets" />
</ImportGroup>
</Project>
13 changes: 13 additions & 0 deletions Samples/0_Introduction/asyncAPI/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ CCFLAGS :=
LDFLAGS :=

# build flags

# Link flag for customized HOST_COMPILER with gcc realpath
GCC_PATH := $(shell which gcc)
ifeq ($(CUSTOM_HOST_COMPILER),1)
ifneq ($(filter /%,$(HOST_COMPILER)),)
ifneq ($(findstring gcc,$(HOST_COMPILER)),)
ifneq ($(GCC_PATH),$(HOST_COMPILER))
LDFLAGS += -lstdc++
endif
endif
endif
endif

ifeq ($(TARGET_OS),darwin)
LDFLAGS += -rpath $(CUDA_PATH)/lib
CCFLAGS += -arch $(HOST_ARCH)
Expand Down
2 changes: 1 addition & 1 deletion Samples/0_Introduction/asyncAPI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cudaProfilerStop, cudaMalloc, cudaMemcpyAsync, cudaFree, cudaMallocHost, cudaPro

## Prerequisites

Download and install the [CUDA Toolkit 12.4](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.

## Build and Run

Expand Down
4 changes: 2 additions & 2 deletions Samples/0_Introduction/asyncAPI/asyncAPI_vs2017.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.props" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
Expand Down Expand Up @@ -107,6 +107,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.targets" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.targets" />
</ImportGroup>
</Project>
4 changes: 2 additions & 2 deletions Samples/0_Introduction/asyncAPI/asyncAPI_vs2019.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.props" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
Expand Down Expand Up @@ -103,6 +103,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.targets" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.targets" />
</ImportGroup>
</Project>
4 changes: 2 additions & 2 deletions Samples/0_Introduction/asyncAPI/asyncAPI_vs2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.props" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
Expand Down Expand Up @@ -103,6 +103,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.targets" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.targets" />
</ImportGroup>
</Project>
13 changes: 13 additions & 0 deletions Samples/0_Introduction/c++11_cuda/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ CCFLAGS :=
LDFLAGS :=

# build flags

# Link flag for customized HOST_COMPILER with gcc realpath
GCC_PATH := $(shell which gcc)
ifeq ($(CUSTOM_HOST_COMPILER),1)
ifneq ($(filter /%,$(HOST_COMPILER)),)
ifneq ($(findstring gcc,$(HOST_COMPILER)),)
ifneq ($(GCC_PATH),$(HOST_COMPILER))
LDFLAGS += -lstdc++
endif
endif
endif
endif

ifeq ($(TARGET_OS),darwin)
LDFLAGS += -rpath $(CUDA_PATH)/lib
CCFLAGS += -arch $(HOST_ARCH)
Expand Down
2 changes: 1 addition & 1 deletion Samples/0_Introduction/c++11_cuda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cudaMalloc, cudaMemcpy, cudaMemset, cudaFree

## Prerequisites

Download and install the [CUDA Toolkit 12.4](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
Download and install the [CUDA Toolkit 12.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
Make sure the dependencies mentioned in [Dependencies]() section above are installed.

## Build and Run
Expand Down
4 changes: 2 additions & 2 deletions Samples/0_Introduction/c++11_cuda/c++11_cuda_vs2017.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.props" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
Expand Down Expand Up @@ -107,6 +107,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.targets" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.targets" />
</ImportGroup>
</Project>
4 changes: 2 additions & 2 deletions Samples/0_Introduction/c++11_cuda/c++11_cuda_vs2019.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.props" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
Expand Down Expand Up @@ -103,6 +103,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.targets" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.targets" />
</ImportGroup>
</Project>
4 changes: 2 additions & 2 deletions Samples/0_Introduction/c++11_cuda/c++11_cuda_vs2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.props" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
Expand Down Expand Up @@ -103,6 +103,6 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(CUDAPropsPath)\CUDA 12.4.targets" />
<Import Project="$(CUDAPropsPath)\CUDA 12.5.targets" />
</ImportGroup>
</Project>
Loading

0 comments on commit 9c688d7

Please sign in to comment.