Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BinningMemoryResource

summary

Allocates memory from upstream resources associated with bin sizes.

Hierarchy

Index

Constructors

constructor

  • new BinningMemoryResource(upstreamMemoryResource: MemoryResource, minSizeExponent?: number, maxSizeExponent?: number): BinningMemoryResource
  • summary

    Constructs a MemoryResource which allocates memory from a set of specified "bin" sizes based on a specified allocation size from an upstream MemoryResource.

    detail

    If minSizeExponent and maxSizeExponent are specified, initializes with one or more FixedSizeMemoryResource bins in the range [2^minSizeExponent, 2^maxSizeExponent].

    Call addBin to add additional bin allocators.

    Parameters

    • upstreamMemoryResource: MemoryResource

      The MemoryResource to use for allocations larger than any of the bins.

    • Optional minSizeExponent: number

      The base-2 exponent of the minimum size FixedSizeMemoryResource bin to create (optional).

    • Optional maxSizeExponent: number

      The base-2 exponent of the maximum size FixedSizeMemoryResource bin to create (optional).

    Returns BinningMemoryResource

Properties

Readonly memoryResource

memoryResource: MemoryResource

The MemoryResource to use for allocations larger than any of the bins.

Readonly supportsGetMemInfo

supportsGetMemInfo: boolean
summary

A boolean indicating whether the resource supports the getMemInfo() API.

Readonly supportsStreams

supportsStreams: boolean
summary

A boolean indicating whether the resource supports use of non-null CUDA streams for allocation/deallocation.

Methods

addBin

  • addBin(byteLength: number, binResource?: MemoryResource): void
  • summary

    Adds a bin of the specified maximum allocation size to this MemoryResource.

    detail

    If specified, uses binResource for allocation for this bin. If not specified, uses a FixedSizeMemoryResource for this bin's allocations.

    Allocations smaller than byteLength and larger than the next smaller bin size will use this fixed-size MemoryResource.

    Parameters

    • byteLength: number

      The maximum allocation size in bytes for the created bin

    • Optional binResource: MemoryResource

      The resource to use for this bin (optional)

    Returns void

getMemInfo

  • getMemInfo(stream?: number): [number, number]
  • Queries the amount of free and total memory for the resource.

    Parameters

    • Optional stream: number

      the stream whose memory manager we want to retrieve

    Returns [number, number]

    a tuple which contains [free memory, total memory] (in bytes)

isEqual

  • isEqual(other: MemoryResource): boolean
  • summary

    Compare this resource to another.

    remarks

    Two CudaMemoryResource instances always compare equal, because they can each deallocate memory allocated by the other.

    Parameters

    • other: MemoryResource

      The other resource to compare to

    Returns boolean

    true if the two resources are equal, else false