Compute Graph Framework SDK Reference  5.10
IChannelPacket.hpp
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) 2020-2022 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
31#ifndef DW_FRAMEWORK_ICHANNEL_PACKET_HPP_
32#define DW_FRAMEWORK_ICHANNEL_PACKET_HPP_
33
34#include <typeinfo>
35#include <cstddef>
38#include <nvscibuf.h>
39#include <nvscisync.h>
40#include <dw/core/language/Function.hpp>
41
42namespace dw
43{
44namespace framework
45{
46
56{
57public:
58 // Enable ownership via this interface
59 virtual ~IChannelPacket() = default;
60
65
73 {
74 public:
78 virtual uint8_t* getBuffer() = 0;
83 virtual size_t getBufferSize() = 0;
88 virtual size_t serialize() = 0;
92 virtual void deserialize(size_t) = 0;
93 };
94
103 {
104 public:
111 virtual uint32_t getNumBuffers() const = 0;
121 virtual void fillNvSciBufAttributes(uint32_t bufferIndex, NvSciBufAttrList& attrList) const = 0;
128 virtual void initializeFromNvSciBufObjs(dw::core::span<NvSciBufObj> bufs) = 0;
129
133 virtual void pack() = 0;
137 virtual void unpack() = 0;
138 };
139
152};
153
154// TODO(chale): this should be made private to the framework once external entities no longer create
155// Channel packets
157{
158public:
159 ChannelPacketDefaultBase(size_t typeSize);
160
162
163protected:
165 std::unique_ptr<uint8_t[]> m_buffer;
167};
168
170{
171public:
172 ChannelPacketDefault(size_t typeSize);
173
174 uint8_t* getBuffer() final;
175
176 size_t getBufferSize() final;
177
178 size_t serialize() final;
179
180 void deserialize(size_t) final;
181};
182
184{
185 static constexpr char LOG_TAG[] = "ChannelNvSciPacketDefault";
186
187public:
189
190 uint32_t getNumBuffers() const final;
191 void fillNvSciBufAttributes(uint32_t bufferIndex, NvSciBufAttrList& attrList) const final;
192
193 void initializeFromNvSciBufObjs(dw::core::span<NvSciBufObj> bufs);
194
195 void pack() final;
196
197 void unpack() final;
198
200
201private:
202 void fillCpuPacketDataAttributes(NvSciBufAttrList& output) const;
203
204 size_t m_typeSize{};
205 void* m_data{};
206};
207
212{
213public:
221 virtual std::unique_ptr<IChannelPacket> makePacket(GenericDataReference ref, ChannelType channelType) = 0;
222};
223using ChannelPacketFactoryPtr = std::shared_ptr<IChannelPacketFactory>;
224
225} // namespace framework
226} // namespace dw
227
228#endif // DW_FRAMEWORK_ICHANNEL_PACKET_HPP_
std::unique_ptr< uint8_t[]> m_buffer
virtual std::unique_ptr< IChannelPacket > makePacket(GenericDataReference ref, ChannelType channelType)=0
Make a packet.
virtual void initializeFromNvSciBufObjs(dw::core::span< NvSciBufObj > bufs)=0
virtual uint32_t getNumBuffers() const =0
virtual void fillNvSciBufAttributes(uint32_t bufferIndex, NvSciBufAttrList &attrList) const =0
SocketCallbacks & getSocketCallbacks()
virtual GenericData getGenericData()=0
virtual ~IChannelPacket()=default
NvSciCallbacks & getNvSciCallbacks()
std::shared_ptr< IChannelPacketFactory > ChannelPacketFactoryPtr
enum ChannelType :uint8_t { DW_CHANNEL_TYPE_SHMEM_LOCAL=0, DW_CHANNEL_TYPE_SHMEM_REMOTE=1, DW_CHANNEL_TYPE_EGLSTREAM=2, DW_CHANNEL_TYPE_SOCKET=3, DW_CHANNEL_TYPE_DDS=4, DW_CHANNEL_TYPE_NVSCI=5, } ChannelType
Definition: Buffer.hpp:40