DriveWorks SDK Reference
5.20.37 Release
For Test and Development only

TraceFunctions.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_FUNCTIONS_HPP_
32#define DWTRACE_TRACE_FUNCTIONS_HPP_
33
37
38namespace dw
39{
40namespace trace
41{
42
43// advertise performance impact of cudaEventBlockingSync (true = use it)
45{
46#ifdef VIBRANTE
47 return true; // Tegra
48#else
49 return false; // x86
50#endif
51}
52
54{
55 return dw::trace::isBlockingSyncPreferred() ? static_cast<uint32_t>(cudaEventBlockingSync) : static_cast<uint32_t>(0U);
56}
57
59{
60public:
61 static Level getTraceLevel(const sv& level);
62 static uint64_t getFlushInterval();
64
65 static dwtFixedString_t singlePayload(char8_t const* const str1);
66 static dwtFixedString_t singlePayload(int32_t const i);
67 static dwtFixedString_t joinPayloadChars(char8_t const* const str1, char8_t const* const str2);
68
69 static bool isFileBackendEnabled();
70 static bool isNVTXBackendEnabled();
72 static bool isDWTracingEnabled();
73
74 static void fTraceInit();
75 static void fTraceWrite(dwtFixedString_t& str);
76 static void fTraceDeInit();
77
78 static void dwTraceEnable(TracerConfig& config);
79 static void dwTraceDisable(uint64_t const chanMask);
80 static void dwTraceEnableAll();
81
82 static size_t getDeviceMemFree();
83 static int32_t getHostMemUsed();
84 static uint64_t getNvMapMemUsed();
85
86 static void dwTraceCoreInit(TracerConfig tracerCfg);
87 static void dwTraceWrapperInit(TracerConfig const tracerCfg);
88 static void dwTraceWrapperReset();
89 static void dwTraceWrapperDeinit();
90 static void dwTraceReset();
91
92 static void dwTraceBindOutput(TraceBuf* const buf);
93 static void dwTraceRegisterCallback(avtFlushCb_t func, void* const userdata);
94
95 static void dwTraceMark(
96 TraceChannel const chan, dwtFixedString_t const& name = dwtFixedString_t(""),
97 Level const level = DW_TRACE_LEVEL_DEFAULT,
98 dwtFixedString_t const& payload = dwtFixedString_t(""),
99 dw::core::Optional<uint64_t> const nvtxPayload = dw::core::NULLOPT);
100
101 static void dwTraceBegin(TraceChannel const chan, dwtFixedString_t const& name = dwtFixedString_t(""),
102 Level const level = DW_TRACE_LEVEL_DEFAULT,
103 dwtFixedString_t const& payload = dwtFixedString_t(""),
104 dw::core::Optional<uint64_t> const nvtxPayload = dw::core::NULLOPT);
105
106 static void dwTraceEnd(TraceChannel const chan, dwtFixedString_t const& name = dwtFixedString_t(""),
107 Level const level = DW_TRACE_LEVEL_DEFAULT,
108 dwtFixedString_t const& payload = dwtFixedString_t(""),
109 dw::core::Optional<uint64_t> const nvtxPayload = dw::core::NULLOPT);
110
111 static void dwTraceAsyncBegin(TraceChannel const chan, dwtFixedString_t const& name = dwtFixedString_t(""),
112 Level const level = DW_TRACE_LEVEL_DEFAULT,
113 dwtFixedString_t const& payload = dwtFixedString_t(""),
114 dw::core::Optional<uint64_t> const nvtxPayload = dw::core::NULLOPT);
115
116 static void dwTraceAsyncEnd(TraceChannel const chan, dwtFixedString_t const& name = dwtFixedString_t(""),
117 Level const level = DW_TRACE_LEVEL_DEFAULT,
118 dwtFixedString_t const& payload = dwtFixedString_t(""),
119 dw::core::Optional<uint64_t> const nvtxPayload = dw::core::NULLOPT);
120
121 static void dwTraceCudaBegin(TraceChannel const chan, dwtFixedString_t const& name = dwtFixedString_t(""),
122 cudaStream_t const stream = nullptr,
123 Level const level = DW_TRACE_LEVEL_DEFAULT,
124 dwtFixedString_t const& payload = dwtFixedString_t(""));
125
126 static void dwTraceCudaEnd(TraceChannel const chan, dwtFixedString_t const& name = dwtFixedString_t(""),
127 cudaStream_t stream = nullptr,
128 Level const level = DW_TRACE_LEVEL_DEFAULT,
129 dwtFixedString_t const& payload = dwtFixedString_t(""));
130
131 static void dwTraceCudaRecordAsync(TraceChannel const chan, dwtFixedString_t const& name = dwtFixedString_t(""),
132 cudaStream_t const stream = nullptr,
133 Level const level = DW_TRACE_LEVEL_DEFAULT);
134
136 Level const level = DW_TRACE_LEVEL_DEFAULT,
137 dwtFixedString_t const& payload = dwtFixedString_t(""));
138
140
141 static void dwTraceFlush(bool const isForce);
142
143#ifdef __QNX__
144 static void dwTraceBootProfiler(const dw::core::FixedString<256>& msg);
145#endif
146};
147
148} // namespace trace
149} // namespace dw
150
151#endif // DWTRACE_TRACE_FUNCTIONS_HPP_
static void dwTraceAsyncEnd(TraceChannel const chan, dwtFixedString_t const &name=dwtFixedString_t(""), Level const level=DW_TRACE_LEVEL_DEFAULT, dwtFixedString_t const &payload=dwtFixedString_t(""), dw::core::Optional< uint64_t > const nvtxPayload=dw::core::NULLOPT)
static void fTraceWrite(dwtFixedString_t &str)
static void dwTraceWrapperDeinit()
static uint64_t getFlushInterval()
static void dwTraceBegin(TraceChannel const chan, dwtFixedString_t const &name=dwtFixedString_t(""), Level const level=DW_TRACE_LEVEL_DEFAULT, dwtFixedString_t const &payload=dwtFixedString_t(""), dw::core::Optional< uint64_t > const nvtxPayload=dw::core::NULLOPT)
static void dwTraceFlush(bool const isForce)
static bool isFTraceBackendEnabled()
static bool isFileBackendEnabled()
static Level getTraceLevel()
static int32_t getHostMemUsed()
static void dwTraceReset()
static void dwTraceRegisterCallback(avtFlushCb_t func, void *const userdata)
static void dwTraceWrapperReset()
static bool isDWTracingEnabled()
static void dwTraceAsyncBegin(TraceChannel const chan, dwtFixedString_t const &name=dwtFixedString_t(""), Level const level=DW_TRACE_LEVEL_DEFAULT, dwtFixedString_t const &payload=dwtFixedString_t(""), dw::core::Optional< uint64_t > const nvtxPayload=dw::core::NULLOPT)
static void dwTraceWrapperInit(TracerConfig const tracerCfg)
static bool isNVTXBackendEnabled()
static size_t getDeviceMemFree()
static void dwTraceCudaCollectAll()
static void dwTraceCudaEnd(TraceChannel const chan, dwtFixedString_t const &name=dwtFixedString_t(""), cudaStream_t stream=nullptr, Level const level=DW_TRACE_LEVEL_DEFAULT, dwtFixedString_t const &payload=dwtFixedString_t(""))
static void dwTraceEnd(TraceChannel const chan, dwtFixedString_t const &name=dwtFixedString_t(""), Level const level=DW_TRACE_LEVEL_DEFAULT, dwtFixedString_t const &payload=dwtFixedString_t(""), dw::core::Optional< uint64_t > const nvtxPayload=dw::core::NULLOPT)
static dwtFixedString_t singlePayload(char8_t const *const str1)
static void dwTraceBindOutput(TraceBuf *const buf)
static void dwTraceEnable(TracerConfig &config)
static Level getTraceLevel(const sv &level)
static void dwTraceCoreInit(TracerConfig tracerCfg)
static void dwTraceCudaRecordAsync(TraceChannel const chan, dwtFixedString_t const &name=dwtFixedString_t(""), cudaStream_t const stream=nullptr, Level const level=DW_TRACE_LEVEL_DEFAULT)
static void dwTraceDisable(uint64_t const chanMask)
static void dwTraceEnableAll()
static dwtFixedString_t singlePayload(int32_t const i)
static dwtFixedString_t joinPayloadChars(char8_t const *const str1, char8_t const *const str2)
static void dwTraceCudaCollectAsync(TraceChannel const chan, dwtFixedString_t const &name=dwtFixedString_t(""), Level const level=DW_TRACE_LEVEL_DEFAULT, dwtFixedString_t const &payload=dwtFixedString_t(""))
static void fTraceDeInit()
static void dwTraceCudaBegin(TraceChannel const chan, dwtFixedString_t const &name=dwtFixedString_t(""), cudaStream_t const stream=nullptr, Level const level=DW_TRACE_LEVEL_DEFAULT, dwtFixedString_t const &payload=dwtFixedString_t(""))
static uint64_t getNvMapMemUsed()
static void dwTraceMark(TraceChannel const chan, dwtFixedString_t const &name=dwtFixedString_t(""), Level const level=DW_TRACE_LEVEL_DEFAULT, dwtFixedString_t const &payload=dwtFixedString_t(""), dw::core::Optional< uint64_t > const nvtxPayload=dw::core::NULLOPT)
Level
Tracing can be controlled through tracing levels.
TraceChannel
DWTrace channels are used for capturing similar traces in one place.
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.
uint32_t getPreferredBlockingFlags()
dw::core::FixedString< DW_TRACE_MAX_TAG_SIZE > dwtFixedString_t
Definition: TraceTypes.hpp:51
bool isBlockingSyncPreferred()
dw::core::StringView sv
Definition: TraceTypes.hpp:60
dwtVectorFixed_t< DWTraceChannel > TraceBuf
void(*)(TraceBuf *&, void *) avtFlushCb_t
DWTrace initialisation and configuration structure.