Memory Buffer Basics

The buffer allocation model of NvSciBuf is summarized as follows:

If two or more hardware engines want to access a common buffer (for example, one engine is writing data into the buffer and the other engine is reading from the buffer), then:

Allocation Model

  1. Applications create an attribute list for each accessor.
  2. Set the attributes to define the properties of the buffer they intend to create in the respective attribute list.
    • Applications must set all datatypes (such as Image datatype, etc.) attributes using NvSciBuf/UMD APIs. Applications must also set the NvSciBuf General attributes directly in the attribute list.
    • For CUDA, applications must set all the required attributes.
    Note:

    Applications must ensure they set the NvSciBufGeneralAttrKey_GpuId attribute on the CUDA side to specify the IDs of all the GPUs that access the buffer.

  3. Reconcile these multiple attribute lists. The process of reconciliation guarantees that a common buffer is allocated that satisfies the constraints of all the accessors.
  4. Allocate the buffer using the reconciled attribute list. The reconciled attribute list used for allocating the object is associated with the object until the lifetime of the object.
  5. Share the buffer with all the accessors.

Types of Buffers

The hardware engine constraints depend on the type of buffer allocated. The different types of buffers supported by NvSciBuf (applications can choose to allocate one of the following types):

  • RawBuffer: Raw memory that is used by an application for storing data.
  • Image: Memory used to store image data.
  • ImagePyramid: Memory used to store ImagePyramid, a group of images arranged in multiple levels, with each level of image scaled to a specific scaling factor.
  • NvSciBufArray: Memory used to store a group of units, where each unit represents data of various basic types such as int, float etc.
  • Tensor: Memory used to store Tensor data.

Memory Domain Allocation

Applications can choose to allocate the memory from the following domains:

  • System memory
  • Vidmem of a specific dGPU (on the standard build)

Types of Buffer Attributes

The NvSciBuf attribute can be categorized into the following types:

Datatype attributes: Attributes that are specific to one of the buffer types mentioned in the previous section. If the buffer type in the attribute list is one type, then setting the attributes of another type returns an error.

General attributes: Attributes that are not specific to any buffer type and describes the general properties of the buffer. Some of the examples:

  • NvSciBufGeneralAttrKey_Types: Defines the type of the buffer.
  • NvSciBufGeneralAttrKey_NeedCpuAccess: Defines whether the CPU accesses the buffer.
  • NvSciBufGeneralAttrKey_RequiredPerm: Defines the access permissions expected by this buffer accessor.