/dvs/p4/build/sw/rel/gpgpu/toolkit/r13.4/cuDLA/inc/cudla.h
File members: /dvs/p4/build/sw/rel/gpgpu/toolkit/r13.4/cuDLA/inc/cudla.h
/*
* Copyright 2020-2026 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO LICENSEE:
*
* This source code and/or documentation ("Licensed Deliverables") are
* subject to NVIDIA intellectual property rights under U.S. and
* international Copyright laws.
*
* These Licensed Deliverables contained herein is PROPRIETARY and
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
* conditions of a form of NVIDIA software license agreement by and
* between NVIDIA and Licensee ("License Agreement") or electronically
* accepted by Licensee. Notwithstanding any terms or conditions to
* the contrary in the License Agreement, reproduction or disclosure
* of the Licensed Deliverables to any third party without the express
* written consent of NVIDIA is prohibited.
*
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THESE LICENSED DELIVERABLES.
*
* U.S. Government End Users. These Licensed Deliverables are a
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
* 1995), consisting of "commercial computer software" and "commercial
* computer software documentation" as such terms are used in 48
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
* U.S. Government End Users acquire the Licensed Deliverables with
* only those rights set forth herein.
*
* Any use of the Licensed Deliverables in individual and commercial
* software must include, in the user documentation and internal
* comments to the code, the above Disclaimer and U.S. Government End
* Users Notice.
*/
#if !defined __CUDLA_H__
#define __CUDLA_H__
#include <stdint.h>
#include <stddef.h>
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
#define CUDLA_VER_MAJOR 1U
#define CUDLA_VER_MINOR 5U
#define CUDLA_VER_PATCH 0U
#define CUDLA_DATA_FORMAT_UNKNOWN 0U
#define CUDLA_DATA_FORMAT_NCHW 1U
#define CUDLA_DATA_FORMAT_NHWC 2U
#define CUDLA_DATA_FORMAT_NCxHWx 3U
#define CUDLA_DATA_TYPE_UNKNOWN 0U
#define CUDLA_DATA_TYPE_FLOAT 1U
#define CUDLA_DATA_TYPE_HALF 2U
#define CUDLA_DATA_TYPE_INT16 3U
#define CUDLA_DATA_TYPE_INT8 4U
#define CUDLA_DATA_TYPE_UINT8 5U
#define CUDLA_DATA_TYPE_UINT16 6U
#define CUDLA_DATA_CATEGORY_IMAGE 0U
#define CUDLA_DATA_CATEGORY_WEIGHT 1U
#define CUDLA_DATA_CATEGORY_FEATURE 2U
#define CUDLA_DATA_CATEGORY_PLANAR 3U
#define CUDLA_DATA_CATEGORY_BIAS 4U
#define CUDLA_PIXEL_FORMAT_R8 0U
#define CUDLA_PIXEL_FORMAT_R10 1U
#define CUDLA_PIXEL_FORMAT_R12 2U
#define CUDLA_PIXEL_FORMAT_R16 3U
#define CUDLA_PIXEL_FORMAT_R16_I 4U
#define CUDLA_PIXEL_FORMAT_R16_F 5U
#define CUDLA_PIXEL_FORMAT_A16B16G16R16 6U
#define CUDLA_PIXEL_FORMAT_X16B16G16R16 7U
#define CUDLA_PIXEL_FORMAT_A16B16G16R16_F 8U
#define CUDLA_PIXEL_FORMAT_A16Y16U16V16 9U
#define CUDLA_PIXEL_FORMAT_V16U16Y16A16 10U
#define CUDLA_PIXEL_FORMAT_A16Y16U16V16_F 11U
#define CUDLA_PIXEL_FORMAT_A8B8G8R8 12U
#define CUDLA_PIXEL_FORMAT_A8R8G8B8 13U
#define CUDLA_PIXEL_FORMAT_B8G8R8A8 14U
#define CUDLA_PIXEL_FORMAT_R8G8B8A8 15U
#define CUDLA_PIXEL_FORMAT_X8B8G8R8 16U
#define CUDLA_PIXEL_FORMAT_X8R8G8B8 17U
#define CUDLA_PIXEL_FORMAT_B8G8R8X8 18U
#define CUDLA_PIXEL_FORMAT_R8G8B8X8 19U
#define CUDLA_PIXEL_FORMAT_A2B10G10R10 20U
#define CUDLA_PIXEL_FORMAT_A2R10G10B10 21U
#define CUDLA_PIXEL_FORMAT_B10G10R10A2 22U
#define CUDLA_PIXEL_FORMAT_R10G10B10A2 23U
#define CUDLA_PIXEL_FORMAT_A2Y10U10V10 24U
#define CUDLA_PIXEL_FORMAT_V10U10Y10A2 25U
#define CUDLA_PIXEL_FORMAT_A8Y8U8V8 26U
#define CUDLA_PIXEL_FORMAT_V8U8Y8A8 27U
#define CUDLA_PIXEL_FORMAT_Y8___U8V8_N444 28U
#define CUDLA_PIXEL_FORMAT_Y8___V8U8_N444 29U
#define CUDLA_PIXEL_FORMAT_Y10___U10V10_N444 30U
#define CUDLA_PIXEL_FORMAT_Y10___V10U10_N444 31U
#define CUDLA_PIXEL_FORMAT_Y12___U12V12_N444 32U
#define CUDLA_PIXEL_FORMAT_Y12___V12U12_N444 33U
#define CUDLA_PIXEL_FORMAT_Y16___U16V16_N444 34U
#define CUDLA_PIXEL_FORMAT_Y16___V16U16_N444 35U
#define CUDLA_PIXEL_FORMAT_FEATURE 36U
#define CUDLA_PIXEL_FORMAT_UNKNOWN 37U
#define CUDLA_PIXEL_MAPPING_PITCH_LINEAR 0U
#define CUDLA_PIXEL_MAPPING_BLOCK_LINEAR 1U
#define CUDLA_LOADABLE_TENSOR_DESC_NUM_STRIDES 8U
#define CUDLA_RUNTIME_TENSOR_DESC_NAME_MAX_LEN 80U
enum cudlaStatus {
cudlaSuccess = 0,
cudlaErrorInvalidParam = 1,
cudlaErrorOutOfResources = 2,
cudlaErrorCreationFailed = 3,
cudlaErrorInvalidAddress = 4,
cudlaErrorOs = 5,
cudlaErrorCuda = 6,
cudlaErrorUmd = 7,
cudlaErrorInvalidDevice = 8,
cudlaErrorInvalidAttribute = 9,
cudlaErrorIncompatibleDlaSWVersion = 10,
cudlaErrorMemoryRegistered = 11,
cudlaErrorInvalidModule = 12,
cudlaErrorUnsupportedOperation = 13,
cudlaErrorNvSci = 14,
cudlaErrorDriverNotFound = 15,
cudlaErrorDlaErrInvalidInput = 0x40000001,
cudlaErrorDlaErrInvalidPreAction = 0x40000002,
cudlaErrorDlaErrNoMem = 0x40000003,
cudlaErrorDlaErrProcessorBusy = 0x40000004,
cudlaErrorDlaErrTaskStatusMismatch = 0x40000005,
cudlaErrorDlaErrEngineTimeout = 0x40000006,
cudlaErrorDlaErrDataMismatch = 0x40000007,
cudlaErrorUnknown = 0x7fffffff
};
typedef enum cudlaStatus cudlaStatus;
enum cudlaMode {
CUDLA_CUDA_DLA = 0,
CUDLA_STANDALONE = 1
};
typedef enum cudlaMode cudlaMode;
enum cudlaScratchMemoryConfig {
CUDLA_SCRATCH_MEMORY_DEFAULT = 0U << 1, /* 0x0 : private per-loadable scratch (default) */
CUDLA_SCRATCH_MEMORY_SHARED_STATIC = 1U << 1, /* 0x2 : shared static scratch pool; must be OR-ed with a cudlaMode */
CUDLA_SCRATCH_MEMORY_CONFIG_MAX = 0x7FFFFFFF /* pin enum to 32-bit width */
};
typedef enum cudlaScratchMemoryConfig cudlaScratchMemoryConfig;
enum cudlaNvSciSyncAttributes {
CUDLA_NVSCISYNC_ATTR_WAIT = 1,
CUDLA_NVSCISYNC_ATTR_SIGNAL = 2
};
typedef enum cudlaNvSciSyncAttributes cudlaNvSciSyncAttributes;
struct cudlaExternalMemoryHandleDesc_t {
const void* extBufObject;
unsigned long long size;
};
typedef struct cudlaExternalMemoryHandleDesc_t cudlaExternalMemoryHandleDesc;
struct cudlaExternalSemaphoreHandleDesc_t {
const void* extSyncObject;
};
typedef struct cudlaExternalSemaphoreHandleDesc_t cudlaExternalSemaphoreHandleDesc;
struct cudlaDevHandle_t;
typedef struct cudlaDevHandle_t* cudlaDevHandle;
struct cudlaModule_t;
typedef struct cudlaModule_t* cudlaModule;
enum cudlaModuleAttributeType {
CUDLA_NUM_INPUT_TENSORS = 0,
CUDLA_NUM_OUTPUT_TENSORS = 1,
CUDLA_INPUT_TENSOR_DESCRIPTORS = 2,
CUDLA_OUTPUT_TENSOR_DESCRIPTORS = 3,
CUDLA_NUM_OUTPUT_TASK_STATISTICS = 4,
CUDLA_OUTPUT_TASK_STATISTICS_DESCRIPTORS = 5,
};
typedef enum cudlaModuleAttributeType cudlaModuleAttributeType;
typedef struct cudlaModuleTensorDescriptor_t {
char name[CUDLA_RUNTIME_TENSOR_DESC_NAME_MAX_LEN + 1];
uint64_t size;
uint64_t n;
uint64_t c;
uint64_t h;
uint64_t w;
uint8_t dataFormat;
uint8_t dataType;
uint8_t dataCategory;
uint8_t pixelFormat;
uint8_t pixelMapping;
uint32_t stride[CUDLA_LOADABLE_TENSOR_DESC_NUM_STRIDES];
} cudlaModuleTensorDescriptor;
typedef union cudlaModuleAttribute_t {
uint32_t numInputTensors;
uint32_t numOutputTensors;
cudlaModuleTensorDescriptor* inputTensorDesc;
cudlaModuleTensorDescriptor* outputTensorDesc;
} cudlaModuleAttribute;
enum cudlaFenceType {
CUDLA_NVSCISYNC_FENCE = 1,
/*
* NvSciSync fence type for SOF.
*/
CUDLA_NVSCISYNC_FENCE_SOF = 2
};
typedef enum cudlaFenceType cudlaFenceType;
typedef struct CudlaFence {
void* fence;
cudlaFenceType type;
} CudlaFence;
typedef struct cudlaWaitEvents {
const CudlaFence* preFences;
uint32_t numEvents;
} cudlaWaitEvents;
typedef struct cudlaSignalEvents {
uint64_t* const * devPtrs;
CudlaFence* eofFences;
uint32_t numEvents;
} cudlaSignalEvents;
enum cudlaModuleLoadFlags {
CUDLA_MODULE_DEFAULT = 0,
CUDLA_MODULE_ENABLE_FAULT_DIAGNOSTICS = 1
};
typedef enum cudlaModuleLoadFlags cudlaModuleLoadFlags;
enum cudlaSubmissionFlags {
CUDLA_SUBMIT_NOOP = 1,
CUDLA_SUBMIT_SKIP_LOCK_ACQUIRE = 1<<1,
CUDLA_SUBMIT_DIAGNOSTICS_TASK = 1<<2
};
typedef enum cudlaSubmissionFlags cudlaSubmissionFlags;
enum cudlaAccessPermissionFlags {
CUDLA_READ_WRITE_PERM = 0,
CUDLA_READ_ONLY_PERM = 1,
CUDLA_TASK_STATISTICS = 1<<1
};
typedef enum cudlaAccessPermissionFlags cudlaAccessPermissionFlags;
typedef struct cudlaTask_t {
cudlaModule moduleHandle;
uint64_t* const * outputTensor;
uint32_t numOutputTensors;
uint32_t numInputTensors;
const uint64_t* const * inputTensor;
const cudlaWaitEvents* waitEvents;
cudlaSignalEvents* signalEvents;
} cudlaTask;
enum cudlaDevAttributeType {
CUDLA_UNIFIED_ADDRESSING = 0,
CUDLA_DEVICE_VERSION = 1
};
typedef enum cudlaDevAttributeType cudlaDevAttributeType;
typedef union cudlaDevAttribute_t {
uint8_t unifiedAddressingSupported;
uint32_t deviceVersion;
} cudlaDevAttribute;
/* END CUDLA_TYPES */
cudlaStatus cudlaGetVersion(uint64_t * const version);
cudlaStatus cudlaDeviceGetCount(uint64_t * const pNumDevices);
cudlaStatus cudlaCreateDevice(uint64_t const device,
cudlaDevHandle * const devHandle,
uint32_t const flags);
cudlaStatus cudlaMemRegister(cudlaDevHandle const devHandle,
const uint64_t* const ptr,
size_t const size,
uint64_t** const devPtr,
uint32_t const flags);
cudlaStatus cudlaModuleLoadFromMemory(cudlaDevHandle const devHandle,
const uint8_t * const pModule,
size_t const moduleSize,
cudlaModule* const hModule,
uint32_t const flags);
cudlaStatus cudlaModuleGetAttributes(cudlaModule const hModule,
cudlaModuleAttributeType const attrType,
cudlaModuleAttribute* const attribute);
cudlaStatus cudlaModuleUnload(cudlaModule const hModule, uint32_t const flags);
cudlaStatus cudlaSubmitTask(cudlaDevHandle const devHandle,
const cudlaTask * const ptrToTasks,
uint32_t const numTasks,
void* const stream,
uint32_t const flags);
cudlaStatus cudlaDeviceGetAttribute(cudlaDevHandle const devHandle,
cudlaDevAttributeType const attrib,
cudlaDevAttribute* const pAttribute);
cudlaStatus cudlaMemUnregister(cudlaDevHandle const devHandle,
const uint64_t * const devPtr);
cudlaStatus cudlaGetLastError(cudlaDevHandle const devHandle);
cudlaStatus cudlaDestroyDevice(cudlaDevHandle const devHandle);
cudlaStatus cudlaImportExternalMemory(cudlaDevHandle const devHandle,
const cudlaExternalMemoryHandleDesc* const desc,
uint64_t** const devPtr,
uint32_t const flags);
cudlaStatus cudlaGetNvSciSyncAttributes(uint64_t* attrList,
uint32_t const flags);
cudlaStatus cudlaImportExternalSemaphore(cudlaDevHandle const devHandle,
const cudlaExternalSemaphoreHandleDesc* const desc,
uint64_t** const devPtr,
uint32_t const flags);
cudlaStatus cudlaSetTaskTimeoutInMs(cudlaDevHandle const devHandle,
uint32_t const timeout);
/* END CUDLA_API */
#if defined(__cplusplus)
}
#endif /* __cplusplus */
#endif // __CUDLA_H__