System Task Manager SDK Reference  5.22
stm.h
Go to the documentation of this file.
1
2//
3// Notice
4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8//
9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10// information or for any infringement of patents or other rights of third parties that may
11// result from its use. No license is granted by implication or otherwise under any patent
12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13// expressly authorized by NVIDIA. Details are subject to change without notice.
14// This code supersedes and replaces all information previously supplied.
15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16// components in life support devices or systems without express written approval of
17// NVIDIA CORPORATION & AFFILIATES.
18//
19// SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21//
22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23// property and proprietary rights in and to this material, related
24// documentation and any modifications thereto. Any use, reproduction,
25// disclosure or distribution of this material and related documentation
26// without an express license agreement from NVIDIA CORPORATION or
27// its affiliates is strictly prohibited.
28//
30
50#ifndef STM_H_
51#define STM_H_
52
53#if __GNUC__ >= 4
54#define STM_API __attribute__((visibility("default")))
55#endif
56
57#include <stdint.h>
58#include "stm_error.h"
59#include <cuda_runtime.h>
60#include <stdbool.h>
61#include <nvscisync.h>
62
63#ifdef VIBRANTE
64#if VIBRANTE_PDK_DECIMAL < 6000400
65#include <nvmedia_dla.h>
66#endif
67#if VIBRANTE_PDK_DECIMAL >= 6000000
68#include <cupva_host_wrapper.h>
69#if VIBRANTE_PDK_DECIMAL >= 6000400
70#include <cudla.h>
71#if VIBRANTE_PDK_DECIMAL >= 6000500
72#include <VulkanSC/vulkan/vulkan_sc.h>
73#if VIBRANTE_PDK_DECIMAL >= 6000600
74#include <nvmedia_6x/nvmedia_ldc.h>
75#include <nvmedia_6x/nvmedia_2d.h>
76#endif
77#endif
78#endif
79#endif
80#endif
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85
89typedef struct
90{
92 uint16_t scheduleId;
94
101typedef void (*stmRunnable_t)(void* userdata);
102
114typedef void (*stmCudaSubmitter_t)(void* userdata, cudaStream_t stream);
115
127STM_API stmErrorCode_t stmClientInit(const char* clientName);
128
141STM_API stmErrorCode_t stmClientInitWithDiscriminator(const char* clientName, int32_t discriminator);
142
153STM_API stmErrorCode_t stmRegisterCpuRunnable(stmRunnable_t func, const char* const runnableId, void* userdata);
154
165STM_API stmErrorCode_t stmRegisterCudaSubmitter(stmCudaSubmitter_t func, const char* const runnableId, void* userdata);
166
180STM_API stmErrorCode_t stmRegisterCudaResource(const char* resourceName, cudaStream_t stream);
181
182#ifdef VIBRANTE
183
184#if VIBRANTE_PDK_DECIMAL >= 6000500
185STM_API stmErrorCode_t stmRegisterVulkanResource(const char* resourceName, VkQueue queue, VkDevice device, VkPhysicalDevice physicalDevice, VkInstance instance);
186
187typedef void (*stmVulkanSubmitter_t)(void* userdata, VkQueue queue);
188
189STM_API stmErrorCode_t stmRegisterVulkanSubmitter(stmVulkanSubmitter_t func, const char* const runnableId, void* userdata);
190#endif
191
192#if VIBRANTE_PDK_DECIMAL < 6000400
203typedef void (*stmDlaSubmitter_t)(void* userdata, NvMediaDla* dla);
204#endif
205
206#if VIBRANTE_PDK_DECIMAL >= 6000200
218typedef void (*stmCuDlaSubmitter_t)(void* userdata, cudaStream_t cudla);
219#endif
220
221#if VIBRANTE_PDK_DECIMAL >= 6000600
236typedef void (*stmLdcSubmitter_t)(void* userdata, NvMediaLdc* ldc, NvSciSyncFence const ldcPrefenceList[], size_t ldcPrefenceCount, NvSciSyncObj ldcPostfencesyncObj, NvSciSyncFence* ldcPostfence);
237
252typedef void (*stmNv2DSubmitter_t)(void* userdata, NvMedia2D* nv2D, NvSciSyncFence const nv2DPrefenceList[], size_t nv2DPrefenceCount, NvSciSyncObj nv2DPostfencesyncObj, NvSciSyncFence* nv2DPostfence);
253#endif
254
255#if VIBRANTE_PDK_DECIMAL >= 6000400
267typedef void (*stmCuDlaStandaloneSubmitter_t)(void* userdata, cudlaDevHandle cudla);
268#endif
269
270#if VIBRANTE_PDK_DECIMAL >= 6000000
282typedef void (*stmVpuSubmitter_t)(void* userdata, cupvaStream_t vpu);
283#endif
284
285#if VIBRANTE_PDK_DECIMAL < 6000400
300STM_API stmErrorCode_t stmRegisterDlaResource(const char* resourceName, NvMediaDla* dla);
301#endif
302
303#if VIBRANTE_PDK_DECIMAL >= 6000200
320STM_API stmErrorCode_t stmRegisterCuDlaResource(const char* resourceName, cudaStream_t cudla);
321#endif
322
323#if VIBRANTE_PDK_DECIMAL >= 6000600
338STM_API stmErrorCode_t stmRegisterLdcResource(const char* resourceName, NvMediaLdc* ldc);
339
354STM_API stmErrorCode_t stmRegisterNv2DResource(const char* resourceName, NvMedia2D* nv2D);
355#endif
356
357#if VIBRANTE_PDK_DECIMAL >= 6000400
374STM_API stmErrorCode_t stmRegisterCuDlaStandaloneResource(const char* resourceName, cudlaDevHandle cudla);
375#endif
376
377#if VIBRANTE_PDK_DECIMAL >= 6000000
394STM_API stmErrorCode_t stmRegisterVpuResource(const char* resourceName, cupvaStream_t vpu);
395#endif
396
397#if VIBRANTE_PDK_DECIMAL < 6000400
409STM_API stmErrorCode_t stmRegisterDlaSubmitter(stmDlaSubmitter_t func, const char* const runnableId, void* userdata);
410#endif
411
412#if VIBRANTE_PDK_DECIMAL >= 6000200
426STM_API stmErrorCode_t stmRegisterCuDlaSubmitter(stmCuDlaSubmitter_t func, const char* const runnableId, void* userdata);
427#endif
428
429#if VIBRANTE_PDK_DECIMAL >= 6000600
441STM_API stmErrorCode_t stmRegisterLdcSubmitter(stmLdcSubmitter_t func, const char* const runnableId, void* userdata);
442
454STM_API stmErrorCode_t stmRegisterNv2DSubmitter(stmNv2DSubmitter_t func, const char* const runnableId, void* userdata);
455#endif
456
457#if VIBRANTE_PDK_DECIMAL >= 6000400
471STM_API stmErrorCode_t stmRegisterCuDlaStandaloneSubmitter(stmCuDlaStandaloneSubmitter_t func, const char* const runnableId, void* userdata);
472#endif
473
474#if VIBRANTE_PDK_DECIMAL >= 6000000
488STM_API stmErrorCode_t stmRegisterVpuSubmitter(stmVpuSubmitter_t func, const char* const runnableId, void* userdata);
489#endif
490
491#endif
492
499typedef void (*stmScheduleSwitchCallback_t)(uint16_t startScheduleId, uint16_t hyperepochId, void* userdata);
500
516
531
545
557
563STM_API void stmClientExit(void);
564
565#ifdef __cplusplus
566}
567#endif
568
569#endif
STM_API stmErrorCode_t stmEnterScheduler(void)
Yield to STM scheduler, which will schedule all registered runnables in the STM schedule periodically...
STM_API stmErrorCode_t stmRegisterVpuSubmitter(stmVpuSubmitter_t func, const char *const runnableId, void *userdata)
Registers an stmVpuSubmitter_t function with the name provided by the user to the STM compiler.
STM_API stmErrorCode_t stmRegisterCallBack(stmScheduleSwitchCallback_t func, void *userdata)
Registers a callback function with a client to be invoked during a schedule switch....
STM_API stmErrorCode_t stmClientInit(const char *clientName)
Initialize STM client context.
void(* stmVulkanSubmitter_t)(void *userdata, VkQueue queue)
Definition: stm.h:187
STM_API stmErrorCode_t stmRegisterCuDlaStandaloneResource(const char *resourceName, cudlaDevHandle cudla)
Registers a cuDLA standalone resource.
void(* stmRunnable_t)(void *userdata)
Function signature for STM CPU runnable.
Definition: stm.h:101
STM_API stmErrorCode_t stmRegisterCuDlaResource(const char *resourceName, cudaStream_t cudla)
Registers a cuDLA hybrid resource.
STM_API stmErrorCode_t stmClientInitWithDiscriminator(const char *clientName, int32_t discriminator)
Initialize STM client context with a discriminator.
uint32_t epochIterations
Definition: stm.h:91
STM_API stmErrorCode_t stmRegisterVulkanResource(const char *resourceName, VkQueue queue, VkDevice device, VkPhysicalDevice physicalDevice, VkInstance instance)
STM_API stmErrorCode_t stmRegisterVpuResource(const char *resourceName, cupvaStream_t vpu)
Registers a cuPVA resource.
STM_API stmErrorCode_t stmGetRuntimeInfo(stmRunnableInfo_t *info)
Get runtime information about execution.
STM_API stmErrorCode_t stmRegisterVulkanSubmitter(stmVulkanSubmitter_t func, const char *const runnableId, void *userdata)
void(* stmVpuSubmitter_t)(void *userdata, cupvaStream_t vpu)
Function signature for STM VPU submitter runnable.
Definition: stm.h:282
void(* stmCuDlaSubmitter_t)(void *userdata, cudaStream_t cudla)
Function signature for STM cuDLA hybrid submitter runnable.
Definition: stm.h:218
STM_API stmErrorCode_t stmRegisterCudaResource(const char *resourceName, cudaStream_t stream)
Registers a CUDA stream resource.
STM_API void stmClientExit(void)
Cleans up STM client context. No STM APIs can be called after this.
STM_API stmErrorCode_t stmRegisterCuDlaStandaloneSubmitter(stmCuDlaStandaloneSubmitter_t func, const char *const runnableId, void *userdata)
Registers an stmCudlaStandaloneSubmitter_t function with the name provided by the user to the STM com...
STM_API stmErrorCode_t stmRegisterCuDlaSubmitter(stmCuDlaSubmitter_t func, const char *const runnableId, void *userdata)
Registers an stmCudlaSubmitter_t function with the name provided by the user to the STM compiler.
uint16_t scheduleId
Definition: stm.h:92
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.
void(* stmCuDlaStandaloneSubmitter_t)(void *userdata, cudlaDevHandle cudla)
Function signature for STM cuDLA standalone submitter runnable.
Definition: stm.h:267
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.
void(* stmCudaSubmitter_t)(void *userdata, cudaStream_t stream)
Function signature for STM CUDA submitter runnable.
Definition: stm.h:114
void(* stmScheduleSwitchCallback_t)(uint16_t startScheduleId, uint16_t hyperepochId, void *userdata)
Function signature for STM schedule switch callback.
Definition: stm.h:499
STM_API stmErrorCode_t stmExitScheduler(void)
Return from stmEnterScheduler().
Information which can be queried by CPU runnables using stmGetRuntimeInfo()
Definition: stm.h:90
Return/error codes for all STM functions.
stmErrorCode_t
Return/error codes for all STM functions.
Definition: stm_error.h:47