gsdf_impl_swseq.h#
Fully qualified name: src/device/vpu_runtime/include/cupva_device/impl/gsdf_impl_swseq.h
File members: src/device/vpu_runtime/include/cupva_device/impl/gsdf_impl_swseq.h
/*
* Copyright (c) 2023-2026 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 GSDF_IMPL_SWSEQ_H
#define GSDF_IMPL_SWSEQ_H
#include "dma_common.h"
#include "gsdf_impl_common.h"
#include <cupva_device/impl/cpp_utils.h>
#include <cupva_types.h>
// Struct to base tile size. Matches tileCntl layout.
struct GSDFTileBase
{
uint16_t alignX;
uint16_t alignY;
};
// Data which exists on a per config buffer basis
struct GSDFSwseqConfigBuffer
{
ExtMemPointer extPointer;
uint32_t vmemAddr;
GSDFBufferMetadata bufferMetadata;
uint32_t *transposeTable;
CUPVA_ALIGNED(GSDFTileBase, tileBase[GSDF_MAX_NUM_TILES], 4);
};
// Private GSDF struct
struct GSDFSwseqPriv
{
GSDFSwseqConfigBuffer configBuffers[cupva::device::priv::gsdfNumVpucBuffers];
uint8_t copyIters;
uint8_t configIdx;
uint8_t triggered;
uint8_t reserved[5];
AgenCFG transposeAgen;
AgenCFG vpuCAgen;
};
namespace cupva { namespace device { namespace priv {
constexpr uint32_t gsdfStaticHeaderSize =
sizeof(GSDFParams) + (sizeof(uint8_t) * GSDF_MAX_NUM_TILES) + sizeof(GSDFSwseqPriv);
inline constexpr uint32_t gsdfSwseqHandlerTotalSize(uint32_t numTiles)
{
cupva::device::priv::vpuAssert((numTiles <= GSDF_MAX_NUM_TILES));
return cupva::device::priv::gsdfStaticHeaderSize + gsdfSwseqTransposeTableOffset(numTiles) +
cupva::device::priv::gsdfSwseqTransposeTableSize;
}
inline constexpr uint32_t gsdfHwseqHandlerTotalSize(uint32_t numTiles, bool isUniform)
{
cupva::device::priv::vpuAssert((numTiles <= GSDF_MAX_NUM_TILES));
uint32_t const tblSize = gsdfHwseqVpucTableSize(numTiles, isUniform);
cupva::device::priv::vpuAssert((tblSize <= ((UINT32_MAX - cupva::device::priv::gsdfStaticHeaderSize) / 2U)));
return cupva::device::priv::gsdfStaticHeaderSize + 2U * tblSize;
}
inline constexpr uint32_t gsdfHandlerTotalSize(uint32_t numTiles, bool isUniform)
{
uint32_t const swseqSize = gsdfSwseqHandlerTotalSize(numTiles);
uint32_t const hwseqSize = gsdfHwseqHandlerTotalSize(numTiles, isUniform);
return swseqSize > hwseqSize ? swseqSize : hwseqSize;
}
}}} // namespace cupva::device::priv
// Implementation of flipping GSDF buffer
inline void cupvaGSDFSwseqCycleBuffersImpl(GSDFSwseqPriv *priv)
{
int32_t const bufCountMinus1 = cupva::device::priv::gsdfNumVpucBuffersSigned - 1;
int32_t const nextIdx = mod_inc(static_cast<int32_t>(priv->configIdx), bufCountMinus1);
cupva::device::priv::vpuAssert((nextIdx >= 0));
cupva::device::priv::vpuAssert((nextIdx <= 0xFF));
priv->configIdx = static_cast<uint8_t>(nextIdx);
}
// Flush current transpose table to VPUC area
inline void cupvaGSDFSwseqFlushImpl(GSDFSwseqPriv *priv)
{
cupva::device::priv::vpuAssert(
(static_cast<uint32_t>(priv->configIdx) < static_cast<uint32_t>(cupva::device::priv::gsdfNumVpucBuffers)));
cupvaModifyAgenCfgBase(&priv->transposeAgen, priv->configBuffers[priv->configIdx].transposeTable);
agen transposeInAgen = init_agen_from_cfg(priv->transposeAgen);
agen vpuCOutAgen = init_agen_from_cfg(priv->vpuCAgen);
dvintx vOut;
vOut.lo = replicatew(0);
vOut.hi = replicatew(0);
int32_t const pred = 0x00000555;
chess_separator_scheduler();
// Fill in addresses and values to VPUC table
for (uint32_t i = 0; i < priv->copyIters; i++) chess_loop_range(2, 32)
chess_prepare_for_pipelining
{
vOut.lo = vint_load_transp(transposeInAgen);
vstore_i(vOut, vpuCOutAgen, pred);
}
}
// Implementation of GSDF trigger.
inline void cupvaGSDFSwseqTrigImpl(GSDFParams *params, GSDFSwseqPriv *priv)
{
cupvaGSDFSwseqFlushImpl(priv);
cupvaGSDFSwseqCycleBuffersImpl(priv);
priv->triggered = 1U;
cupvaDataFlowTrig(params->trigger);
}
// Implementation of GSDF sync.
inline void cupvaGSDFSwseqSyncImpl(GSDFParams *params, GSDFSwseqPriv *priv)
{
uint32_t trigger = (priv->triggered == 1U) ? params->trigger : 0U;
cupvaDataFlowSync(trigger);
}
// The cupvaGSDFSwseq*Priv() private function declarations — both the non-inline entry points
// and the inline Trig/Sync/CycleBuffers dispatch helpers — live in impl/gsdf_impl_priv.h,
// which gatherscatter_dataflow.h includes after the handler types are complete.
#endif // GSDF_IMPL_SWSEQ_H