NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release
Context.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
38 #ifndef DW_CORE_CONTEXT_H_
39 #define DW_CORE_CONTEXT_H_
40 
41 #include <dw/core/base/Config.h>
42 #include <dw/core/base/Exports.h>
43 #include <dw/core/base/Types.h>
44 #include <dw/core/base/Version.h>
45 #include <dw/core/base/Status.h>
46 #include <dw/core/time/Timer.h>
49 
50 #include <cuda_runtime_api.h>
51 #include <cuda_runtime.h>
52 #include <nvscibuf.h>
53 #include <nvscisync.h>
54 
59 // type definitions for CUDA structs
61 
62 #ifdef DW_USE_EGL
63 // Forward declares from EGL
64 typedef void* EGLDisplay;
65 #endif
66 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
80 typedef struct dwContextObject* dwContextHandle_t;
83 // coverity[misra_c_2012_rule_2_3_violation] Deviation Record: AV-NDAS-SWSADR-005
84 typedef struct dwContextObject const* dwConstContextHandle_t;
85 
87 typedef struct dwModuleObject* dwModuleHandle_t;
88 // coverity[misra_c_2012_rule_2_3_violation] Deviation Record: AV-NDAS-SWSADR-005
89 typedef struct dwModuleObject const* dwConstModuleHandle_t;
90 
94 // coverity[misra_c_2012_rule_2_4_violation] Deviation Record: AV-NDAS-SWSADR-003
95 typedef struct dwContextParameters
96 {
97 
98 #ifdef DW_USE_EGL
99  EGLDisplay eglDisplay;
101 
106  bool skipEglInit;
107 #endif
108 
114 
120 
127  bool enablePVA;
128 
133 
139 
146 
154 
157 
159 typedef void* dwDLAHandleArray;
160 
164 // coverity[misra_c_2012_rule_2_4_violation] Deviation Record: AV-NDAS-SWSADR-003
166 {
170 
176  size_t (*write)(dwCustomizedFileHandle hnd, const void* ptr, size_t size);
177 
182  size_t (*read)(dwCustomizedFileHandle hnd, void* ptr, size_t size);
183 
188  bool (*getString)(dwCustomizedFileHandle hnd, char8_t* ptr, size_t size);
189 
193  size_t (*size)(dwCustomizedFileHandle hnd);
194 
199 
204 
209 
214 
218 
223  dwCustomizedFileHandle (*open)(const char8_t* ptr1, const char8_t* ptr2);
224 
226 
230 typedef enum {
233 
236 
239 
242 
245 } dwPTPStatus;
246 
263 
285 dwStatus dwGetLastError(char8_t const** const errorMsg);
286 
307 dwStatus dwGetLastCudaError(cudaError_t* const cudaError, char8_t const** const errorMsg);
308 
341 dwStatus dwInitialize(dwContextHandle_t* const context, dwVersion const headerVersion, dwContextParameters const* const params);
342 
360 dwStatus dwRelease(dwContextHandle_t const context);
361 
380 dwStatus dwContext_getCurrentTime(dwTime_t* const time, dwContextHandle_t const context);
381 
398 
414 
432 
458 dwStatus dwContext_isTimePTPSynchronized(bool* const flag, dwContextHandle_t const context); // clang-tidy NOLINT(readability-non-const-parameter);
459 
476 dwStatus dwContext_getTimePTPSynchronizationStatus(dwPTPStatus* const status, dwContextHandle_t const context); // clang-tidy NOLINT(readability-non-const-parameter);
477 
492 dwStatus dwContext_sleepMonotonic(dwTime_t const sleepTimeUs);
493 
511 dwStatus dwContext_selectGPUDevice(int32_t const deviceNumber, dwContextHandle_t const context);
512 
527 dwStatus dwContext_getGPUDeviceCurrent(int32_t* const deviceNumber, dwContextHandle_t const context);
528 
543 dwStatus dwContext_getGPUCount(int32_t* const count, dwContextHandle_t const context);
544 
563 dwStatus dwContext_getGPUProperties(dwGPUDeviceProperties* const properties, int32_t const deviceNum,
564  dwContextHandle_t const context);
565 
586 dwStatus dwContext_getGPUAttribute(int32_t* const value, cudaDeviceAttr const attribute, int32_t const deviceNum,
587  dwContextHandle_t const context);
588 
603 dwStatus dwContext_getGPUArchitecture(char8_t const** const architecture, dwContextHandle_t const context);
604 
621 dwStatus dwContext_getCUDAProperties(int32_t* const driverVersion, int32_t* const apiVersion, dwContextHandle_t const context);
622 
638 dwStatus dwContext_getCUDAStream(cudaStream_t* stream, uint32_t const streamIndex, dwContextHandle_t const context);
639 
656 dwStatus dwContext_getGPUDeviceType(dwGPUDeviceType* const deviceType, int32_t const deviceNum, dwContextHandle_t const context);
657 
672 dwStatus dwContext_getDLAEngineCount(int32_t* const count, dwContextHandle_t const context);
673 
700 dwStatus dwContext_setupCUDLA(uint16_t const* const handleCountArray, uint16_t const handleCountArraySize, dwContextHandle_t const context);
701 
720 dwStatus dwContext_getCUDLADeviceHandleArray(dwDLAHandleArray* const cudlaDeviceHandleArray, uint16_t* const cudlaDeviceHandleCount, uint16_t const engineId, dwContextHandle_t const context);
721 
738 dwStatus dwContext_getDataPath(char8_t const** const dataPath, dwContextHandle_t const context);
739 
754 dwStatus dwContext_getUseVirtualTime(bool* const useVirtualTime, dwContextHandle_t const ctx);
755 
773  dwContextHandle_t const context);
774 
792  dwContextHandle_t const context);
793 
810 
811 #ifdef __cplusplus
812 }
813 #endif
814 
815 #endif // DW_CORE_CONTEXT_H_
dwGPUDeviceProperties
GPU device properties.
Definition: GPUProperties.h:23
dwCustomizedFileFunctions::read
size_t(* read)(dwCustomizedFileHandle hnd, void *ptr, size_t size)
Function pointer: Read raw data from the file stream and return the number of bytes read.
Definition: Context.h:182
dwCustomizedFileFunctions::error
bool(* error)(dwCustomizedFileHandle hnd)
Function pointer: Check if any I/O error occurred during OPEN/RD/WR operations.
Definition: Context.h:213
dwContext_getGPUProperties
DW_API_PUBLIC dwStatus dwContext_getGPUProperties(dwGPUDeviceProperties *const properties, int32_t const deviceNum, dwContextHandle_t const context)
Returns the properties for the specific CUDA device.
dwContext_getGPUCount
DW_API_PUBLIC dwStatus dwContext_getGPUCount(int32_t *const count, dwContextHandle_t const context)
Get the available GPU devices count.
DW_PTP_STATUS_INTERNAL_ERROR
@ DW_PTP_STATUS_INTERNAL_ERROR
PTP internal error.
Definition: Context.h:241
dwContextParameters::enablePVA
bool enablePVA
if true, PVA platform will be enabled.
Definition: Context.h:127
dwCustomizedFileFunctions
struct dwCustomizedFileFunctions dwCustomizedFileFunctions
Data structure representing a customized FileStream that can be passed in.
dwContext_getCurrentTimeMono
DW_API_PUBLIC dwStatus dwContext_getCurrentTimeMono(dwTime_t *const time, dwContextHandle_t const context)
Returns the current monotonic timestamp.
dwCustomizedFileFunctions::eof
bool(* eof)(dwCustomizedFileHandle hnd)
Function pointer: Check if the end of file flag is set for the file stream.
Definition: Context.h:208
DW_PTP_STATUS_NO_INIT_SYNC
@ DW_PTP_STATUS_NO_INIT_SYNC
PTP synchronization is not started.
Definition: Context.h:232
DW_PTP_STATUS_LOST_SYNC
@ DW_PTP_STATUS_LOST_SYNC
PTP synchronization lost.
Definition: Context.h:238
Types.h
dwRelease
DW_API_PUBLIC dwStatus dwRelease(dwContextHandle_t const context)
Releases the context.
dwContext_getNvSciBufModule
DW_API_PUBLIC dwStatus dwContext_getNvSciBufModule(NvSciBufModule *const mod, dwContextHandle_t const context)
Get the nvscibuf module.
dwConstModuleHandle_t
struct dwModuleObject const * dwConstModuleHandle_t
Definition: Context.h:89
dwContext_getNvSciSyncModule
DW_API_PUBLIC dwStatus dwContext_getNvSciSyncModule(NvSciSyncModule *const mod, dwContextHandle_t const context)
Get the NvSciSync module.
dwContext_getCUDAProperties
DW_API_PUBLIC dwStatus dwContext_getCUDAProperties(int32_t *const driverVersion, int32_t *const apiVersion, dwContextHandle_t const context)
Returns Driver and Runtime API version of CUDA on the current machine.
dwGPUDeviceType
dwGPUDeviceType
GPU device type definitions Only applicable on Drive platforms.
Definition: TypesExtra.h:110
dwContext_getGPUDeviceCurrent
DW_API_PUBLIC dwStatus dwContext_getGPUDeviceCurrent(int32_t *const deviceNumber, dwContextHandle_t const context)
Returns the currently selected GPU device.
dwPTPStatus
dwPTPStatus
Defines PTP synchronization status.
Definition: Context.h:230
dwCustomizedFileFunctions::size
size_t(* size)(dwCustomizedFileHandle hnd)
Function pointer: Returns the total number of bytes in the file stream.
Definition: Context.h:193
Exports.h
nvscisync.h
NVIDIA Software Communications Interface (SCI) : NvSciSync
dwContext_getDataPath
DW_API_PUBLIC dwStatus dwContext_getDataPath(char8_t const **const dataPath, dwContextHandle_t const context)
Gets the initial data path of the library that contains the driveworks context.
dwContext_getUseVirtualTime
DW_API_PUBLIC dwStatus dwContext_getUseVirtualTime(bool *const useVirtualTime, dwContextHandle_t const ctx)
Check if in virtual time mode.
dwModuleHandle_t
struct dwModuleObject * dwModuleHandle_t
The Generic Module Object Handle.
Definition: Context.h:87
Version.h
dwVersion
Definition: Version.h:44
dwContext_getCurrentTime
DW_API_PUBLIC dwStatus dwContext_getCurrentTime(dwTime_t *const time, dwContextHandle_t const context)
Returns the current PTP timestamp.
dwTime_t
int64_t dwTime_t
Definition: core/base/BasicTypes.h:65
dwContext_getCUDLADeviceHandleArray
DW_API_PUBLIC dwStatus dwContext_getCUDLADeviceHandleArray(dwDLAHandleArray *const cudlaDeviceHandleArray, uint16_t *const cudlaDeviceHandleCount, uint16_t const engineId, dwContextHandle_t const context)
Get the CUDLA Engine handles.
source
const WFDPipeline const WFDSource source
Definition: wfdext.h:111
HealthSignals.h
dwContext_getCurrentTimeUTC
DW_API_PUBLIC dwStatus dwContext_getCurrentTimeUTC(dwTime_t *const time, dwContextHandle_t const context)
Returns the current UTC timestamp.
Timer.h
dwGetLastError
DW_API_PUBLIC dwStatus dwGetLastError(char8_t const **const errorMsg)
Retrieves the last error encountered.
dwCustomizedFileFunctions
Data structure representing a customized FileStream that can be passed in.
Definition: Context.h:165
dwContextParameters::useVirtualTime
bool useVirtualTime
if true, the context's time source will be a virtual clock.
Definition: Context.h:138
dwContextParameters::useVirtualTimeShmem
bool useVirtualTimeShmem
if true, the context's time source will be a virtual clock with shared memory for use across multiple...
Definition: Context.h:145
char8_t
char char8_t
Definition: core/base/BasicTypes.h:55
dwContextParameters
struct dwContextParameters dwContextParameters
A set of parameters that is passed to the SDK to create the context.
dwContextParameters::enableCudaTaskGraph
bool enableCudaTaskGraph
if true, Cuda task-graph will be used where possible.
Definition: Context.h:132
dwCustomizedFileFunctions::getString
bool(* getString)(dwCustomizedFileHandle hnd, char8_t *ptr, size_t size)
Function pointer: Read a string from the file stream.
Definition: Context.h:188
dwInitialize
DW_API_PUBLIC dwStatus dwInitialize(dwContextHandle_t *const context, dwVersion const headerVersion, dwContextParameters const *const params)
Creates and initializes an SDK context.
dwContextParameters::disablePTP
bool disablePTP
if true, PTP time synchronization will be disabled.
Definition: Context.h:152
dwStatus
dwStatus
Status definition.
Definition: ErrorDefs.h:32
dwCustomizedFileFunctions::close
void(* close)(dwCustomizedFileHandle hnd)
Function pointer: Close the file stream.
Definition: Context.h:169
dwCustomizedFileHandle
void * dwCustomizedFileHandle
FileStream function pointers handle.
Definition: Context.h:156
dwCustomizedFileFunctions::open
dwCustomizedFileHandle(* open)(const char8_t *ptr1, const char8_t *ptr2)
Function pointer: Open the file stream and returns the handle to the file.
Definition: Context.h:223
NvSciBufModule
struct NvSciBufModuleRec * NvSciBufModule
top-level container for the following set of resources: NvSciBufAttrLists, memory objects,...
Definition: nvscibuf.h:3857
void
typedef void(WFD_APIENTRY PFNWFDBINDSOURCETOPIPELINEWITHTIMESTAMPNV)(const WFDDevice device
dwContext_isTimePTPSynchronized
DW_API_PUBLIC dwStatus dwContext_isTimePTPSynchronized(bool *const flag, dwContextHandle_t const context)
Check if the used time source inside the context is synchronized over PTP.
dwContext_getTimePTPSynchronizationStatus
DW_API_PUBLIC dwStatus dwContext_getTimePTPSynchronizationStatus(dwPTPStatus *const status, dwContextHandle_t const context)
Get the PTP synchronization status of time source inside the context.
dwContext_getGPUArchitecture
DW_API_PUBLIC dwStatus dwContext_getGPUArchitecture(char8_t const **const architecture, dwContextHandle_t const context)
Returns the architecture for the currently selected CUDA device.
Config.h
dwContext_selectGPUDevice
DW_API_PUBLIC dwStatus dwContext_selectGPUDevice(int32_t const deviceNumber, dwContextHandle_t const context)
Selects a GPU device, if available.
dwContextHandle_t
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:81
dwGetLastCudaError
DW_API_PUBLIC dwStatus dwGetLastCudaError(cudaError_t *const cudaError, char8_t const **const errorMsg)
Retrieves the last CUDA error encountered.
DW_PTP_STATUS_DISABLED
@ DW_PTP_STATUS_DISABLED
PTP synchronization is disabled.
Definition: Context.h:244
dwContext_getCUDAStream
DW_API_PUBLIC dwStatus dwContext_getCUDAStream(cudaStream_t *stream, uint32_t const streamIndex, dwContextHandle_t const context)
Returns a preallocated CUDA stream.
nvscibuf.h
NVIDIA Software Communications Interface (SCI) : NvSciBuf
dwContextParameters::skipCudaInit
bool skipCudaInit
if true will skip CUDA initialization in the context
Definition: Context.h:119
dwCustomizedFileFunctions::setPosition
void(* setPosition)(dwCustomizedFileHandle hnd, size_t size)
Function pointer: Set the desired position inside the file stream.
Definition: Context.h:203
dwConstContextHandle_t
struct dwContextObject const * dwConstContextHandle_t
The Driveworks context handle.
Definition: Context.h:84
dwContext_getDLAEngineCount
DW_API_PUBLIC dwStatus dwContext_getDLAEngineCount(int32_t *const count, dwContextHandle_t const context)
Get the available DLA engines count.
handle
const WFDCommitType const WFDHandle handle
Definition: wfdext.h:532
dwContextParameters
A set of parameters that is passed to the SDK to create the context.
Definition: Context.h:95
dwCustomizedFileFunctions::getPosition
size_t(* getPosition)(dwCustomizedFileHandle hnd)
Function pointer: Returns the current position inside the file stream.
Definition: Context.h:198
dwContext_getTimeSource
DW_API_PUBLIC dwStatus dwContext_getTimeSource(dwTimeSourceHandle_t *const source, dwContextHandle_t const context)
Retrieve time source used in the context.
Status.h
dwDLAHandleArray
void * dwDLAHandleArray
cuDLA Device handle array pointer
Definition: Context.h:159
dwCustomizedFileFunctions::write
size_t(* write)(dwCustomizedFileHandle hnd, const void *ptr, size_t size)
Function pointer: Write raw data to the file stream from an input buffer and return the number of byt...
Definition: Context.h:176
dwCustomizedFileFunctions::flush
void(* flush)(dwCustomizedFileHandle hnd)
Function pointer: Synchronizes the file stream, waiting that all requested bytes have been read.
Definition: Context.h:217
dwContext_setupCUDLA
DW_API_PUBLIC dwStatus dwContext_setupCUDLA(uint16_t const *const handleCountArray, uint16_t const handleCountArraySize, dwContextHandle_t const context)
Setup CUDLA, create CUDLA Engine handles per request.
NvSciSyncModule
struct NvSciSyncModuleRec * NvSciSyncModule
Represents an instance of the NvSciSyncModule.
Definition: nvscisync.h:209
EGLDisplay
void * EGLDisplay
Definition: EGL.h:40
dwContext_getGPUAttribute
DW_API_PUBLIC dwStatus dwContext_getGPUAttribute(int32_t *const value, cudaDeviceAttr const attribute, int32_t const deviceNum, dwContextHandle_t const context)
Returns the value of the selected CUDA attribute for the specific CUDA device.
DW_API_PUBLIC
#define DW_API_PUBLIC
Definition: core/base/Exports.h:57
dwContext_sleepMonotonic
DW_API_PUBLIC dwStatus dwContext_sleepMonotonic(dwTime_t const sleepTimeUs)
Sleep for a given time using a monotonic clock.
dwTimeSourceHandle_t
struct dwTimeSourceObject * dwTimeSourceHandle_t
Handle represents a TimeSource object.
Definition: Timer.h:42
cudaDeviceAttr
enum cudaDeviceAttr cudaDeviceAttr
Definition: Context.h:60
GPUProperties.h
DW_PTP_STATUS_NO_ERROR
@ DW_PTP_STATUS_NO_ERROR
No error.
Definition: Context.h:235
dwContext_getErrorSignal
DW_API_PUBLIC dwStatus dwContext_getErrorSignal(dwErrorSignal *errorSignal, dwModuleHandle_t const handle)
Get the module error signal.
dwContext_getGPUDeviceType
DW_API_PUBLIC dwStatus dwContext_getGPUDeviceType(dwGPUDeviceType *const deviceType, int32_t const deviceNum, dwContextHandle_t const context)
Returns the device type of the input GPU number.
dwContext_setCustomFileFunctions
DW_API_PUBLIC dwStatus dwContext_setCustomFileFunctions(dwContextHandle_t const context, dwCustomizedFileFunctions *const fileFunctionPtr)
Set the customized fileStream function pointers in context.
dwContextParameters::dataPath
const char8_t * dataPath
Path where all DriveWorks related data required during runtime are stored.
Definition: Context.h:113
dwErrorSignal
Basic error signal that gets reported only when there is an error.
Definition: HealthSignals.h:61