tp::MemoryPreference struct

Represents the progression of tp::MemoryLocation that the device will attempt to allocate resources from, in the given order of preference.

Public static variables

static const MemoryPreference Device
Only device-local memory will be allocated, otherwise memory allocation error is thrown. This preference should be used when the resource does not need to be directly accessible by the host, but fast access by the device is needed. Images are always allocated with this memory preference.
static const MemoryPreference Host
Used for resources that should live in host memory. Meant for large data that is being read by the device infrequently and shouldn't be wasting the potentially limited device local, host visible memory. This is the best progression for staging buffers used to copy data to device local memory.
static const MemoryPreference ReadbackStream
Used for priority resources that are written to by the device and need to be read by the host with low latency.
static const MemoryPreference UploadStream
Used for priority resources that are written to by the host and need to be read by the device with low latency. If device locality is required, the resulting memory location of the allocation should be checked for a potential fallback to be used as a staging buffer.

Constructors, destructors, conversion operators

MemoryPreference(std::initializer_list<MemoryLocation> locationProgression, bool createPersistentlyMapped)

Function documentation

tp::MemoryPreference::MemoryPreference(std::initializer_list<MemoryLocation> locationProgression, bool createPersistentlyMapped)

Parameters
locationProgression The progression of memory locations in the order of preference.
createPersistentlyMapped If set to true, the memory allocated from this location will be mapped for host access upon creation and unmapped only when freed.

Variable documentation

static const MemoryPreference tp::MemoryPreference::Device

Only device-local memory will be allocated, otherwise memory allocation error is thrown. This preference should be used when the resource does not need to be directly accessible by the host, but fast access by the device is needed. Images are always allocated with this memory preference.

Progression: DeviceLocal -> DeviceLocalHostVisible -> DeviceLocalHostCached

static const MemoryPreference tp::MemoryPreference::Host

Used for resources that should live in host memory. Meant for large data that is being read by the device infrequently and shouldn't be wasting the potentially limited device local, host visible memory. This is the best progression for staging buffers used to copy data to device local memory.

Progression: HostCached -> HostVisible -> DeviceLocalHostCached -> DeviceLocalHostVisible

static const MemoryPreference tp::MemoryPreference::ReadbackStream

Used for priority resources that are written to by the device and need to be read by the host with low latency.

Progression: DeviceLocalHostCached -> HostCached -> DeviceLocalHostVisible -> HostVisible

static const MemoryPreference tp::MemoryPreference::UploadStream

Used for priority resources that are written to by the host and need to be read by the device with low latency. If device locality is required, the resulting memory location of the allocation should be checked for a potential fallback to be used as a staging buffer.

Progression: DeviceLocalHostVisible -> DeviceLocalHostCached -> HostVisible -> HostCached