CupvaPpeIpcVpu.h#
Fully qualified name: src/device/vpu_runtime/include/CupvaPpeIpcVpu.h
File members: src/device/vpu_runtime/include/CupvaPpeIpcVpu.h
/*
* Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#ifndef CUPVA_PPE_IPC_VPU_H
#define CUPVA_PPE_IPC_VPU_H
#include <CupvaPpeIpcCommon.h>
#include <cupva_device/impl/cpp_utils.h>
#if CUPVA_BUILD_MODE == CUPVA_NATIVE
# include <CupvaPpeIpcVpuNative.h>
#else
# include <CupvaPpeIpcVpuImpl.h>
#endif
#ifdef __cplusplus
static_assert(sizeof(PpeInteropStruct) == PPE_INTEROP_STRUCT_SIZE,
"PPE interop struct must exactly match the reserved interop region");
static_assert(sizeof(void *) <= PPE_MAX_PARAM_SIZE, "PPE parameter area must fit one interop handle pointer");
// Convenience overload (C++ only): publish an interop handle pointer into the
// PPE param area and start the command in one call, replacing the common
// "cupvaPPEWait(); *paramPtr = handle; cupvaPPEStart(id);" idiom. Build-mode
// agnostic -- it composes the mode-specific cupvaPPEWait/Start/GetParamPointer,
// so it works for NATIVE, EMU, and on-target (chess) builds alike. The handle
// is written after the previous command has drained (cupvaPPEWait) and before
// the new start, so the interop is never overwritten while the PPE is using it.
template<typename T>
inline void cupvaPPEStart(int32_t functionId, T *handle)
{
static_assert(sizeof(T *) <= PPE_MAX_PARAM_SIZE, "PPE parameter area must fit this interop handle pointer");
cupvaPPEWait();
*cupva::device::priv::pointerCast<T *volatile>(cupvaPPEGetParamPointer()) = handle;
cupvaPPEStart(functionId);
}
#endif
#endif // CUPVA_PPE_IPC_VPU_H