NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release

Detailed Description

Data Structures

struct  stmRunnableInfo_t
 Information which can be queried by CPU runnables using stmGetRuntimeInfo() More...
 

Macros

#define STM_ALL_SCHEDULES   UINT16_MAX
 The key to use to reference to all schedules. More...
 

Typedefs

typedef void(* stmRunnable_t) (void *userdata)
 Function signature for STM CPU runnable. More...
 
typedef void(* stmCudaSubmitter_t) (void *userdata, cudaStream_t stream)
 Function signature for STM CUDA submitter runnable. More...
 
typedef void(* stmScheduleSwitchCallback_t) (uint16_t startScheduleId, uint16_t hyperepochId, void *userdata)
 Function signature for STM schedule switch callback. More...
 

Functions

STM_API stmErrorCode_t stmClientInit (const char *clientName, uint16_t scheduleId)
 Initialize STM client context for all schedules. More...
 
STM_API stmErrorCode_t stmClientInitWithDiscriminator (const char *clientName, int32_t discriminator, uint16_t scheduleId)
 Initialize STM client context with a discriminator for all schedules. More...
 
STM_API stmErrorCode_t stmRegisterCpuRunnable (stmRunnable_t func, const char *const runnableId, void *userdata)
 Registers an stmRunnable_t function with the name provided by the user to the STM compiler. More...
 
STM_API stmErrorCode_t stmRegisterCudaSubmitter (stmCudaSubmitter_t func, const char *const runnableId, void *userdata)
 Registers an stmCudaSubmitter_t function with the name provided by the user to the STM compiler. More...
 
STM_API stmErrorCode_t stmRegisterCudaResource (const char *resourceName, cudaStream_t stream)
 Registers a CUDA stream resource. More...
 
STM_API stmErrorCode_t stmRegisterCallBack (stmScheduleSwitchCallback_t func, void *userdata)
 Registers a callback function with a client to be invoked during a schedule switch. More...
 
STM_API stmErrorCode_t stmNotifyScheduleReady (uint16_t scheduleId)
 Notify the STM scheduler that the schedule is ready to run. More...
 
STM_API stmErrorCode_t stmWaitForExit (void)
 Wait until the STM schedule has exited and it is safe to exit the client using stmClientExit. More...
 
STM_API stmErrorCode_t stmGetRuntimeInfo (stmRunnableInfo_t *info)
 Get runtime information about execution. More...
 
STM_API stmErrorCode_t stmEventInit (void)
 Initializes context for external fence signaling. More...
 
STM_API stmErrorCode_t stmEventInitWithDiscriminator (int32_t discriminator)
 Initializes context for external fence signaling with a discriminator. More...
 
STM_API void stmEventDeinit (void)
 Deinitializes context for external fence signaling. More...
 
STM_API stmErrorCode_t stmTriggerHyperepoch (uint16_t hyperepochId)
 Signals start of an event-triggered hyperepoch. More...
 
STM_API stmErrorCode_t stmExitScheduler (void)
 Request an exit to the global STM scheduler. More...
 
STM_API void stmClientExit (void)
 Cleans up STM client context. More...
 

Macro Definition Documentation

◆ STM_ALL_SCHEDULES

#define STM_ALL_SCHEDULES   UINT16_MAX

The key to use to reference to all schedules.

Definition at line 78 of file stm.h.

Typedef Documentation

◆ stmCudaSubmitter_t

typedef void(* stmCudaSubmitter_t) (void *userdata, cudaStream_t stream)

Function signature for STM CUDA submitter runnable.

Remarks
stmCudaSubmitter_t functions should contain some CPU work, followed by some number of asynchronous CUDA kernel launches. All kernels launched in submitter must be launched onto cudaStream_t stream. The use of stream 0 (the null stream) is prohibited due to CUDA's implicit synchronization semantics. This function should not internally launch any threads or call any blocking APIs, including cudaMemcpy(), cudaMemset(), cudaFree(), etc..
Parameters
[in]userdataPointer to any data needed by the runnable
[in]streamCUDA stream created by application for the kernels

Definition at line 108 of file stm.h.

◆ stmRunnable_t

typedef void(* stmRunnable_t) (void *userdata)

Function signature for STM CPU runnable.

Remarks
stmRunnable_t functions should only contain CPU work. They should not call any blocking APIs or internally launch any threads.

Definition at line 95 of file stm.h.

◆ stmScheduleSwitchCallback_t

typedef void(* stmScheduleSwitchCallback_t) (uint16_t startScheduleId, uint16_t hyperepochId, void *userdata)

Function signature for STM schedule switch callback.

Remarks
stmScheduleSwitchCallback_t functions should only contain some CPU work. This function will be called once per hyperepoch for each client.

Definition at line 396 of file stm.h.

Function Documentation

◆ stmClientExit()

STM_API void stmClientExit ( void  )

Cleans up STM client context.

No STM APIs can be called after this.

Remarks
This API can only be called once per call to stmClientInit(); doing so multiple times will cause undefined behavior.

◆ stmClientInit()

STM_API stmErrorCode_t stmClientInit ( const char *  clientName,
uint16_t  scheduleId 
)

Initialize STM client context for all schedules.

Remarks
This API will block until the STM master process is started. Client contexts should be cleaned up with stmClientExit() after STM has completed its execution. Same as calling stmClientInitWithDiscriminator() with discriminator = -1. This must be called after registering all resources/runnables for the schedule(s) specified by scheduleId.
Parameters
[in]clientNameName of the client.
[in]scheduleIdSchedule id for the schedule to initialize. Note if this is STM_ALL_SCHEDULES, all schedules will be initialized and this will block until all of them are ready. Thus, if it is necessary to start a schedule before the rest are initialized, the call to the early schedule must occur first.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_GENERIC if some error occured.
  • STM_SUCCESS otherwise.

◆ stmClientInitWithDiscriminator()

STM_API stmErrorCode_t stmClientInitWithDiscriminator ( const char *  clientName,
int32_t  discriminator,
uint16_t  scheduleId 
)

Initialize STM client context with a discriminator for all schedules.

Remarks
This API will block until the STM master process with this discriminator is started. Client contexts should be cleaned up with stmClientExit() after STM has completed its execution. Client must call at most one of the two: stmClientInit() or stmClientInitWithDiscriminator() All negative values of discriminator are equivalent and the same as calling stmClientInit() This must be called after registering all resources/runnables for the schedule(s) specified by scheduleId.
Parameters
[in]clientNameName of the client.
[in]discriminatorDiscriminator for the client.
[in]scheduleIdSchedule id for the schedule to initialize. Note if this is STM_ALL_SCHEDULES, all schedules will be initialized and this will block until all of them are ready. Thus, if it is necessary to start a schedule before the rest are initialized, the call to the early schedule must occur first.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_GENERIC if some error occured.
  • STM_SUCCESS otherwise.

◆ stmEventDeinit()

STM_API void stmEventDeinit ( void  )

Deinitializes context for external fence signaling.

◆ stmEventInit()

STM_API stmErrorCode_t stmEventInit ( void  )

Initializes context for external fence signaling.

Returns
stmErrorCode_t, the completion code of the operation:
  • STM_SUCCESS if it is successful.
  • an error code otherwise

◆ stmEventInitWithDiscriminator()

STM_API stmErrorCode_t stmEventInitWithDiscriminator ( int32_t  discriminator)

Initializes context for external fence signaling with a discriminator.

Parameters
discriminatorThe discriminator to use.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_SUCCESS if it is successful.
  • an error code otherwise

◆ stmExitScheduler()

STM_API stmErrorCode_t stmExitScheduler ( void  )

Request an exit to the global STM scheduler.

Remarks
Called from within a runnable; causes all clients to return from their respective calls to stmWaitForExit() at the next epoch boundary. Only needs to be called from one runnable in one STM client; subsequent calls are ignored.
Warning
This API is not supproted in the safety build.
Returns
stmErrorCode_t, the completion code of the operation: -STM_SUCCESS if successful. -STM_ERROR_GENERIC if the request to set the state to exit failed. -STM_ERROR_BAD_PARAMETER if the request to set the state to exit has already been triggered. -STM_ERROR_NOT_INITIALIZED if stmClientInit() has not been called, or stmClientExit() has already been called. -STM_ERROR_NOT_SUPPORTED if called in a safety build.

◆ stmGetRuntimeInfo()

STM_API stmErrorCode_t stmGetRuntimeInfo ( stmRunnableInfo_t *  info)

Get runtime information about execution.

Remarks
Must be called from within a CPU runnable
Parameters
[out]infoPointer to stmRunnableInfo_t whose fields will be populated
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER if info is NULL.
  • STM_ERROR_NOT_FOUND if the current STM thread could not be found.
  • STM_ERROR_INVALID_STATE if the requisite information could not be obtained.
  • STM_SUCCESS otherwise.

◆ stmNotifyScheduleReady()

STM_API stmErrorCode_t stmNotifyScheduleReady ( uint16_t  scheduleId)

Notify the STM scheduler that the schedule is ready to run.

This is non-blocking once the state of the specified schedule is updated to ready. Once all clients notify that all schedules are ready by specifying STM_ALL_SCHEDULES, STM will have fully transitioned from init to ready state and no more initialization APIs will be called by STM.

Parameters
[in]scheduleIdThe schedule ID to notify the scheduler about. Can be STM_ALL_SCHEDULES to notify all schedules.
Returns
stmErrorCode_t

◆ stmRegisterCallBack()

STM_API stmErrorCode_t stmRegisterCallBack ( stmScheduleSwitchCallback_t  func,
void *  userdata 
)

Registers a callback function with a client to be invoked during a schedule switch.

Before this client starts running, the callback function will be invoked.

Remarks
This API can only be called once per client; doing so multiple times will result in an error. It must be called before any schedule this client participates in starts running.
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 call back function has already been registered with this client.
  • STM_ERROR_GENERIC if some other error occured.
  • STM_SUCCESS

◆ stmRegisterCpuRunnable()

STM_API stmErrorCode_t stmRegisterCpuRunnable ( stmRunnable_t  func,
const char *const  runnableId,
void *  userdata 
)

Registers an stmRunnable_t function with the name provided by the user to the STM compiler.

Parameters
[in]funcSTM CPU runnable function pointer.
[in]runnableIdName of CPU runnable provided to the STM compiler.
[in]userdataPointer to any data needed by the runnable.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER if runnableId exceeds STM_FUNC_NAME_MAX.
  • STM_ERROR_GENERIC if some other error occured.
  • STM_SUCCESS otherwise.

◆ stmRegisterCudaResource()

STM_API stmErrorCode_t stmRegisterCudaResource ( const char *  resourceName,
cudaStream_t  stream 
)

Registers a CUDA stream resource.

Parameters
[in]resourceNameName of resource. Needs to match resource name passed to STM compiler.
[in]streamCUDA stream created by application.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER if any of the following occurs:
    • resourceName exceeds STM_RESOURCE_NAME_MAX
    • stream is the NULL stream or has not been previously created by calling cudaStreamCreate()
    • the same cudaStream_t has already been registered (possibly with a different resourceName)
  • STM_ERROR_GENERIC if some other error occured.
  • STM_SUCCESS otherwise.

◆ stmRegisterCudaSubmitter()

STM_API stmErrorCode_t stmRegisterCudaSubmitter ( stmCudaSubmitter_t  func,
const char *const  runnableId,
void *  userdata 
)

Registers an stmCudaSubmitter_t function with the name provided by the user to the STM compiler.

Parameters
[in]funcSTM CUDA submitter runnable function pointer.
[in]runnableIdName of CUDA submitter runnable provided to the STM compiler.
[in]userdataPointer to any data needed by the runnable.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_ERROR_BAD_PARAMETER if runnableId exceeds STM_FUNC_NAME_MAX.
  • STM_ERROR_GENERIC if some other error occured.
  • STM_SUCCESS otherwise.

◆ stmTriggerHyperepoch()

STM_API stmErrorCode_t stmTriggerHyperepoch ( uint16_t  hyperepochId)

Signals start of an event-triggered hyperepoch.

Parameters
[in]hyperepochIdThe hyperepoch id to trigger.
Note
This API can only be called after stmEventInit() or stmEventInitWithDiscriminator() has been called; and before stmEventDeinit() has been called.
Returns
stmErrorCode_t, the completion code of the operation:
  • STM_SUCCESS if the hyperepoch was triggered successfully
  • STM_ERROR_NOT_INITIALIZED if client is not initialized
  • STM_ERROR_BAD_PARAMETER if the hyperepoch id is invalid

◆ stmWaitForExit()

STM_API stmErrorCode_t stmWaitForExit ( void  )

Wait until the STM schedule has exited and it is safe to exit the client using stmClientExit.

Note
This may only be called after all schedules have been notified as ready.
Returns
stmErrorCode_t