Skip to content

Commit b458daf

Browse files
committed
Add and update samples with CUDA 10.1 support
1 parent 32f0fc6 commit b458daf

File tree

201 files changed

+9072
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+9072
-286
lines changed

Common/helper_cuda.h

+36
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,42 @@ static const char *_cudaGetErrorEnum(curandStatus_t error) {
282282
}
283283
#endif
284284

285+
#ifdef NVJPEGAPI
286+
// nvJPEG API errors
287+
static const char *_cudaGetErrorEnum(nvjpegStatus_t error) {
288+
switch (error) {
289+
case NVJPEG_STATUS_SUCCESS:
290+
return "NVJPEG_STATUS_SUCCESS";
291+
292+
case NVJPEG_STATUS_NOT_INITIALIZED:
293+
return "NVJPEG_STATUS_NOT_INITIALIZED";
294+
295+
case NVJPEG_STATUS_INVALID_PARAMETER:
296+
return "NVJPEG_STATUS_INVALID_PARAMETER";
297+
298+
case NVJPEG_STATUS_BAD_JPEG:
299+
return "NVJPEG_STATUS_BAD_JPEG";
300+
301+
case NVJPEG_STATUS_JPEG_NOT_SUPPORTED:
302+
return "NVJPEG_STATUS_JPEG_NOT_SUPPORTED";
303+
304+
case NVJPEG_STATUS_ALLOCATOR_FAILURE:
305+
return "NVJPEG_STATUS_ALLOCATOR_FAILURE";
306+
307+
case NVJPEG_STATUS_EXECUTION_FAILED:
308+
return "NVJPEG_STATUS_EXECUTION_FAILED";
309+
310+
case NVJPEG_STATUS_ARCH_MISMATCH:
311+
return "NVJPEG_STATUS_ARCH_MISMATCH";
312+
313+
case NVJPEG_STATUS_INTERNAL_ERROR:
314+
return "NVJPEG_STATUS_INTERNAL_ERROR";
315+
}
316+
317+
return "<unknown>";
318+
}
319+
#endif
320+
285321
#ifdef NV_NPPIDEFS_H
286322
// NPP API errors
287323
static const char *_cudaGetErrorEnum(NppStatus error) {

Common/helper_multiprocess.cpp

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
2+
*
3+
* Redistribution and use in source and binary forms, with or without
4+
* modification, are permitted provided that the following conditions
5+
* are met:
6+
* * Redistributions of source code must retain the above copyright
7+
* notice, this list of conditions and the following disclaimer.
8+
* * Redistributions in binary form must reproduce the above copyright
9+
* notice, this list of conditions and the following disclaimer in the
10+
* documentation and/or other materials provided with the distribution.
11+
* * Neither the name of NVIDIA CORPORATION nor the names of its
12+
* contributors may be used to endorse or promote products derived
13+
* from this software without specific prior written permission.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#include "helper_multiprocess.h"
29+
#include <cstdlib>
30+
#include <string>
31+
32+
int sharedMemoryCreate(const char *name, size_t sz, sharedMemoryInfo *info)
33+
{
34+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
35+
info->size = sz;
36+
info->shmHandle = CreateFileMapping(INVALID_HANDLE_VALUE,
37+
NULL,
38+
PAGE_READWRITE,
39+
0,
40+
(DWORD)sz,
41+
name);
42+
if (info->shmHandle == 0) {
43+
return GetLastError();
44+
}
45+
46+
info->addr = MapViewOfFile(info->shmHandle, FILE_MAP_ALL_ACCESS, 0, 0, sz);
47+
if (info->addr == NULL) {
48+
return GetLastError();
49+
}
50+
51+
return 0;
52+
#else
53+
int status = 0;
54+
55+
info->size = sz;
56+
57+
info->shmFd = shm_open(name, O_RDWR | O_CREAT, 0777);
58+
if (info->shmFd < 0) {
59+
return errno;
60+
}
61+
62+
status = ftruncate(info->shmFd, sz);
63+
if (status != 0) {
64+
return status;
65+
}
66+
67+
info->addr = mmap(0, sz, PROT_READ | PROT_WRITE, MAP_SHARED, info->shmFd, 0);
68+
if (info->addr == NULL) {
69+
return errno;
70+
}
71+
72+
return 0;
73+
#endif
74+
}
75+
76+
int sharedMemoryOpen(const char *name, size_t sz, sharedMemoryInfo *info)
77+
{
78+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
79+
info->size = sz;
80+
81+
info->shmHandle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, name);
82+
if (info->shmHandle == 0) {
83+
return GetLastError();
84+
}
85+
86+
info->addr = MapViewOfFile(info->shmHandle, FILE_MAP_ALL_ACCESS, 0, 0, sz);
87+
if (info->addr == NULL) {
88+
return GetLastError();
89+
}
90+
91+
return 0;
92+
#else
93+
info->size = sz;
94+
95+
info->shmFd = shm_open(name, O_RDWR, 0777);
96+
if (info->shmFd < 0) {
97+
return errno;
98+
}
99+
100+
info->addr = mmap(0, sz, PROT_READ | PROT_WRITE, MAP_SHARED, info->shmFd, 0);
101+
if (info->addr == NULL) {
102+
return errno;
103+
}
104+
105+
return 0;
106+
#endif
107+
}
108+
109+
void sharedMemoryClose(sharedMemoryInfo *info)
110+
{
111+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
112+
if (info->addr) {
113+
UnmapViewOfFile(info->addr);
114+
}
115+
if (info->shmHandle) {
116+
CloseHandle(info->shmHandle);
117+
}
118+
#else
119+
if (info->addr) {
120+
munmap(info->addr, info->size);
121+
}
122+
if (info->shmFd) {
123+
close(info->shmFd);
124+
}
125+
#endif
126+
}
127+
128+
int spawnProcess(Process *process, const char *app, char * const *args)
129+
{
130+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
131+
STARTUPINFO si = {0};
132+
BOOL status;
133+
size_t arglen = 0;
134+
size_t argIdx = 0;
135+
std::string arg_string;
136+
memset(process, 0, sizeof(*process));
137+
138+
while (*args) {
139+
arg_string.append(*args).append(1, ' ');
140+
args++;
141+
}
142+
143+
status = CreateProcess(app, LPSTR(arg_string.c_str()), NULL, NULL, FALSE, 0, NULL, NULL, &si, process);
144+
145+
return status ? 0 : GetLastError();
146+
#else
147+
*process = fork();
148+
if (*process == 0) {
149+
if (0 > execvp(app, args)) {
150+
return errno;
151+
}
152+
}
153+
else if (*process < 0) {
154+
return errno;
155+
}
156+
return 0;
157+
#endif
158+
}
159+
160+
int waitProcess(Process *process)
161+
{
162+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
163+
DWORD exitCode;
164+
WaitForSingleObject(process->hProcess, INFINITE);
165+
GetExitCodeProcess(process->hProcess, &exitCode);
166+
CloseHandle(process->hProcess);
167+
CloseHandle(process->hThread);
168+
return (int)exitCode;
169+
#else
170+
int status = 0;
171+
do {
172+
if (0 > waitpid(*process, &status, 0)) {
173+
return errno;
174+
}
175+
} while (!WIFEXITED(status));
176+
return WEXITSTATUS(status);
177+
#endif
178+
}

Common/helper_multiprocess.h

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
2+
*
3+
* Redistribution and use in source and binary forms, with or without
4+
* modification, are permitted provided that the following conditions
5+
* are met:
6+
* * Redistributions of source code must retain the above copyright
7+
* notice, this list of conditions and the following disclaimer.
8+
* * Redistributions in binary form must reproduce the above copyright
9+
* notice, this list of conditions and the following disclaimer in the
10+
* documentation and/or other materials provided with the distribution.
11+
* * Neither the name of NVIDIA CORPORATION nor the names of its
12+
* contributors may be used to endorse or promote products derived
13+
* from this software without specific prior written permission.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#ifndef HELPER_MULTIPROCESS_H
29+
#define HELPER_MULTIPROCESS_H
30+
31+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
32+
#ifndef WIN32_LEAN_AND_MEAN
33+
#define WIN32_LEAN_AND_MEAN
34+
#endif
35+
#include <windows.h>
36+
#else
37+
#include <fcntl.h>
38+
#include <sys/mman.h>
39+
#include <unistd.h>
40+
#include <errno.h>
41+
#include <sys/wait.h>
42+
#endif
43+
44+
typedef struct sharedMemoryInfo_st {
45+
void *addr;
46+
size_t size;
47+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
48+
HANDLE shmHandle;
49+
#else
50+
int shmFd;
51+
#endif
52+
} sharedMemoryInfo;
53+
54+
int sharedMemoryCreate(const char *name, size_t sz, sharedMemoryInfo *info);
55+
56+
int sharedMemoryOpen(const char *name, size_t sz, sharedMemoryInfo *info);
57+
58+
void sharedMemoryClose(sharedMemoryInfo *info);
59+
60+
61+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
62+
typedef PROCESS_INFORMATION Process;
63+
#else
64+
typedef pid_t Process;
65+
#endif
66+
67+
int spawnProcess(Process *process, const char *app, char * const *args);
68+
69+
int waitProcess(Process *process);
70+
71+
#endif // HELPER_MULTIPROCESS_H

Samples/UnifiedMemoryPerf/Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
234234

235235
SAMPLE_ENABLED := 1
236236

237+
# This sample is not supported on QNX
238+
ifeq ($(TARGET_OS),qnx)
239+
$(info >>> WARNING - UnifiedMemoryPerf is not supported on QNX - waiving sample <<<)
240+
SAMPLE_ENABLED := 0
241+
endif
242+
237243
ALL_LDFLAGS :=
238244
ALL_LDFLAGS += $(ALL_CCFLAGS)
239245
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
@@ -246,7 +252,11 @@ LIBRARIES :=
246252
################################################################################
247253

248254
# Gencode arguments
255+
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),armv7l aarch64))
256+
SMS ?= 30 35 37 50 52 60 61 70 72 75
257+
else
249258
SMS ?= 30 35 37 50 52 60 61 70 75
259+
endif
250260

251261
ifeq ($(SMS),)
252262
$(info >>> WARNING - no SM architectures have been specified - waiving sample <<<)

Samples/UnifiedMemoryPerf/NsightEclipse.xml

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<sm-arch>sm60</sm-arch>
5353
<sm-arch>sm61</sm-arch>
5454
<sm-arch>sm70</sm-arch>
55+
<sm-arch>sm72</sm-arch>
5556
<sm-arch>sm75</sm-arch>
5657
<supported_envs>
5758
<env>

Samples/UnifiedMemoryPerf/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CUDA Systems Integration, Unified Memory, CUDA Streams and Events, Pinned System
1010

1111
## Supported SM Architectures
1212

13-
[SM 3.0 ](https://developer.nvidia.com/cuda-gpus) [SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](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.5 ](https://developer.nvidia.com/cuda-gpus)
13+
[SM 3.0 ](https://developer.nvidia.com/cuda-gpus) [SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](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)
1414

1515
## Supported OSes
1616

@@ -30,7 +30,7 @@ cudaMallocManaged, cudaStreamAttachMemAsync, cudaMemcpyAsync, cudaMallocHost, cu
3030

3131
## Prerequisites
3232

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

3636
## Build and Run

Samples/UnifiedMemoryPerf/UnifiedMemoryPerf_vs2012.vcxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</PropertyGroup>
3434
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
3535
<ImportGroup Label="ExtensionSettings">
36-
<Import Project="$(CUDAPropsPath)\CUDA 10.0.props" />
36+
<Import Project="$(CUDAPropsPath)\CUDA 10.1.props" />
3737
</ImportGroup>
3838
<ImportGroup Label="PropertySheets">
3939
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
@@ -105,6 +105,6 @@
105105
</ItemGroup>
106106
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
107107
<ImportGroup Label="ExtensionTargets">
108-
<Import Project="$(CUDAPropsPath)\CUDA 10.0.targets" />
108+
<Import Project="$(CUDAPropsPath)\CUDA 10.1.targets" />
109109
</ImportGroup>
110110
</Project>

Samples/UnifiedMemoryPerf/UnifiedMemoryPerf_vs2013.vcxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</PropertyGroup>
3434
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
3535
<ImportGroup Label="ExtensionSettings">
36-
<Import Project="$(CUDAPropsPath)\CUDA 10.0.props" />
36+
<Import Project="$(CUDAPropsPath)\CUDA 10.1.props" />
3737
</ImportGroup>
3838
<ImportGroup Label="PropertySheets">
3939
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
@@ -105,6 +105,6 @@
105105
</ItemGroup>
106106
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
107107
<ImportGroup Label="ExtensionTargets">
108-
<Import Project="$(CUDAPropsPath)\CUDA 10.0.targets" />
108+
<Import Project="$(CUDAPropsPath)\CUDA 10.1.targets" />
109109
</ImportGroup>
110110
</Project>

Samples/UnifiedMemoryPerf/UnifiedMemoryPerf_vs2015.vcxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</PropertyGroup>
3434
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
3535
<ImportGroup Label="ExtensionSettings">
36-
<Import Project="$(CUDAPropsPath)\CUDA 10.0.props" />
36+
<Import Project="$(CUDAPropsPath)\CUDA 10.1.props" />
3737
</ImportGroup>
3838
<ImportGroup Label="PropertySheets">
3939
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
@@ -105,6 +105,6 @@
105105
</ItemGroup>
106106
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
107107
<ImportGroup Label="ExtensionTargets">
108-
<Import Project="$(CUDAPropsPath)\CUDA 10.0.targets" />
108+
<Import Project="$(CUDAPropsPath)\CUDA 10.1.targets" />
109109
</ImportGroup>
110110
</Project>

0 commit comments

Comments
 (0)