System Task Manager SDK Reference  5.12
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-2023 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
62#ifdef VIBRANTE
63#if VIBRANTE_PDK_DECIMAL < 6000400
64#include <nvmedia_dla.h>
65#endif
66#if VIBRANTE_PDK_DECIMAL >= 6000000
67#include <cupva_host_wrapper.h>
68#if VIBRANTE_PDK_DECIMAL >= 6000500
69#include <VulkanSC/vulkan/vulkan_sc.h>
70#endif
71#endif
72#endif
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
81typedef struct
82{
84 uint16_t scheduleId;
86
93typedef void (*stmRunnable_t)(void* userdata);
94
106typedef void (*stmCudaSubmitter_t)(void* userdata, cudaStream_t stream);
107
114STM_API void stmClientInit(const char* clientName);
115
123STM_API void stmClientInitWithDiscriminator(const char* clientName, int32_t discriminator);
124
134STM_API stmErrorCode_t stmRegisterCpuRunnable(stmRunnable_t func, const char* const runnableId, void* userdata);
135
145STM_API stmErrorCode_t stmRegisterCudaSubmitter(stmCudaSubmitter_t func, const char* const runnableId, void* userdata);
146
159STM_API stmErrorCode_t stmRegisterCudaResource(const char* resourceName, cudaStream_t stream);
160
161#ifdef VIBRANTE
162
163#if VIBRANTE_PDK_DECIMAL >= 6000500
164STM_API stmErrorCode_t stmRegisterVulkanResource(const char* resourceName, VkQueue queue, VkDevice device, VkPhysicalDevice physicalDevice, VkInstance instance);
165
166typedef void (*stmVulkanSubmitter_t)(void* userdata, VkQueue queue);
167
168STM_API stmErrorCode_t stmRegisterVulkanSubmitter(stmVulkanSubmitter_t func, const char* const runnableId, void* userdata);
169#endif
170
171#if VIBRANTE_PDK_DECIMAL < 6000400
182typedef void (*stmDlaSubmitter_t)(void* userdata, NvMediaDla* dla);
183#endif
184
185#if VIBRANTE_PDK_DECIMAL >= 6000200
197typedef void (*stmCuDlaSubmitter_t)(void* userdata, cudaStream_t cudla);
198#endif
199
200#if VIBRANTE_PDK_DECIMAL >= 6000000
212typedef void (*stmVpuSubmitter_t)(void* userdata, cupvaStream_t vpu);
213#endif
214
215#if VIBRANTE_PDK_DECIMAL < 6000400
229STM_API stmErrorCode_t stmRegisterDlaResource(const char* resourceName, NvMediaDla* dla);
230#endif
231
232#if VIBRANTE_PDK_DECIMAL >= 6000200
248STM_API stmErrorCode_t stmRegisterCuDlaResource(const char* resourceName, cudaStream_t cudla);
249#endif
250
251#if VIBRANTE_PDK_DECIMAL >= 6000000
267STM_API stmErrorCode_t stmRegisterVpuResource(const char* resourceName, cupvaStream_t vpu);
268#endif
269
270#if VIBRANTE_PDK_DECIMAL < 6000400
281STM_API stmErrorCode_t stmRegisterDlaSubmitter(stmDlaSubmitter_t func, const char* const runnableId, void* userdata);
282#endif
283
284#if VIBRANTE_PDK_DECIMAL >= 6000200
297STM_API stmErrorCode_t stmRegisterCuDlaSubmitter(stmCuDlaSubmitter_t func, const char* const runnableId, void* userdata);
298#endif
299
300#if VIBRANTE_PDK_DECIMAL >= 6000000
313STM_API stmErrorCode_t stmRegisterVpuSubmitter(stmVpuSubmitter_t func, const char* const runnableId, void* userdata);
314#endif
315
316#endif
317
324typedef void (*stmScheduleSwitchCallback_t)(uint16_t startScheduleId, uint16_t hyperepochId, void* userdata);
325
340
355
369
379
385STM_API void stmClientExit(void);
386
387#ifdef __cplusplus
388}
389#endif
390
391#endif
STM_API void stmClientInit(const char *clientName)
Initialize STM client context.
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....
void(* stmVulkanSubmitter_t)(void *userdata, VkQueue queue)
Definition: stm.h:166
void(* stmRunnable_t)(void *userdata)
Function signature for STM CPU runnable.
Definition: stm.h:93
STM_API stmErrorCode_t stmRegisterCuDlaResource(const char *resourceName, cudaStream_t cudla)
Registers a cuDLA resource.
uint32_t epochIterations
Definition: stm.h:83
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:212
void(* stmCuDlaSubmitter_t)(void *userdata, cudaStream_t cudla)
Function signature for STM cuDLA submitter runnable.
Definition: stm.h:197
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 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:84
STM_API void stmClientInitWithDiscriminator(const char *clientName, int32_t discriminator)
Initialize STM client context with a discriminator.
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.
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:106
void(* stmScheduleSwitchCallback_t)(uint16_t startScheduleId, uint16_t hyperepochId, void *userdata)
Function signature for STM schedule switch callback.
Definition: stm.h:324
STM_API stmErrorCode_t stmExitScheduler(void)
Return from stmEnterScheduler().
Information which can be queried by CPU runnables using stmGetRuntimeInfo()
Definition: stm.h:82
Return/error codes for all STM functions.
stmErrorCode_t
Return/error codes for all STM functions.
Definition: stm_error.h:47