NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release

Detailed Description

Data Structures

struct  stmElementInfo_t
 A singular event. More...
 
struct  stmPerfInfo_t
 A singular perfInfo event. More...
 
struct  stmStateInfo_t
 A singular State Manager event. More...
 
struct  stmHeaderInfo_t
 STM Log Header Information needed by STM Analytics. More...
 

Macros

#define STM_RESOURCE_NAME_MAX   (41)
 
#define STM_MAX_SCHEDULES   (8)
 

Typedefs

typedef enum stmEventType_t stmEventType_t
 Types of Events logged by STM. More...
 
typedef uint16_t stmElementOptionalVal
 
typedef uint64_t stmElementTimestamp
 
typedef int(* stmLoggingEventCallback_t) (void *userdata, stmElementInfo_t *buf, size_t size)
 Function signature for STM event log callbacks. More...
 
typedef int(* stmLoggingStateCallback_t) (void *userdata, stmStateInfo_t *buf, size_t size)
 Function signature for STM state manager log callbacks. More...
 
typedef int(* stmLoggingPerfInfoCallback_t) (void *userdata, stmPerfInfo_t *buf, size_t size)
 Function signature for perfInfo log Callbacks. More...
 

Enumerations

enum  stmClockInfo_t {
  stmClock_HW = 0,
  stmClock_REALTIME,
  stmClock_PTP_IOCTL_NVPPS,
  stmClock_DGPU,
  stmClock_THREAD_CPU
}
 Types of Clocks used by STM. More...
 
enum  stmEventType_t {
  STM_EVENT_EXECUTION_START = 0,
  STM_EVENT_EXECUTION_END,
  STM_EVENT_FRAME_SKIPPED,
  STM_EVENT_CLIENT_CONNECT,
  STM_EVENT_CLIENT_DISCONNECT,
  STM_EVENT_CLIENT_CRASH,
  STM_EVENT_FENCE_TIMESTAMP_CF,
  STM_EVENT_FENCE_TIMESTAMP_SF,
  STM_EVENT_RUNNABLE_START,
  STM_EVENT_RUNNABLE_END,
  STM_EVENT_COLLECT_RTC,
  STM_EVENT_COLLECT_TSC,
  STM_EVENT_STATE_UPDATE,
  STM_EVENT_PERFORMANCE,
  STM_EVENT_CUSUB_OVERHEAD,
  STM_EVENT_CUF_OVERHEAD,
  STM_EVENT_VPUSUB_OVERHEAD,
  STM_EVENT_VPUF_OVERHEAD,
  STM_EVENT_CUDLASUB_OVERHEAD,
  STM_EVENT_CUDLAF_OVERHEAD,
  STM_EVENT_VULKANSUB_OVERHEAD,
  STM_EVENT_VULKANF_OVERHEAD,
  STM_EVENT_LDCSUB_OVERHEAD,
  STM_EVENT_LDCF_OVERHEAD,
  STM_EVENT_NV2DSUB_OVERHEAD,
  STM_EVENT_NV2DF_OVERHEAD,
  STM_EVENT_TIMESTAMP_COLLECTION_OVERHEAD,
  STM_EVENT_THREAD_START,
  STM_EVENT_THREAD_END,
  STM_EVENT_ERROR,
  STM_EVENT_MAX
}
 Types of Events logged by STM. More...
 
enum  stmPerformanceEvent_t {
  INIT_TIME_START = 0,
  INIT_TIME_DONE,
  ARG_PARSING_TIME_START,
  ARG_PARSING_TIME_DONE,
  SCHED_PARSING_TIME_START,
  SCHED_PARSING_TIME_DONE,
  COMMAND_RESOURCE_TIME_START,
  COMMAND_RESOURCE_TIME_DONE,
  SYNC_TIME_START,
  SYNC_TIME_DONE,
  SCHED_START_INIT,
  SCHED_START_DONE,
  SCHED_STOP_INIT,
  SCHED_STOP_DONE,
  SCHED_ROLLOVER_INIT,
  SCHED_ROLLOVER_DONE,
  SCHED_CALLBACK_START,
  SCHED_CALLBACK_DONE,
  INIT_MEMORY_OVERHEAD,
  SYNC_MEMORY_OVERHEAD,
  COMMAND_RESOURCE_MEMORY_OVERHEAD,
  SHM_COMM_SETUP_TIME_START,
  SHM_COMM_SETUP_TIME_STOP,
  LOGGER_SETUP_TIME_START,
  LOGGER_SETUP_TIME_STOP,
  MANAGED_CLIENT_SPAWN_START,
  MANAGED_CLIENT_SPAWN_STOP
}
 Type of event being logged for STM_EVENT_PERFORMANCE events. More...
 

Functions

STM_API stmErrorCode_t stmLoggerInit (stmHeaderInfo_t *header)
 Initialize STM logger context. More...
 
STM_API stmErrorCode_t stmLoggerInitWithDiscriminator (int32_t discriminator, stmHeaderInfo_t *header)
 Initialize STM logger context with a discriminator. More...
 
STM_API stmErrorCode_t stmRegisterEventCallBack (stmLoggingEventCallback_t func, void *userdata)
 Registers a callback function with the Logger to be invoked during a event buffer write. More...
 
STM_API stmErrorCode_t stmRegisterStateCallBack (stmLoggingStateCallback_t func, void *userdata)
 Registers a callback function with the Logger to be invoked during a state buffer write. More...
 
STM_API stmErrorCode_t stmRegisterPerfInfoCallBack (stmLoggingPerfInfoCallback_t func, void *userdata)
 Registers a callback function with the Logger to be invoked during a perfInfo buffer write. More...
 
STM_API stmErrorCode_t stmEnterLoggingLoop ()
 Enters logging loop which logs at a set frequency. More...
 
STM_API stmErrorCode_t stmLoggerFlush (void)
 Flush all buffers to the callbacks. More...
 
STM_API stmErrorCode_t stmLoggerExit (void)
 Cleans up STM logger context. More...
 

Macro Definition Documentation

◆ STM_MAX_SCHEDULES

#define STM_MAX_SCHEDULES   (8)

Definition at line 55 of file stm_logging.h.

◆ STM_RESOURCE_NAME_MAX

#define STM_RESOURCE_NAME_MAX   (41)

Definition at line 53 of file stm_logging.h.

Typedef Documentation

◆ stmElementOptionalVal

typedef uint16_t stmElementOptionalVal

Definition at line 141 of file stm_logging.h.

◆ stmElementTimestamp

typedef uint64_t stmElementTimestamp

Definition at line 142 of file stm_logging.h.

◆ stmEventType_t

Types of Events logged by STM.

◆ stmLoggingEventCallback_t

typedef int(* stmLoggingEventCallback_t) (void *userdata, stmElementInfo_t *buf, size_t size)

Function signature for STM event log callbacks.

Parameters
[in]userdataPointer to any data needed by the event callback
[in]bufElement log buffer containing STM runtime events
[in]sizeSize of the element buffer
Returns
status of the callback function, EXIT_SUCCESS on success

Definition at line 270 of file stm_logging.h.

◆ stmLoggingPerfInfoCallback_t

typedef int(* stmLoggingPerfInfoCallback_t) (void *userdata, stmPerfInfo_t *buf, size_t size)

Function signature for perfInfo log Callbacks.

Parameters
[in]userdataPointer to any data needed by the perfInfo callback
[in]bufperfInfo log buffer containing STM perfInfo events
[in]sizeSize of the perfInfo log buffer
Returns
status of the callback function, EXIT_SUCCESS on success

Definition at line 292 of file stm_logging.h.

◆ stmLoggingStateCallback_t

typedef int(* stmLoggingStateCallback_t) (void *userdata, stmStateInfo_t *buf, size_t size)

Function signature for STM state manager log callbacks.

Parameters
[in]userdataPointer to any data needed by the state callback
[in]bufstate log buffer containing STM state manager events
[in]sizeSize of the state log buffer
Returns
status of the callback function, EXIT_SUCCESS on success

Definition at line 281 of file stm_logging.h.

Enumeration Type Documentation

◆ stmClockInfo_t

Types of Clocks used by STM.

Enumerator
stmClock_HW 

Timestamp Counter.

stmClock_REALTIME 

Real time Counter.

stmClock_PTP_IOCTL_NVPPS 

PTP hardware clock.

stmClock_DGPU 

Dedicated GPU clock.

stmClock_THREAD_CPU 

Thread-specific CPU clock.

Definition at line 60 of file stm_logging.h.

◆ stmEventType_t

Types of Events logged by STM.

Enumerator
STM_EVENT_EXECUTION_START 

Start of hyperepoch frame.

STM_EVENT_EXECUTION_END 

End of hyperepoch frame.

STM_EVENT_FRAME_SKIPPED 

Event logged instead of START/END if the frame execution was skipped.

STM_EVENT_CLIENT_CONNECT 

Client connected [Deprecated].

STM_EVENT_CLIENT_DISCONNECT 

Client disconnected [Deprecated].

STM_EVENT_CLIENT_CRASH 

Connected client crashed [Deprecated].

STM_EVENT_FENCE_TIMESTAMP_CF 

Event logged when a fence is signaled.

STM_EVENT_FENCE_TIMESTAMP_SF 

Event logged for engine (GPU only) fences before the start of the engine submittee.

STM_EVENT_RUNNABLE_START 

Event logged when a CPU runnable starts.

STM_EVENT_RUNNABLE_END 

Event logged when a CPU runnable ends.

STM_EVENT_COLLECT_RTC 

Collect Real Time Clock timestamp.

STM_EVENT_COLLECT_TSC 

Collect Timestamp Counter.

STM_EVENT_STATE_UPDATE 

Change state.

STM_EVENT_PERFORMANCE 

Performance profiling related info.

STM_EVENT_CUSUB_OVERHEAD 

Event to collect runtime overhead for CUSUB STM command.

STM_EVENT_CUF_OVERHEAD 

Event to collect runtime overhead for CUF STM command.

STM_EVENT_VPUSUB_OVERHEAD 

Event to collect runtime overhead for VPUSUB STM command.

STM_EVENT_VPUF_OVERHEAD 

Event to collect runtime overhead for VPUF STM command.

STM_EVENT_CUDLASUB_OVERHEAD 

Event to collect runtime overhead for CUDLASUB STM command.

STM_EVENT_CUDLAF_OVERHEAD 

Event to collect runtime overhead for CUDLAF STM command.

STM_EVENT_VULKANSUB_OVERHEAD 

Event to collect runtime overhead for VULKANSUB STM command.

STM_EVENT_VULKANF_OVERHEAD 

Event to collect runtime overhead for VULKANF STM command.

STM_EVENT_LDCSUB_OVERHEAD 

Event to collect runtime overhead for LDCSUB STM command.

STM_EVENT_LDCF_OVERHEAD 

Event to collect runtime overhead for LDCF STM command.

STM_EVENT_NV2DSUB_OVERHEAD 

Event to collect runtime overhead for NV2DSUB STM command.

STM_EVENT_NV2DF_OVERHEAD 

Event to collect runtime overhead for NV2DF STM command.

STM_EVENT_TIMESTAMP_COLLECTION_OVERHEAD 

Event to collect runtime overhead for engine fence timestamps.

STM_EVENT_THREAD_START 

Event to collect active thread start time.

STM_EVENT_THREAD_END 

Event to collect active thread end time.

STM_EVENT_ERROR 

Logged to indicate an error while logging [Deprecated].

STM_EVENT_MAX 

Max log value.

Should never be in the log

Definition at line 76 of file stm_logging.h.

◆ stmPerformanceEvent_t

Type of event being logged for STM_EVENT_PERFORMANCE events.

Enumerator
INIT_TIME_START 

STM master init start timestamp.

INIT_TIME_DONE 

STM master init completion timestamp.

ARG_PARSING_TIME_START 

STM master commandline parsing start timestamp.

ARG_PARSING_TIME_DONE 

STM master commandline parsing completion timestamp.

SCHED_PARSING_TIME_START 

STM master schedule parsing start timestamp.

SCHED_PARSING_TIME_DONE 

STM master schedule parsing completion timestamp.

COMMAND_RESOURCE_TIME_START 

STM master command setup start timestamp.

COMMAND_RESOURCE_TIME_DONE 

STM master command setup completion timestamp.

SYNC_TIME_START 

STM master sync server setup start timestamp.

SYNC_TIME_DONE 

STM master sync server setup completion timestamp.

SCHED_START_INIT 

Complete schedule switch init start timestamp.

SCHED_START_DONE 

Complete schedule switch init completion timestamp.

SCHED_STOP_INIT 

Complete schedule switch stop start timestamp.

SCHED_STOP_DONE 

Complete schedule switch stop completion timestamp.

SCHED_ROLLOVER_INIT 

Rollover schedule switch init start timestamp.

SCHED_ROLLOVER_DONE 

Rollover schedule switch done completion timestamp.

SCHED_CALLBACK_START 

Rollover schedule switch callback start timestamp.

SCHED_CALLBACK_DONE 

Rollover schedule switch callback done completion timestamp.

INIT_MEMORY_OVERHEAD 

STM master init memory overhead.

SYNC_MEMORY_OVERHEAD 

STM master sync server memory overhead.

COMMAND_RESOURCE_MEMORY_OVERHEAD 

STM master command memory overhead.

SHM_COMM_SETUP_TIME_START 

STM master shm/com setup start.

SHM_COMM_SETUP_TIME_STOP 

STM master shm/com setup done.

LOGGER_SETUP_TIME_START 

STM master logger setup start.

LOGGER_SETUP_TIME_STOP 

STM master logger setup done.

MANAGED_CLIENT_SPAWN_START 

STM master launching managed clients start.

MANAGED_CLIENT_SPAWN_STOP 

STM master launching managed clients stop.

Definition at line 147 of file stm_logging.h.

Function Documentation

◆ stmEnterLoggingLoop()

STM_API stmErrorCode_t stmEnterLoggingLoop ( )

Enters logging loop which logs at a set frequency.

Remarks
This API can only be called once; doing so multiple times will result in undefined behaviour. Should only be called after stmLoggerInit / stmLoggerInitWithDiscriminator and after registering the callback functions.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER if write fails or LogServer construction fails
  • STM_ERROR_NOT_INITIALIZED if logger isn't initialized with a call to stmLoggerInit or stmLoggerInitWithDiscriminator
  • STM_SUCCESS if successful.

◆ stmLoggerExit()

STM_API stmErrorCode_t stmLoggerExit ( void  )

Cleans up STM logger context.

No STM logging APIs can be called after this.

Remarks
This API can only be called once; doing so multiple times will cause undefined behavior.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_SUCCESS

◆ stmLoggerFlush()

STM_API stmErrorCode_t stmLoggerFlush ( void  )

Flush all buffers to the callbacks.

Useful for ensuring all data is written before a non-graceful exit.

Remarks
If this API is called after stmLoggerExit, the behavior is well defined and will return STM_SUCCESS.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_SUCCESS

◆ stmLoggerInit()

STM_API stmErrorCode_t stmLoggerInit ( stmHeaderInfo_t *  header)

Initialize STM logger context.

Remarks
This API must be called before any other STM Logger APIs. This API will block until the STM master process is started. Logger's context should be cleaned up with stmLoggerExit() after STM has completed its execution. There is only one logger in the system. Same as calling stmLoggerInitWithDiscriminator() with discriminator = -1.
Parameters
[out]headerHeader for the LogFile.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER if header provided is invalid
  • STM_ERROR_GENERIC Failed to connect with STM master
  • STM_SUCCESS if successful.

◆ stmLoggerInitWithDiscriminator()

STM_API stmErrorCode_t stmLoggerInitWithDiscriminator ( int32_t  discriminator,
stmHeaderInfo_t *  header 
)

Initialize STM logger context with a discriminator.

Remarks
This API must be called before any other STM Logger APIs. This API will block until the STM master process with this discriminator is started. Logger's context should be cleaned up with stmLoggerExit() after STM has completed its execution. Logger must call at most one of the two: stmLoggerInit() or stmLoggerInitWithDiscriminator(), if both are called single or multiple times, it will cause undefined behavior. There is only one logger in the system. All negative values of discriminator are equivalent and the same as calling stmScheduleManagerInit()
Parameters
[in]discriminatorUsed to distinguish instance of STM.
[out]headerHeader for the LogFile.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER if header provided is invalid
  • STM_ERROR_GENERIC Failed to connect with STM master
  • STM_SUCCESS if successful.

◆ stmRegisterEventCallBack()

STM_API stmErrorCode_t stmRegisterEventCallBack ( stmLoggingEventCallback_t  func,
void *  userdata 
)

Registers a callback function with the Logger to be invoked during a event buffer write.

Remarks
This API can only be called once; doing so multiple times will result in an error. Should only be called after stmLoggerInit / stmLoggerInitWithDiscriminator and before stmEnterLoggingLoop.
Parameters
[in]funcThe callback function to be executed.
[in]userdataOptional pointer to any data needed by the callback.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER : if a eventcall back function has already been registered with the Logger or the callback is invalid.
  • STM_SUCCESS : if successful.

◆ stmRegisterPerfInfoCallBack()

STM_API stmErrorCode_t stmRegisterPerfInfoCallBack ( stmLoggingPerfInfoCallback_t  func,
void *  userdata 
)

Registers a callback function with the Logger to be invoked during a perfInfo buffer write.

Remarks
This API can only be called once; doing so multiple times will result in an error. Should only be called after stmLoggerInit / stmLoggerInitWithDiscriminator and before stmEnterLoggingLoop.
Parameters
[in]funcThe callback function to be executed.
[in]userdataOptional pointer to any data needed by the callback.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER if a perfInfo callback function has already been registered with the Logger or the callback is invalid.
  • STM_SUCCESS if successful.

◆ stmRegisterStateCallBack()

STM_API stmErrorCode_t stmRegisterStateCallBack ( stmLoggingStateCallback_t  func,
void *  userdata 
)

Registers a callback function with the Logger to be invoked during a state buffer write.

Remarks
This API can only be called once; doing so multiple times will result in an error. Should only be called after stmLoggerInit / stmLoggerInitWithDiscriminator and before stmEnterLoggingLoop.
Parameters
[in]funcThe callback function to be executed.
[in]userdataOptional pointer to any data needed by the callback.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER if a state callback function has already been registered with the Logger or the callback is invalid.
  • STM_SUCCESS if successful.