System Task Manager SDK Reference  5.18
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#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
122STM_API void stmClientInit(const char* clientName);
123
131STM_API void stmClientInitWithDiscriminator(const char* clientName, int32_t discriminator);
132
142STM_API stmErrorCode_t stmRegisterCpuRunnable(stmRunnable_t func, const char* const runnableId, void* userdata);
143
153STM_API stmErrorCode_t stmRegisterCudaSubmitter(stmCudaSubmitter_t func, const char* const runnableId, void* userdata);
154
167STM_API stmErrorCode_t stmRegisterCudaResource(const char* resourceName, cudaStream_t stream);
168
169#ifdef VIBRANTE
170
171#if VIBRANTE_PDK_DECIMAL >= 6000500
172STM_API stmErrorCode_t stmRegisterVulkanResource(const char* resourceName, VkQueue queue, VkDevice device, VkPhysicalDevice physicalDevice, VkInstance instance);
173
174typedef void (*stmVulkanSubmitter_t)(void* userdata, VkQueue queue);
175
176STM_API stmErrorCode_t stmRegisterVulkanSubmitter(stmVulkanSubmitter_t func, const char* const runnableId, void* userdata);
177#endif
178
179#if VIBRANTE_PDK_DECIMAL < 6000400
190typedef void (*stmDlaSubmitter_t)(void* userdata, NvMediaDla* dla);
191#endif
192
193#if VIBRANTE_PDK_DECIMAL >= 6000200
205typedef void (*stmCuDlaSubmitter_t)(void* userdata, cudaStream_t cudla);
206#endif
207
208#if VIBRANTE_PDK_DECIMAL >= 6000600
223typedef void (*stmLdcSubmitter_t)(void* userdata, NvMediaLdc* ldc, NvSciSyncFence ldcPrefenceList[], size_t ldcPrefenceCount, NvSciSyncObj ldcPostfencesyncObj, NvSciSyncFence* ldcPostfence);
224
239typedef void (*stmNv2DSubmitter_t)(void* userdata, NvMedia2D* nv2D, NvSciSyncFence nv2DPrefenceList[], size_t nv2DPrefenceCount, NvSciSyncObj nv2DPostfencesyncObj, NvSciSyncFence* nv2DPostfence);
240#endif
241
242#if VIBRANTE_PDK_DECIMAL >= 6000400
254typedef void (*stmCuDlaStandaloneSubmitter_t)(void* userdata, cudlaDevHandle cudla);
255#endif
256
257#if VIBRANTE_PDK_DECIMAL >= 6000000
269typedef void (*stmVpuSubmitter_t)(void* userdata, cupvaStream_t vpu);
270#endif
271
272#if VIBRANTE_PDK_DECIMAL < 6000400
286STM_API stmErrorCode_t stmRegisterDlaResource(const char* resourceName, NvMediaDla* dla);
287#endif
288
289#if VIBRANTE_PDK_DECIMAL >= 6000200
305STM_API stmErrorCode_t stmRegisterCuDlaResource(const char* resourceName, cudaStream_t cudla);
306#endif
307
308#if VIBRANTE_PDK_DECIMAL >= 6000600
322STM_API stmErrorCode_t stmRegisterLdcResource(const char* resourceName, NvMediaLdc* ldc);
323
337STM_API stmErrorCode_t stmRegisterNv2DResource(const char* resourceName, NvMedia2D* nv2D);
338#endif
339
340#if VIBRANTE_PDK_DECIMAL >= 6000400
356STM_API stmErrorCode_t stmRegisterCuDlaStandaloneResource(const char* resourceName, cudlaDevHandle cudla);
357#endif
358
359#if VIBRANTE_PDK_DECIMAL >= 6000000
375STM_API stmErrorCode_t stmRegisterVpuResource(const char* resourceName, cupvaStream_t vpu);
376#endif
377
378#if VIBRANTE_PDK_DECIMAL < 6000400
389STM_API stmErrorCode_t stmRegisterDlaSubmitter(stmDlaSubmitter_t func, const char* const runnableId, void* userdata);
390#endif
391
392#if VIBRANTE_PDK_DECIMAL >= 6000200
405STM_API stmErrorCode_t stmRegisterCuDlaSubmitter(stmCuDlaSubmitter_t func, const char* const runnableId, void* userdata);
406#endif
407
408#if VIBRANTE_PDK_DECIMAL >= 6000600
419STM_API stmErrorCode_t stmRegisterLdcSubmitter(stmLdcSubmitter_t func, const char* const runnableId, void* userdata);
420
431STM_API stmErrorCode_t stmRegisterNv2DSubmitter(stmNv2DSubmitter_t func, const char* const runnableId, void* userdata);
432#endif
433
434#if VIBRANTE_PDK_DECIMAL >= 6000400
447STM_API stmErrorCode_t stmRegisterCuDlaStandaloneSubmitter(stmCuDlaStandaloneSubmitter_t func, const char* const runnableId, void* userdata);
448#endif
449
450#if VIBRANTE_PDK_DECIMAL >= 6000000
463STM_API stmErrorCode_t stmRegisterVpuSubmitter(stmVpuSubmitter_t func, const char* const runnableId, void* userdata);
464#endif
465
466#endif
467
474typedef void (*stmScheduleSwitchCallback_t)(uint16_t startScheduleId, uint16_t hyperepochId, void* userdata);
475
490
505
519
531
537STM_API void stmClientExit(void);
538
539#ifdef __cplusplus
540}
541#endif
542
543#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:174
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.
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:269
void(* stmCuDlaSubmitter_t)(void *userdata, cudaStream_t cudla)
Function signature for STM cuDLA hybrid submitter runnable.
Definition: stm.h:205
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 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.
void(* stmCuDlaStandaloneSubmitter_t)(void *userdata, cudlaDevHandle cudla)
Function signature for STM cuDLA standalone submitter runnable.
Definition: stm.h:254
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:474
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