DriveWorks SDK Reference
5.16.65 Release
For Test and Development only

Context.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) 2016-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
48#ifndef DW_CORE_CONTEXT_H_
49#define DW_CORE_CONTEXT_H_
50
51#include <dw/core/base/Config.h>
53#include <dw/core/base/Types.h>
55#include <dw/core/base/Status.h>
56#include <dw/core/time/Timer.h>
58
59#include <cuda_runtime_api.h>
60#include <cuda_runtime.h>
61#include <nvscibuf.h>
62#include <nvscisync.h>
63
64// type definitions for CUDA structs
68
69// Forward declares from EGL
70typedef void* EGLDisplay;
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
85// coverity[misra_c_2012_rule_1_1_violation]
86typedef struct dwContextObject* dwContextHandle_t;
88typedef struct dwContextObject const* dwConstContextHandle_t;
89
91typedef struct dwModuleObject* dwModuleHandle_t;
92typedef struct dwModuleObject const* dwConstModuleHandle_t;
93
97typedef struct dwContextParameters
98{
99
100#ifdef DW_USE_EGL
102 EGLDisplay eglDisplay;
103
108 bool skipEglInit;
109#endif
110
115 const char8_t* dataPath;
116
122
130
135
142
145
150{
154
160 size_t (*write)(dwCustomizedFileHandle hnd, const void* ptr, size_t size);
161
166 size_t (*read)(dwCustomizedFileHandle hnd, void* ptr, size_t size);
167
172 bool (*getString)(dwCustomizedFileHandle hnd, char8_t* ptr, size_t size);
173
178
183
188
193
198
202
207 dwCustomizedFileHandle (*open)(const char8_t* ptr1, const char8_t* ptr2);
208
210
214typedef enum {
217
220
223
227
241
257dwStatus dwGetLastError(char8_t const** const errorMsg);
258
287dwStatus dwInitialize(dwContextHandle_t* const context, dwVersion const headerVersion, dwContextParameters const* const params);
288
303
321
336
359dwStatus dwContext_isTimePTPSynchronized(bool* const flag, dwContextHandle_t const context); // clang-tidy NOLINT(readability-non-const-parameter);
360
374dwStatus dwContext_getTimePTPSynchronizationStatus(dwPTPStatus* const status, dwContextHandle_t const context); // clang-tidy NOLINT(readability-non-const-parameter);
375
385
400dwStatus dwContext_selectGPUDevice(int32_t const deviceNumber, dwContextHandle_t const context);
401
413dwStatus dwContext_getGPUDeviceCurrent(int32_t* const deviceNumber, dwContextHandle_t const context);
414
426dwStatus dwContext_getGPUCount(int32_t* const count, dwContextHandle_t const context);
427
443dwStatus dwContext_getGPUProperties(dwGPUDeviceProperties* const properties, int32_t const deviceNum,
444 dwContextHandle_t const context);
445
463dwStatus dwContext_getGPUAttribute(int32_t* const value, cudaDeviceAttr const attribute, int32_t const deviceNum,
464 dwContextHandle_t const context);
465
477dwStatus dwContext_getGPUArchitecture(char8_t const** const architecture, dwContextHandle_t const context);
478
492dwStatus dwContext_getCUDAProperties(int32_t* const driverVersion, int32_t* const apiVersion, dwContextHandle_t const context);
493
507dwStatus dwContext_getGPUDeviceType(dwGPUDeviceType* const deviceType, int32_t const deviceNum, dwContextHandle_t const context);
508
509#ifdef DW_USE_EGL
525dwStatus dwContext_setEGLDisplay(EGLDisplay display, dwContextHandle_t context);
526
541dwStatus dwContext_getEGLDisplay(EGLDisplay* display, dwContextHandle_t context);
542#endif
543
555dwStatus dwContext_getDLAEngineCount(int32_t* const count, dwContextHandle_t const context);
556
570dwStatus dwContext_getDataPath(char8_t const** const dataPath, dwContextHandle_t const context);
571
583dwStatus dwContext_getUseVirtualTime(bool* const useVirtualTime, dwContextHandle_t const ctx);
584
598 dwContextHandle_t const context);
599
613 dwContextHandle_t const context);
614
615#ifdef __cplusplus
616}
617#endif
619#endif // DW_CORE_CONTEXT_H_
struct cudaDeviceProp cudaDeviceProp
Definition: Context.h:65
enum cudaDeviceAttr cudaDeviceAttr
Definition: Context.h:66
void * EGLDisplay
Definition: Context.h:70
enum cudaTextureAddressMode cudaTextureAddressMode
Definition: Context.h:67
dwStatus
Status definition.
Definition: ErrorDefs.h:44
GPU device properties.
Definition: GPUProperties.h:41
NVIDIA DriveWorks API: Core Status Methods
NVIDIA DriveWorks API: Timer
NVIDIA DriveWorks API: Core Types
NVIDIA DriveWorks API: Core Version Information
NVIDIA DriveWorks API: Core Exports
int64_t dwTime_t
Specifies a timestamp unit, in microseconds.
Definition: BasicTypes.h:65
const char8_t * dataPath
Path where all DriveWorks related data required during runtime are stored.
Definition: Context.h:115
bool enablePVA
if true, PVA platform will be enabled.
Definition: Context.h:129
bool skipCudaInit
if true will skip CUDA initialization in the context
Definition: Context.h:121
bool enableCudaTaskGraph
if true, Cuda task-graph will be used where possible.
Definition: Context.h:134
bool useVirtualTime
if true, the context's time source will be a virtual clock.
Definition: Context.h:140
DW_API_PUBLIC dwStatus dwInitialize(dwContextHandle_t *const context, dwVersion const headerVersion, dwContextParameters const *const params)
Creates and initializes an SDK context.
DW_API_PUBLIC dwStatus dwRelease(dwContextHandle_t const context)
Releases the context.
DW_API_PUBLIC dwStatus dwContext_getUseVirtualTime(bool *const useVirtualTime, dwContextHandle_t const ctx)
Check if in virtual time mode.
DW_API_PUBLIC dwStatus dwContext_getGPUDeviceCurrent(int32_t *const deviceNumber, dwContextHandle_t const context)
Returns the currently selected GPU device.
struct dwModuleObject * dwModuleHandle_t
The Generic Module Object Handle.
Definition: Context.h:91
DW_API_PUBLIC dwStatus dwContext_setCustomFileFunctions(dwContextHandle_t const context, dwCustomizedFileFunctions *const fileFunctionPtr)
Set the customized fileStream function pointers in context.
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.
DW_API_PUBLIC dwStatus dwContext_getGPUCount(int32_t *const count, dwContextHandle_t const context)
Get the available GPU devices count.
struct dwContextObject const * dwConstContextHandle_t
The Driveworks context handle.
Definition: Context.h:88
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.
DW_API_PUBLIC dwStatus dwContext_getDLAEngineCount(int32_t *const count, dwContextHandle_t const context)
Get the available DLA engines count.
DW_API_PUBLIC dwStatus dwContext_getNvSciSyncModule(NvSciSyncModule *mod, dwContextHandle_t const context)
Get the NvSciSync module.
struct dwModuleObject const * dwConstModuleHandle_t
Definition: Context.h:92
dwPTPStatus
Defines PTP synchronization status.
Definition: Context.h:214
DW_API_PUBLIC dwStatus dwContext_getGPUArchitecture(char8_t const **const architecture, dwContextHandle_t const context)
Returns the architecture for the currently selected CUDA device.
DW_API_PUBLIC dwStatus dwContext_getNvSciBufModule(NvSciBufModule *mod, dwContextHandle_t const context)
Get the nvscibuf module.
DW_API_PUBLIC dwStatus dwContext_selectGPUDevice(int32_t const deviceNumber, dwContextHandle_t const context)
Selects a GPU device, if available.
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 dwStatus dwContext_getCurrentTime(dwTime_t *const time, dwContextHandle_t const context)
Returns the current timestamp.
DW_API_PUBLIC dwStatus dwContext_getTimePTPSynchronizationStatus(dwPTPStatus *const status, dwContextHandle_t const context)
Get the PTP synchronization status of time source inside the context.
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.
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.
DW_API_PUBLIC dwStatus dwGetLastError(char8_t const **const errorMsg)
Retrieves the last error encountered.
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:86
DW_API_PUBLIC dwStatus dwContext_advanceTime(dwTime_t const newTime, dwContextHandle_t const context)
Advances the virtual time to newTime.
DW_API_PUBLIC dwStatus dwContext_getTimeSource(dwTimeSourceHandle_t *const source, dwContextHandle_t const context)
Retrieve time source used in the context.
void * dwCustomizedFileHandle
FileStream function pointers handle.
Definition: Context.h:144
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.
@ DW_PTP_STATUS_NO_ERROR
No error.
Definition: Context.h:219
@ DW_PTP_STATUS_LOST_SYNC
PTP synchronization lost.
Definition: Context.h:222
@ DW_PTP_STATUS_NO_INIT_SYNC
PTP synchronization is not started.
Definition: Context.h:216
@ DW_PTP_STATUS_INTERNAL_ERROR
PTP internal error.
Definition: Context.h:225
A set of parameters that is passed to the SDK to create the context.
Definition: Context.h:98
#define DW_API_PUBLIC
Definition: Exports.h:56
dwGPUDeviceType
GPU device type definitions Only applicable on Drive platforms.
Definition: TypesExtra.h:120
struct dwTimeSourceObject * dwTimeSourceHandle_t
Handle represents a TimeSource object.
Definition: Timer.h:58
Data structure representing a customized FileStream that can be passed in.
Definition: Context.h:150
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:166
void(* setPosition)(dwCustomizedFileHandle hnd, size_t size)
Function pointer: Set the desired position inside the file stream.
Definition: Context.h:187
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:207
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:160
size_t(* size)(dwCustomizedFileHandle hnd)
Function pointer: Returns the total number of bytes in the file stream.
Definition: Context.h:177
bool(* getString)(dwCustomizedFileHandle hnd, char8_t *ptr, size_t size)
Function pointer: Read a string from the file stream.
Definition: Context.h:172
void(* flush)(dwCustomizedFileHandle hnd)
Function pointer: Synchronizes the file stream, waiting that all requested bytes have been read.
Definition: Context.h:201
bool(* error)(dwCustomizedFileHandle hnd)
Function pointer: Check if any I/O error occurred during OPEN/RD/WR operations.
Definition: Context.h:197
bool(* eof)(dwCustomizedFileHandle hnd)
Function pointer: Check if the end of file flag is set for the file stream.
Definition: Context.h:192
void(* close)(dwCustomizedFileHandle hnd)
Function pointer: Close the file stream.
Definition: Context.h:153
size_t(* getPosition)(dwCustomizedFileHandle hnd)
Function pointer: Returns the current position inside the file stream.
Definition: Context.h:182