DriveWorks SDK Reference
5.16.65 Release
For Test and Development only

TraceTypes.hpp
Go to the documentation of this file.
1
2//
3// Notice
4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8//
9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10// information or for any infringement of patents or other rights of third parties that may
11// result from its use. No license is granted by implication or otherwise under any patent
12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13// expressly authorized by NVIDIA. Details are subject to change without notice.
14// This code supersedes and replaces all information previously supplied.
15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16// components in life support devices or systems without express written approval of
17// NVIDIA CORPORATION & AFFILIATES.
18//
19// SPDX-FileCopyrightText: Copyright (c) 2016-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21//
22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23// property and proprietary rights in and to this material, related
24// documentation and any modifications thereto. Any use, reproduction,
25// disclosure or distribution of this material and related documentation
26// without an express license agreement from NVIDIA CORPORATION or
27// its affiliates is strictly prohibited.
28//
30
31#ifndef DWTRACE_CORE_TRACE_TYPES_HPP_
32#define DWTRACE_CORE_TRACE_TYPES_HPP_
33
34#include <cstdint>
35#include <thread>
36#include <mutex>
37#include <limits>
38#include <cuda_runtime_api.h>
39#include <dwshared/dwfoundation/dw/core/container/VectorFixed.hpp>
40#include <dwshared/dwfoundation/dw/core/container/HashContainer.hpp>
41#include <dwshared/dwfoundation/dw/core/container/BaseString.hpp>
42#include <dwshared/dwfoundation/dw/core/container/RingBuffer.hpp>
43
44namespace dw
45{
46namespace trace
47{
48static constexpr uint32_t DW_TRACE_MAX_NUM_EVENTS_PER_CHAN{(20 * 1024)};
49static constexpr uint32_t DW_TRACE_MAX_TAG_SIZE{256U};
50static constexpr uint32_t DW_TRACE_MAX_PAYLOAD_SIZE{64U};
51static constexpr uint32_t DW_TRACE_SUCCESS{0U};
52
53using dwtTime_t = uint64_t;
54using dwtFixedString_t = dw::core::FixedString<DW_TRACE_MAX_TAG_SIZE>;
55using dwtStringFilepath_t = dw::core::FixedString<384>;
56using dwtStringIPAddr_t = dw::core::FixedString<16>;
57template <typename typeKey, typename typeValue>
58using dwtHashMap_t = dw::core::StaticHashMap<typeKey, typeValue, 384>;
59template <typename typeT, size_t C = 0>
60using dwtVectorFixed_t = dw::core::VectorFixed<typeT, C>;
61template <typename typeT, size_t C>
62using dwtBufferQueue_t = dw::core::RingBuffer<typeT, C>;
63static constexpr dwtTime_t DWTRACE_TIMEOUT_INFINITE{std::numeric_limits<dwtTime_t>::max()};
64using sv = dw::core::StringView;
65
67{
68 NONE = 0,
69 MARKER,
76 SCOPE
77};
78
87enum class TraceChannel
88{
89 DEFAULT = 0,
90 LATENCY,
91 CAMERA,
93 COMM,
94 RENDER,
95 RADAR,
96 STARTUP,
99 VDC,
100 DW,
101 PROFILING,
102 SHUTDOWN,
104};
105
113enum class Level
114{
115 NONE = 0,
116 LEVEL_10 = 10,
117 LEVEL_20 = 20,
118 LEVEL_30 = 30,
119 LEVEL_50 = 50,
120 LEVEL_70 = 70,
121 LEVEL_100 = 100,
122};
123
124static constexpr size_t NUM_LEVELS{static_cast<size_t>(Level::LEVEL_100) + 1UL};
125
126enum class Backend
127{
128 FILEBASED = 0,
129 NETWORK,
130 IBACKEND,
131 NVTX = IBACKEND,
132 FTRACE,
134};
135
136struct dwtEvent_t //clang-tidy NOLINT(readability-identifier-naming)
137{
138 Level level; // level of events
139 TraceChannel channel; // synchronized event channel, suggest one per thread
140 TraceHeaderType type; // event type, marker or range
141 dwtFixedString_t tag; // event tag
142 float32_t duration; // duration of particular event
143 dwtFixedString_t payload; // event payload
144
145 const char* func; // function name of where event comes from.
146 const char* deviceName; // Name of device on which task is running.
147 size_t const deviceMemFree; // Usage of device memory at runtime
148 const int32_t hostMemUsed; // Usage of host memory at runtime (32-bit signed int, converted to size_t during post-processing)
149 uint64_t const nvMapMemUsed; // Usage of nvMap memory at runtime
150 uint64_t const readBytes; // disk i/o readBytes
151 uint64_t const writeBytes; // disk i/o writeBytes
152 uint64_t const ioWaitTime; // Time spent in io wait in nanoseconds
153
154 dwtTime_t stamp; // time stamp
155 std::thread::id tid; // thread id
156 dwtEvent_t(Level const evtLevel, TraceChannel const evtChannel, TraceHeaderType const evtType,
157 dwtFixedString_t const& evtTag, float32_t const evtDuration,
158 dwtFixedString_t const& evtPayload, const char* const evtFunc, const char* const evtDeviceName,
159 size_t const evtDeviceMemFree, const int32_t evtHostMemUsed, uint64_t const evtNvMapMemUsed, uint64_t const evtReadBytes, uint64_t const evtWriteBytes, uint64_t const evtIOWaitTime, dwtTime_t const evtStamp)
160 : level(evtLevel), channel(evtChannel), type(evtType), tag(evtTag.c_str()), duration(evtDuration), payload(evtPayload.c_str()), func(evtFunc), deviceName(evtDeviceName), deviceMemFree(evtDeviceMemFree), hostMemUsed(evtHostMemUsed), nvMapMemUsed(evtNvMapMemUsed), readBytes(evtReadBytes), writeBytes(evtWriteBytes), ioWaitTime(evtIOWaitTime), stamp(evtStamp)
161 {
162 }
163};
164
170{
171private:
172 uint32_t m_id = 0;
174
175public:
176 DWTraceChannel() = default;
177 DWTraceChannel(uint32_t const id, uint32_t const capacity);
180 DWTraceChannel& operator=(const DWTraceChannel& other) = default;
181
182 void pushEvent(dwtEvent_t&& event);
183
184 dwtVectorFixed_t<dwtEvent_t> const& events() { return m_events; }
185 void clear() { m_events.clear(); }
186};
187
189using TraceBufPtr = std::unique_ptr<TraceBuf>;
190using avtFlushCb_t = void (*)(TraceBuf*&, void*);
191
192Level getTraceLevel(const sv& level);
193
194} // namespace trace
195} // namespace dw
196#endif // DWTRACE_CORE_TRACE_TYPES_HPP_
Trace channel contains traces from particular module.
Definition: TraceTypes.hpp:170
void pushEvent(dwtEvent_t &&event)
DWTraceChannel(DWTraceChannel &&other)
DWTraceChannel(uint32_t const id, uint32_t const capacity)
dwtVectorFixed_t< dwtEvent_t > const & events()
Definition: TraceTypes.hpp:184
DWTraceChannel & operator=(const DWTraceChannel &other)=default
float float32_t
Specifies POD types.
Definition: BasicTypes.h:59
Level
Tracing can be controlled through tracing levels.
Definition: TraceTypes.hpp:114
TraceChannel
DWTrace channels are used for capturing similar traces in one place.
Definition: TraceTypes.hpp:88
dw::core::VectorFixed< typeT, C > dwtVectorFixed_t
Definition: TraceTypes.hpp:60
uint64_t dwtTime_t
Definition: TraceTypes.hpp:53
dw::core::RingBuffer< typeT, C > dwtBufferQueue_t
Definition: TraceTypes.hpp:62
static constexpr size_t NUM_LEVELS
Definition: TraceTypes.hpp:124
static constexpr uint32_t DW_TRACE_MAX_PAYLOAD_SIZE
Definition: TraceTypes.hpp:50
static constexpr uint32_t DW_TRACE_MAX_NUM_EVENTS_PER_CHAN
Definition: TraceTypes.hpp:48
dw::core::FixedString< DW_TRACE_MAX_TAG_SIZE > dwtFixedString_t
Definition: TraceTypes.hpp:54
dw::core::StringView sv
Definition: TraceTypes.hpp:64
dw::core::FixedString< 384 > dwtStringFilepath_t
Definition: TraceTypes.hpp:55
dwtVectorFixed_t< DWTraceChannel > TraceBuf
Definition: TraceTypes.hpp:188
Level getTraceLevel(const sv &level)
static constexpr uint32_t DW_TRACE_SUCCESS
Definition: TraceTypes.hpp:51
dw::core::FixedString< 16 > dwtStringIPAddr_t
Definition: TraceTypes.hpp:56
dw::core::StaticHashMap< typeKey, typeValue, 384 > dwtHashMap_t
Definition: TraceTypes.hpp:58
std::unique_ptr< TraceBuf > TraceBufPtr
Definition: TraceTypes.hpp:189
static constexpr uint32_t DW_TRACE_MAX_TAG_SIZE
Definition: TraceTypes.hpp:49
void(*)(TraceBuf *&, void *) avtFlushCb_t
Definition: TraceTypes.hpp:190
static constexpr dwtTime_t DWTRACE_TIMEOUT_INFINITE
Definition: TraceTypes.hpp:63
uint64_t const readBytes
Definition: TraceTypes.hpp:150
uint64_t const ioWaitTime
Definition: TraceTypes.hpp:152
std::thread::id tid
Definition: TraceTypes.hpp:155
const int32_t hostMemUsed
Definition: TraceTypes.hpp:148
TraceChannel channel
Definition: TraceTypes.hpp:139
size_t const deviceMemFree
Definition: TraceTypes.hpp:147
uint64_t const nvMapMemUsed
Definition: TraceTypes.hpp:149
dwtFixedString_t tag
Definition: TraceTypes.hpp:141
uint64_t const writeBytes
Definition: TraceTypes.hpp:151
TraceHeaderType type
Definition: TraceTypes.hpp:140
dwtFixedString_t payload
Definition: TraceTypes.hpp:143
const char * deviceName
Definition: TraceTypes.hpp:146
dwtEvent_t(Level const evtLevel, TraceChannel const evtChannel, TraceHeaderType const evtType, dwtFixedString_t const &evtTag, float32_t const evtDuration, dwtFixedString_t const &evtPayload, const char *const evtFunc, const char *const evtDeviceName, size_t const evtDeviceMemFree, const int32_t evtHostMemUsed, uint64_t const evtNvMapMemUsed, uint64_t const evtReadBytes, uint64_t const evtWriteBytes, uint64_t const evtIOWaitTime, dwtTime_t const evtStamp)
Definition: TraceTypes.hpp:156