Skip to content

Commit

Permalink
Docs updates and added macro for setting NVTX level
Browse files Browse the repository at this point in the history
  • Loading branch information
tylera-nvidia committed Oct 4, 2022
1 parent c535e36 commit f6dee29
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
18 changes: 10 additions & 8 deletions docs_input/api/nvtx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,23 @@ NVTX Examples
- NVTX range scoped to this function, named “MY_MESSAGE” with log level of Internal
* - MATX_NVTX_START("MY_MESSAGE", matx::MATX_NVTX_LOG_API )
- NVTX range scoped to this function, named “MY_MESSAGE” with log level of API
* - MATX_NVTX_START_RANGE( "Exec", matx_nvxtLogLevels::MATX_NVTX_LOG_USER, 1 )
* - MATX_NVTX_START_RANGE( "MY_MESSAGE", matx_nvxtLogLevels::MATX_NVTX_LOG_USER, 1 )
- NVTX range with manual scope, named “MY_MESSAGE”, log level of USER, and handle ID of 1
* - MATX_NVTX_END_RANGE(1)
- Ends the NVTX range of range with a handle of 1 used in NVTX_START_RANGE

Code examples are provided in the ``simple_pipeline`` code to show user utilization of the MatX NVTX API.

.. doxygenvariable:: matx::matx_nvxtLogLevels


MatX NVTX API
-----------------
.. doxygenfunction:: matx::setNVTXLogLevel
.. doxygenfunction:: matx::registerEvent
.. doxygenfunction:: matx::endEvent

.. doxygenclass:: matx::NvtxEvent
:members:

.. doxygenvariable:: matx::matx_nvxtLogLevels
MatX NVTX Logging Levels
-----------------
.. doxygenenum:: matx::matx_nvxtLogLevels

MatX NVTX Auto Range Colors
-----------------
.. doxygenvariable:: matx::nvtxColors
2 changes: 1 addition & 1 deletion examples/simple_pipeline.cu
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
cudaStreamCreate(&stream);

// manually set to log all NVTX levels
matx::setNVTXLogLevel( matx_nvxtLogLevels::MATX_NVTX_LOG_ALL );
MATX_NVTX_SET_LOG_LEVEL( matx_nvxtLogLevels::MATX_NVTX_LOG_ALL );

// create some events for timing
cudaEvent_t start, stop;
Expand Down
26 changes: 20 additions & 6 deletions include/matx/core/nvtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
namespace matx
{

/// Enum for levels of NVTX Logging. Lower level is more selective (prints less)
/**
* @brief levels of NVTX Logging. Lower level is more selective (prints less)
*
*/
enum matx_nvxtLogLevels
{
MATX_NVTX_LOG_NONE = 0,
Expand All @@ -63,7 +66,10 @@ const int32_t NVTX_WHITE = 0xFFFFFF;

static const int32_t nunNvtxColors = 10;

/// automatic NVTX Colors
/**
* @brief automatic NVTX Colors
*
*/
static const int32_t nvtxColors[nunNvtxColors] = {
NVTX_BLACK,
NVTX_RED,
Expand Down Expand Up @@ -110,6 +116,9 @@ inline matx_nvxtLogLevels globalNvtxLevel = matx_nvxtLogLevels::MATX_NVTX_LOG_AP
#define MATX_NVTX_START_RANGE( message, nvtxLevel, id ) matx::NvtxEvent MATX_UNIQUE_NAME(nvtxFlag_)( __FUNCTION__, message, nvtxLevel, id );

#define MATX_NVTX_END_RANGE( id ) endEvent( id );

#define MATX_NVTX_SET_LOG_LEVEL( nvtxLevel ) setNVTXLogLevel( nvtxLevel );

//////////// Disable NVTX Macros /////////////////

#else
Expand All @@ -127,6 +136,8 @@ inline matx_nvxtLogLevels globalNvtxLevel = matx_nvxtLogLevels::MATX_NVTX_LOG_AP
)

#define MATX_NVTX_END_RANGE( id );

#define MATX_NVTX_SET_LOG_LEVEL( nvtxLevel );

#endif
////////////////////////////////////////////////////////////////////////////////
Expand All @@ -135,7 +146,8 @@ inline matx_nvxtLogLevels globalNvtxLevel = matx_nvxtLogLevels::MATX_NVTX_LOG_AP

////////////////////////////////////////////////////////////////////////////////
///
///\brief Utility Function to set Global Log Level
///\brief Utility Function to set Global Log Level. should be called through the
/// MATX_NVTX_SET_LOG_LEVEL macro with the same parameters
///
////////////////////////////////////////////////////////////////////////////////
[[maybe_unused]] static void setNVTXLogLevel( matx_nvxtLogLevels newNVTXLevel)
Expand All @@ -145,10 +157,11 @@ inline matx_nvxtLogLevels globalNvtxLevel = matx_nvxtLogLevels::MATX_NVTX_LOG_AP

////////////////////////////////////////////////////////////////////////////////
///
///\brief Class wrapping NVTX management for automatic creation/deletion
///\brief fucntion wrapping NVTX management for automatic creation/deletion
/// MATX_NVTX_START or MATX_NVTX_START_RANGE macro with the same parameters
///
////////////////////////////////////////////////////////////////////////////////
static void registerEvent( int registerId, nvtxRangeId_t eventId )
[[maybe_unused]] static void registerEvent( int registerId, nvtxRangeId_t eventId )
{
std::pair< int, nvtxRangeId_t > newPair( registerId, eventId );
eventMap.insert(newPair);
Expand All @@ -157,7 +170,8 @@ static void registerEvent( int registerId, nvtxRangeId_t eventId )

////////////////////////////////////////////////////////////////////////////////
///
///\brief Class wrapping NVTX management for automatic creation/deletion
///\brief fucntion wrapping NVTX management for automatic creation/deletion
/// MATX_NVTX_END_RANGE macro with the same parameters
///
////////////////////////////////////////////////////////////////////////////////
static void endEvent( int id )
Expand Down

0 comments on commit f6dee29

Please sign in to comment.