|
|
VisionWorks Toolkit ReferenceApril 8, 2016 | 1.4 Release |
Describes the various mechanisms VisionWorks provides for debugging and profiling an application.
VisionWorks has various error checking mechanisms to help developers detect and debug failures caused by incorrect usages of the API, invalid primitive parameters, or resource allocation problems. These mechanisms are: API-based error status code API-based error log callback function Console message log
In the following subsections, these error debug mechanisms are further explained.
The majority of VisionWorks API functions return a vx_status code that informs you if the function completed with or without error.
Functions that return an object reference (e.g., object creation functions) do not directly return a status code; in these cases, the application can still inquire the status by calling vxGetStatus with the returned object reference as parameter.
The error status code is useful to detect an unexpected error at runtime, but it doesn't convey lots of information and it may not be enough to properly understand and analyze issues at application development time. Some of the API functions perform a complex sequence of operations internally and in this case, a simple error code can not inform you what is the actual problem is in detail. This is, for instance, the case with graph verification (vxVerifyGraph), graph execution (vxProcessGraph) and the execution of any vision primitive in immediate mode such as vxuOpticalFlowPyrLK.
To get more information about any error, it is possible to register a log callback function to a context with vxRegisterLogCallback. The callback will be called when any error occurs within this context. The callback must have an interface defined by vx_log_callback_f .
The execution of the code example given at the end of this section generates the following information:
The call to vxVerifyGraph returned -10 (VX_ERROR_INVALID_PARAMETERS) while the string passed to the callback function informs you on which node of the graph and which particular parameter caused a problem, as well as the detailed reason.
Console Message Log Error reporting through API calls in some cases might be insufficient where the failures are caused by a series of operations combined. VisionWorks provides another layer of status reporting mechanism controlled through an environment variable, called NVX_LOG. The NVX_LOG environment variable enables reporting of various messages directly to the standard output stream (stdout) to be directly generated in the console.
NVX_LOG controls debug messages for certain type of operations, called "zones". You can enable different zone debug messages by setting the NVX_LOG environment variable with the list of zones that must be activated, separated with commas. VisionWorks defines the following zones:
error : errors messageswarning : warning messagesapi : API callsdata : information about data objectsgraph : information related to graphs verification, execution and to the execution of primitives in immediate modememory : memory allocation / deallocation informationperf : performance messagesmisc : messages that do not fit any other categoryTo enable information reported in all the zones, set the environment variable to:
all : activates all console log messagesFor instance, under Linux/Bash:
For the previous code example, it would generate:
{22cd89c0} identifies the thread that generated the message.OpenVX graphs can be complex objects and they usually require special attention from developers. When there is a problem with a graph, the first thing to do is to activate the log messages for the graph, in addition of messages of warnings and errors.
It can be done this way:
It can be useful for you to temporarily set graph options; for instance, for disabling all optimizations. All graph options that can be set though the API with the NVX_GRAPH_VERIFY_OPTIONS graph attribute can be set directly though the NVX_GRAPH environment variable. In order to simplify the definition of the NVX_GRAPH environment variable, comma can be used instead of space as a separator.
In order to check that an OpenVX graph is correctly formed, or visualize a graph created by other developers, VisionWorks provides the option of generating a dot representation of graphs in a file. This graph can be visualized by any tool reading dot files, for instance, xdot under Linux/Ubuntu.
The simplest way to activate the dot generation is to set the NVX_GRAPH environment variable;
Two files are generated per graphs with the graph verified (vxVerifyGraph):
Graph and node performance counters can be accessed with the API. This is done by querying the VX_GRAPH_ATTRIBUTE_PERFORMANCE attribute for graph objects and the VX_NODE_ATTRIBUTE_PERFORMANCE attribute for node objects. For each objects, the performance counters are available in a vx_perf_t structure that provides information such as the latest, average, maximum measurement time, etc.
Graph and node performance tracking is enabled by default. Since performance measurement can create an overhead at runtime (dependent on the target platform), it can be disabled with the NVX_DIRECTIVE_PERFORMANCE_DISABLE directive. This directive can be set globally to the context (it will then propagate to all graphs and nodes of this context), or set locally to particular graphs and nodes. Performance measurement can be re-enabled with the NVX_DIRECTIVE_PERFORMANCE_ENABLE directive or set back to the default behavior with NVX_DIRECTIVE_PERFORMANCE_DEFAULT.
There is the specific perf zone in the console message log that reports performance counters without any need for application code modification.
For instance, under Linux/Bash:
It would output something similar to:
VisionWorks uses the NVIDIA Tools Extension Library (NVTX) to generate VisionWorks related events that come in addition of CUDA profiling events. Such information can be visualized with the NVIDIA visual profiler.
This VisionWorks trace generation is activated by setting the NVX_PROF environment variable to nvtx . Under Linux/Bash:
In order to enable the generation of VisionWorks specific events, the NVTX library must be installed on the target system. Under Linux, this library is installed with the CUDA toolkit, while under Windows it is installed with the NVIDIA NSight IDE.
There are different ways of collecting the profiling information and displaying them. An approach that works on both Tegra and Desktop systems is to use nvprof on the target system to generate a profiling log, and then to import it with the NVIDIA visual profiler (nvvp) running on a development computer.
Under Linux with the Tegra TX1 target system:
VisionWorks specific information is in the 'Markers and Ranges' section of the time chart created by the NVIDIA Visual profiler. VisionWorks ranges are generated for API calls, node execution, and memory movements. From this kind of time chart, application developers can see the relationship between the calls to the VisionWorks library and the CUDA workload.