/* * SPDX-FileCopyrightText: Copyright (c) 2012-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #ifndef _PROFILER_H_ #define _PROFILER_H_ /*! * @file profiler.h * @brief Simple API to measure elapsed times in RM for profiling and statistics * * The primary goals of this API are to: * 1. Be lightweight and have little-to-no setup required (built into release drivers) * 2. Defer as much analysis as possible to the user of the data (keep it simple) * 3. Provide sub-millisecond resolution if possible (medium-high granularity) * * This is intended mainly for coarse measurements of time-critical software * sequences, such as GC6. For example, the measurements could be used to catch * major latency regressions in a particular timing module. * * For more sophisticated profiling (e.g. for prospective analysis), use of an * external profiling tool (e.g. xperf with ETW) is recommended instead. */ #include "core/core.h" /*! * Record containing the statistics of a single time module to be profiled * periodically. * * This tracks the min/max elapsed time over all the measurement * cycles, as well as the total elapsed time and number of cycles. * To calculate the average elapsed time per cycle, divide total_ns by count. * * 64-bit precision integers are used to hold nanosecond resolution * over long periods of time (e.g. greater than 4 seconds). */ typedef struct { NvU64 count; //