NVIDIA DeepStream SDK API Reference
9.1 Release
sources/includes/ds3d/common/helper/check.hpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
* SPDX-License-Identifier: Apache-2.0
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#ifndef DS3D_COMMON_HELPER_CHECK_HPP
19
#define DS3D_COMMON_HELPER_CHECK_HPP
20
21
#include <assert.h>
22
#include <cuda_runtime.h>
23
#include <stdarg.h>
24
#include <stdio.h>
25
26
#include <string>
27
28
namespace
ds3d
{
29
30
#define DS3D_NVUNUSED2(a, b) \
31
{ \
32
(void)(a); \
33
(void)(b); \
34
}
35
#define DS3D_NVUNUSED(a) \
36
{ (void)(a); }
37
38
#ifndef DS3D_INFER_ASSERT
39
#define DS3D_INFER_ASSERT(expr) \
40
do { \
41
if (!(expr)) { \
42
fprintf(stderr, "%s:%d ASSERT(%s) \n", __FILE__, __LINE__, #expr); \
43
std::abort(); \
44
} \
45
} while (0)
46
#endif
47
48
#define checkRuntime(call) ds3d::check_runtime(call, #call, __LINE__, __FILE__)
49
50
#define checkKernel(...) \
51
do { \
52
__VA_ARGS__; \
53
ds3d::check_runtime(cudaPeekAtLastError(), #__VA_ARGS__, __LINE__, __FILE__); \
54
} while (false)
55
#define dprintf(...)
56
57
#define checkCudaErrors(cudaErrorCode) \
58
{ \
59
cudaError_t status = cudaErrorCode; \
60
if (status != 0) { \
61
std::cout << "Cuda failure: " << cudaGetErrorString(status) << " at line " << __LINE__ \
62
<< " in file " << __FILE__ << " error status: " << status << std::endl; \
63
abort(); \
64
} \
65
}
66
67
#define Assertf(cond, fmt, ...) \
68
do { \
69
if (!(cond)) { \
70
fprintf(stderr, "Assert failed 💀. %s in file %s:%d, message: " fmt "\n", #cond, __FILE__, __LINE__, __VA_ARGS__); \
71
abort(); \
72
} \
73
} while (false)
74
75
#define Asserts(cond, s) \
76
do { \
77
if (!(cond)) { \
78
fprintf(stderr, "Assert failed 💀. %s in file %s:%d, message: " s "\n", #cond, __FILE__, __LINE__); \
79
abort(); \
80
} \
81
} while (false)
82
83
#define Assert(cond) \
84
do { \
85
if (!(cond)) { \
86
fprintf(stderr, "Assert failed 💀. %s in file %s:%d\n", #cond, __FILE__, __LINE__); \
87
abort(); \
88
} \
89
} while (false)
90
91
static
inline
bool
check_runtime
(cudaError_t e,
const
char
*call,
int
line,
const
char
*file) {
92
if
(e != cudaSuccess) {
93
fprintf(stderr,
94
"CUDA Runtime error %s # %s, code = %s [ %d ] in file "
95
"%s:%d\n"
,
96
call, cudaGetErrorString(e), cudaGetErrorName(e), e, file, line);
97
abort();
98
return
false
;
99
}
100
return
true
;
101
}
102
103
};
// namespace ds3d
104
105
#endif // DS3D_COMMON_HELPER_CHECK_HPP
ds3d::check_runtime
static bool check_runtime(cudaError_t e, const char *call, int line, const char *file)
Definition:
sources/includes/ds3d/common/helper/check.hpp:91
ds3d
Definition:
sources/includes/ds3d/common/abi_dataprocess.h:25
Privacy Policy
|
Manage My Privacy
|
Do Not Sell or Share My Data
|
Terms of Service
|
Accessibility
|
Corporate Policies
|
Product Security
|
Contact
© 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
NVIDIA Confidential | Subject to Change | For test and development only.
Thu Jul 9 2026 11:48:18 | PR-09318-R32