NVIDIA DriveOS Linux NSR SDK API Reference

7.0.3.0 Release
Context.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2016-2025 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>
47 #include <dw/core/health/HealthSignals.h>
48 #include <dw/core/platform/GPUProperties.h>
49 
50 #include <cuda_runtime_api.h>
51 #include <cuda_runtime.h>
52 #include <nvscibuf.h>
53 #include <nvscisync.h>
54 
55 // type definitions for CUDA structs
57 
58 // Forward declares from EGL
59 typedef void* EGLDisplay;
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
73 typedef struct dwContextObject* dwContextHandle_t;
76 typedef struct dwContextObject const* dwConstContextHandle_t;
77 
79 typedef struct dwModuleObject* dwModuleHandle_t;
80 typedef struct dwModuleObject const* dwConstModuleHandle_t;
81 
85 typedef struct dwContextParameters
86 {
87 
88 #ifdef DW_USE_EGL
89  EGLDisplay eglDisplay;
91 
96  bool skipEglInit;
97 #endif
98 
104 
110 
117  bool enablePVA;
118 
123 
130 
133 
135 typedef void* dwDLAHandleArray;
136 
141 {
145 
151  size_t (*write)(dwCustomizedFileHandle hnd, const void* ptr, size_t size);
152 
157  size_t (*read)(dwCustomizedFileHandle hnd, void* ptr, size_t size);
158 
163  bool (*getString)(dwCustomizedFileHandle hnd, char8_t* ptr, size_t size);
164 
168  size_t (*size)(dwCustomizedFileHandle hnd);
169 
174 
179 
184 
189 
193 
198  dwCustomizedFileHandle (*open)(const char8_t* ptr1, const char8_t* ptr2);
199 
201 
205 typedef enum {
208 
211 
214 
217 } dwPTPStatus;
218 
235 
257 dwStatus dwGetLastError(char8_t const** const errorMsg);
258 
279 dwStatus dwGetLastCudaError(cudaError_t* const cudaError, char8_t const** const errorMsg);
280 
313 dwStatus dwInitialize(dwContextHandle_t* const context, dwVersion const headerVersion, dwContextParameters const* const params);
314 
332 dwStatus dwRelease(dwContextHandle_t const context);
333 
352 dwStatus dwContext_getCurrentTime(dwTime_t* const time, dwContextHandle_t const context);
353 
370 
386 
404 
430 dwStatus dwContext_isTimePTPSynchronized(bool* const flag, dwContextHandle_t const context); // clang-tidy NOLINT(readability-non-const-parameter);
431 
448 dwStatus dwContext_getTimePTPSynchronizationStatus(dwPTPStatus* const status, dwContextHandle_t const context); // clang-tidy NOLINT(readability-non-const-parameter);
449 
464 dwStatus dwContext_sleepMonotonic(dwTime_t const sleepTimeUs);
465 
483 dwStatus dwContext_selectGPUDevice(int32_t const deviceNumber, dwContextHandle_t const context);
484 
499 dwStatus dwContext_getGPUDeviceCurrent(int32_t* const deviceNumber, dwContextHandle_t const context);
500 
515 dwStatus dwContext_getGPUCount(int32_t* const count, dwContextHandle_t const context);
516 
535 dwStatus dwContext_getGPUProperties(dwGPUDeviceProperties* const properties, int32_t const deviceNum,
536  dwContextHandle_t const context);
537 
558 dwStatus dwContext_getGPUAttribute(int32_t* const value, cudaDeviceAttr const attribute, int32_t const deviceNum,
559  dwContextHandle_t const context);
560 
575 dwStatus dwContext_getGPUArchitecture(char8_t const** const architecture, dwContextHandle_t const context);
576 
593 dwStatus dwContext_getCUDAProperties(int32_t* const driverVersion, int32_t* const apiVersion, dwContextHandle_t const context);
594 
610 dwStatus dwContext_getCUDAStream(cudaStream_t* stream, uint32_t streamIndex, dwContextHandle_t const context);
611 
628 dwStatus dwContext_getGPUDeviceType(dwGPUDeviceType* const deviceType, int32_t const deviceNum, dwContextHandle_t const context);
629 
630 #ifdef DW_USE_EGL
631 
646 DW_DEPRECATED("Display and EGL related context is moved to src/dwvisualization, please replace this call with dwVisualization_setEGLDisplay.")
647 dwStatus dwContext_setEGLDisplay(EGLDisplay display, dwContextHandle_t context);
648 
663 DW_DEPRECATED("Display and EGL related context is moved to src/dwvisualization, please replace this call with dwVisualization_getEGLDisplay.")
664 dwStatus dwContext_getEGLDisplay(EGLDisplay* display, dwContextHandle_t context);
665 #endif
666 
681 dwStatus dwContext_getDLAEngineCount(int32_t* const count, dwContextHandle_t const context);
682 
709 dwStatus dwContext_setupCUDLA(uint16_t const* handleCountArray, uint16_t const handleCountArraySize, dwContextHandle_t const context);
710 
729 dwStatus dwContext_getCUDLADeviceHandleArray(dwDLAHandleArray* const cudlaDeviceHandleArray, uint16_t* const cudlaDeviceHandleCount, uint16_t const engineId, dwContextHandle_t const context);
730 
747 dwStatus dwContext_getDataPath(char8_t const** const dataPath, dwContextHandle_t const context);
748 
763 dwStatus dwContext_getUseVirtualTime(bool* const useVirtualTime, dwContextHandle_t const ctx);
764 
782  dwContextHandle_t const context);
783 
801  dwContextHandle_t const context);
802 
819 
820 #ifdef __cplusplus
821 }
822 #endif
823 
824 #endif // DW_CORE_CONTEXT_H_
dwGPUDeviceProperties
GPU device properties.
Definition: GPUProperties.h:22
dwTimeSourceHandle_t
struct dwTimeSourceObject * dwTimeSourceHandle_t
Handle represents a TimeSource object.
Definition: Timer.h:40
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:157
dwCustomizedFileFunctions::error
bool(* error)(dwCustomizedFileHandle hnd)
Function pointer: Check if any I/O error occurred during OPEN/RD/WR operations.
Definition: Context.h:188
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:216
dwContextParameters::enablePVA
bool enablePVA
if true, PVA platform will be enabled.
Definition: Context.h:117
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:183
DW_PTP_STATUS_NO_INIT_SYNC
@ DW_PTP_STATUS_NO_INIT_SYNC
PTP synchronization is not started.
Definition: Context.h:207
dwContext_getNvSciBufModule
DW_API_PUBLIC dwStatus dwContext_getNvSciBufModule(NvSciBufModule *mod, dwContextHandle_t const context)
Get the nvscibuf module.
DW_PTP_STATUS_LOST_SYNC
@ DW_PTP_STATUS_LOST_SYNC
PTP synchronization lost.
Definition: Context.h:213
dwRelease
DW_API_PUBLIC dwStatus dwRelease(dwContextHandle_t const context)
Releases the context.
dwConstModuleHandle_t
struct dwModuleObject const * dwConstModuleHandle_t
Definition: Context.h:80
ctx
DW_API_PUBLIC dwPointCloudRangeImageCreatorParams const *const const dwContextHandle_t ctx
Definition: PointCloudRangeImageCreator.h:293
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:108
dwContext_getGPUDeviceCurrent
DW_API_PUBLIC dwStatus dwContext_getGPUDeviceCurrent(int32_t *const deviceNumber, dwContextHandle_t const context)
Returns the currently selected GPU device.
cudaDeviceAttr
enum cudaDeviceAttr cudaDeviceAttr
Definition: Context.h:56
dwPTPStatus
dwPTPStatus
Defines PTP synchronization status.
Definition: Context.h:205
dwCustomizedFileFunctions::size
size_t(* size)(dwCustomizedFileHandle hnd)
Function pointer: Returns the total number of bytes in the file stream.
Definition: Context.h:168
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.
handle
const WFDCommitType const WFDHandle handle
Definition: wfdext.h:124
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:79
dwVersion
Definition: Version_1.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
Specifies a timestamp unit, in microseconds.
Definition: BasicTypes.h:54
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:58
dwContext_getCurrentTimeUTC
DW_API_PUBLIC dwStatus dwContext_getCurrentTimeUTC(dwTime_t *const time, dwContextHandle_t const context)
Returns the current UTC timestamp.
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:140
dwContextParameters::useVirtualTime
bool useVirtualTime
if true, the context's time source will be a virtual clock.
Definition: Context.h:128
char8_t
char char8_t
Definition: BasicTypes.h:47
dwContextParameters
struct dwContextParameters dwContextParameters
A set of parameters that is passed to the SDK to create the context.
dwContext_setupCUDLA
DW_API_PUBLIC dwStatus dwContext_setupCUDLA(uint16_t const *handleCountArray, uint16_t const handleCountArraySize, dwContextHandle_t const context)
Setup CUDLA, create CUDLA Engine handles per request.
dwContextParameters::enableCudaTaskGraph
bool enableCudaTaskGraph
if true, Cuda task-graph will be used where possible.
Definition: Context.h:122
dwCustomizedFileFunctions::getString
bool(* getString)(dwCustomizedFileHandle hnd, char8_t *ptr, size_t size)
Function pointer: Read a string from the file stream.
Definition: Context.h:163
dwInitialize
DW_API_PUBLIC dwStatus dwInitialize(dwContextHandle_t *const context, dwVersion const headerVersion, dwContextParameters const *const params)
Creates and initializes an SDK context.
DW_DEPRECATED
#define DW_DEPRECATED(msg)
Definition: Exports.h:50
dwCustomizedFileFunctions::close
void(* close)(dwCustomizedFileHandle hnd)
Function pointer: Close the file stream.
Definition: Context.h:144
dwCustomizedFileHandle
void * dwCustomizedFileHandle
FileStream function pointers handle.
Definition: Context.h:132
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:198
NvSciBufModule
struct NvSciBufModuleRec * NvSciBufModule
top-level container for the following set of resources: NvSciBufAttrLists, memory objects,...
Definition: nvscibuf.h:3484
void
typedef void(WFD_APIENTRY PFNWFDBINDSOURCETOPIPELINEWITHTIMESTAMPNV)(const WFDDevice device
dwContext_getErrorSignal
DW_API_PUBLIC dwStatus dwContext_getErrorSignal(dwErrorSignal *errorSignal, dwModuleHandle_t handle)
Get the module error signal.
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.
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:74
dwGetLastCudaError
DW_API_PUBLIC dwStatus dwGetLastCudaError(cudaError_t *const cudaError, char8_t const **const errorMsg)
Retrieves the last CUDA error encountered.
nvscibuf.h
NVIDIA Software Communications Interface (SCI) : NvSciBuf
dwContextParameters::skipCudaInit
bool skipCudaInit
if true will skip CUDA initialization in the context
Definition: Context.h:109
dwCustomizedFileFunctions::setPosition
void(* setPosition)(dwCustomizedFileHandle hnd, size_t size)
Function pointer: Set the desired position inside the file stream.
Definition: Context.h:178
dwConstContextHandle_t
struct dwContextObject const * dwConstContextHandle_t
The Driveworks context handle.
Definition: Context.h:76
dwContext_getDLAEngineCount
DW_API_PUBLIC dwStatus dwContext_getDLAEngineCount(int32_t *const count, dwContextHandle_t const context)
Get the available DLA engines count.
EGLDisplay
void * EGLDisplay
Definition: Context.h:59
dwStatus
dwStatus
Status definition.
Definition: ErrorDefs.h:27
dwContextParameters
A set of parameters that is passed to the SDK to create the context.
Definition: Context.h:85
dwCustomizedFileFunctions::getPosition
size_t(* getPosition)(dwCustomizedFileHandle hnd)
Function pointer: Returns the current position inside the file stream.
Definition: Context.h:173
dwContext_getTimeSource
DW_API_PUBLIC dwStatus dwContext_getTimeSource(dwTimeSourceHandle_t *const source, dwContextHandle_t const context)
Retrieve time source used in the context.
dwDLAHandleArray
void * dwDLAHandleArray
cuDLA Device handle array pointer
Definition: Context.h:135
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:151
dwCustomizedFileFunctions::flush
void(* flush)(dwCustomizedFileHandle hnd)
Function pointer: Synchronizes the file stream, waiting that all requested bytes have been read.
Definition: Context.h:192
NvSciSyncModule
struct NvSciSyncModuleRec * NvSciSyncModule
Represents an instance of the NvSciSyncModule.
Definition: nvscisync.h:211
params
DW_API_PUBLIC dwPointCloudRangeImageCreatorParams const *const params
Definition: PointCloudRangeImageCreator.h:292
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: Exports.h:38
dwContext_sleepMonotonic
DW_API_PUBLIC dwStatus dwContext_sleepMonotonic(dwTime_t const sleepTimeUs)
Sleep for a given time using a monotonic clock.
dwContext_getCUDAStream
DW_API_PUBLIC dwStatus dwContext_getCUDAStream(cudaStream_t *stream, uint32_t streamIndex, dwContextHandle_t const context)
Returns a preallocated CUDA stream.
DW_PTP_STATUS_NO_ERROR
@ DW_PTP_STATUS_NO_ERROR
No error.
Definition: Context.h:210
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_getNvSciSyncModule
DW_API_PUBLIC dwStatus dwContext_getNvSciSyncModule(NvSciSyncModule *mod, dwContextHandle_t const context)
Get the NvSciSync module.
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:103
dwErrorSignal
Basic error signal that gets reported only when there is an error.
Definition: HealthSignals.h:58