Specifying Requirements

With synchronization objects, fences are generated at both endpoints and flow in both directions, so it was necessary for producer and consumer(s) to determine and exchange both write and read requirements. Buffer data, on the other hand, flows in only one direction, from the producer to the consumer(s). So, the producer must query the NVIDIA drivers they use for buffer attribute lists that provide write capability, while consumers must query for buffer attributes that provide read capability. If the buffer memory is written or read directly with the CPU, attribute lists can be manually created, requesting CPU access.

A packet may consist of multiple buffer elements containing different types of data. The producer must obtain a buffer attribute list for each type of data it can generate, and consumers must obtain attribute lists for each type of data they require.

Once a producer knows all the elements it can provide, or a consumer knows all the elements it requires, it can inform the stream by calling NvSciStreamBlockElementAttrSet()(operational after NvSciStreamEventType_Connected is queried) for each element. The userType parameter is an application-defined value to identify the element, understood by both the producer and consumer(s). The userType should be unique for each element. The bufAttrList field contains a handle for the element's attribute list. Ownership of this handle remains with the caller, and it deletes it when it is no longer needed after the function returns. NvSciStream creates a duplicate.

After specifying all of the elements, the application will indicate it is done with the element setup by calling NvSciStreamBlockSetupStatusSet() with a value of NvSciStreamSetup_ElementExport. The indices and count will be determined automatically by NvSciStream.

Asynchronous elements data is not available to the consumer until the fences complete. This generally indicates data written using NVIDIA hardware. Synchronous elements data is available to be read as soon as the packet is acquired by the consumer, without waiting for any fence. This generally indicates data written directly with the CPU. Whether an element is asynchronous or synchronous is determined by sync requirements setup steps.

A typical use case that a packet contains both asynchronous and synchronous elements is a packet containing a large primary data element accompanied by a smaller metadata element containing information required to program the hardware for processing the primary element. Upon acquiring the packet, the metadata must be read immediately by the CPU, so that instructions for the NVIDIA drivers can be issued, but the primary data is read later once the fence has been reached.


NvSciError
NvSciStreamBlockElementAttrSet(
    NvSciStreamBlock const block,
    uint32_t         const userType,
    NvSciBufAttrList const bufAttrList
)