DriveWorks SDK Reference
5.20.37 Release
For Test and Development only

TraceStructures.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) 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_TRACE_STRUCTURES_HPP_
32#define DWTRACE_TRACE_STRUCTURES_HPP_
33
35
36namespace dw
37{
38namespace trace
39{
40
42{
43 NONE = 0,
44 MARKER,
51 SCOPE
52};
53
58enum class TraceChannel
59{
60 DEFAULT = 0,
61 LATENCY,
62 CAMERA,
64 COMM,
65 RENDER,
66 RADAR,
67 STARTUP,
70 VDC,
71 DW,
75};
76
84enum class Level
85{
86 NONE = 0,
87 LEVEL_10 = 10,
88 LEVEL_20 = 20,
89 LEVEL_30 = 30,
90 LEVEL_50 = 50,
91 LEVEL_70 = 70,
92 LEVEL_100 = 100,
93};
94
95static constexpr size_t NUM_LEVELS{static_cast<size_t>(Level::LEVEL_100) + 1UL};
96
103
107enum class Backend
108{
109 FILEBASED = 0,
110 IBACKEND,
111 NVTX = IBACKEND,
112 FTRACE,
114};
115
116static const dw::core::StaticHashMap<sv, Level, NUM_LEVELS> nameToLevelMap{
117 {sv{"NONE"}, Level::NONE},
118 {sv{"LEVEL_10"}, Level::LEVEL_10},
119 {sv{"LEVEL_20"}, Level::LEVEL_20},
120 {sv{"LEVEL_30"}, Level::LEVEL_30},
121 {sv{"LEVEL_50"}, Level::LEVEL_50},
122 {sv{"LEVEL_70"}, Level::LEVEL_70},
123 {sv{"LEVEL_100"}, Level::LEVEL_100},
124};
125
131{
132 // Enable tracing.
133 bool enabled = false;
134 // File path where Trace*.txt will be stored if fileBackend is enabled.
136 // DWTrace supports total 32 channels. Following mask allows to enable/
137 // disable specific channels.
138 uint64_t channelMask = 0;
139 // Enable filebased backend. For this backend post processing
140 // script dwTrace.py is needed to infer results.
141 bool fileBackendEnabled = false;
142 // Max file size of generated filebackend based dwtrace.
143 // After this file limit reached log rotation will start.
144 uint32_t maxFileSizeMB = 0;
145 // Enable NVTx backend.
146 bool nvtxBackendEnabled = false;
147 // Global tracing level, any trace which has level greater than this
148 // level will be ignored.
150 // Number of frames after which flusing to backend will be called.
151 uint32_t flushInterval = 0;
152 // Enable ftrace backend.
154 // Enable memory usage trace
155 bool memTraceEnabled = false;
156 // Enable memory usage trace outside of STARTUP channel
157 bool fullMemUsage = false;
158 // Enable disk io usage(read/write bytes, io delay total) trace. Disk IO operation
159 // mainly happens when running application after boot. After that data is cached(Depends upon OS and System memory)
160 // For now this info will be dumped for STARTUP channels BEGIN/END, as it is expected that major IO operation happens during program init phase.
161 bool diskIOStatsEnabled = false;
162 // Start time of roadrunner
164 // Create Cuda Events
165 bool createCudaEvents = true;
166
167 TracerConfig() = default;
168 TracerConfig(bool const enabledFlag, char8_t const* const fileLoc, uint64_t const chanMask,
169 bool const fileBackendFlag, uint32_t const fileSize, bool const nvtxBackendFlag,
170 uint32_t const traceLevel, uint32_t const flushEpoch, bool const ftraceFlag,
171 bool const memTraceFlag, bool const fullMemUse, bool const diskIOStats,
172 char8_t const* const start = nullptr, bool const& createCudaEventsFlag = true)
173 : enabled(enabledFlag), filePath(fileLoc), channelMask(chanMask), fileBackendEnabled(fileBackendFlag), maxFileSizeMB(fileSize), nvtxBackendEnabled(nvtxBackendFlag), tracingLevel(static_cast<Level>(traceLevel)), flushInterval((flushEpoch > DW_TRACE_MAX_NUM_EVENTS_PER_CHAN) ? DW_TRACE_MAX_NUM_EVENTS_PER_CHAN : flushEpoch), ftraceBackendEnabled(ftraceFlag), memTraceEnabled(memTraceFlag), fullMemUsage(fullMemUse), diskIOStatsEnabled(diskIOStats), startTime(start), createCudaEvents(createCudaEventsFlag)
174 {
175 }
176};
177
178struct dwtEvent_t // clang-tidy NOLINT(readability-identifier-naming)
179{
180 Level level; // level of events
181 TraceChannel channel; // synchronized event channel, suggest one per thread
182 TraceHeaderType type; // event type, marker or range
183 dwtFixedString_t tag; // event tag
184 float32_t duration; // duration of particular event
185 dwtFixedString_t payload; // event payload
186
187 const char* func; // function name of where event comes from.
188 const char* deviceName; // Name of device on which task is running.
189 size_t const deviceMemFree; // Usage of device memory at runtime
190 const int32_t hostMemUsed; // Usage of host memory at runtime (32-bit signed int, converted to size_t during post-processing)
191 uint64_t const nvMapMemUsed; // Usage of nvMap memory at runtime
192 uint64_t const readBytes; // disk i/o readBytes
193 uint64_t const writeBytes; // disk i/o writeBytes
194 uint64_t const ioWaitTime; // Time spent in io wait in nanoseconds
195
196 dwtTime_t stamp; // time stamp
197 std::thread::id tid; // thread id
198 dwtEvent_t(Level const evtLevel, TraceChannel const evtChannel, TraceHeaderType const evtType,
199 dwtFixedString_t const& evtTag, float32_t const evtDuration,
200 dwtFixedString_t const& evtPayload, const char* const evtFunc, const char* const evtDeviceName,
201 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)
202 : 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)
203 {
204 }
205};
206
208{
209 cudaStream_t streamId;
210 cudaEvent_t event;
211};
212
213} // namespace trace
214} // namespace dw
215
216#endif // DWTRACE_TRACE_STRUCTURES_HPP_
float float32_t
Specifies POD types.
Definition: BasicTypes.h:59
Level
Tracing can be controlled through tracing levels.
TraceChannel
DWTrace channels are used for capturing similar traces in one place.
uint64_t dwtTime_t
Definition: TraceTypes.hpp:50
static constexpr Level DW_TRACE_LEVEL_DEFAULT
If not sure about tracing level at the time of using DWTrace API, then use default trace level.
static constexpr size_t NUM_LEVELS
static constexpr uint32_t DW_TRACE_MAX_NUM_EVENTS_PER_CHAN
dw::core::FixedString< DW_TRACE_MAX_TAG_SIZE > dwtFixedString_t
Definition: TraceTypes.hpp:51
dw::core::StringView sv
Definition: TraceTypes.hpp:60
dw::core::FixedString< 384 > dwtStringFilepath_t
Definition: TraceTypes.hpp:52
Backend
Add documentation.
static const dw::core::StaticHashMap< sv, Level, NUM_LEVELS > nameToLevelMap
DWTrace initialisation and configuration structure.
TracerConfig(bool const enabledFlag, char8_t const *const fileLoc, uint64_t const chanMask, bool const fileBackendFlag, uint32_t const fileSize, bool const nvtxBackendFlag, uint32_t const traceLevel, uint32_t const flushEpoch, bool const ftraceFlag, bool const memTraceFlag, bool const fullMemUse, bool const diskIOStats, char8_t const *const start=nullptr, bool const &createCudaEventsFlag=true)
dwtStringFilepath_t filePath
dwtFixedString_t startTime
uint64_t const nvMapMemUsed
dwtFixedString_t payload
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)