aclrtMemPoolAttr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
typedef enum aclrtMemPoolAttr{
    ACL_RT_MEM_POOL_REUSE_FOLLOW_EVENT_DEPENDENCIES = 0x1,
    ACL_RT_MEM_POOL_REUSE_ALLOW_OPPORTUNISTIC = 0x2,
    ACL_RT_MEM_POOL_REUSE_ALLOW_INTERNAL_DEPENDENCIES = 0x3,
    ACL_RT_MEM_POOL_ATTR_RELEASE_THRESHOLD = 0x4,
    ACL_RT_MEM_POOL_ATTR_RESERVED_MEM_CURRENT = 0x5,
    ACL_RT_MEM_POOL_ATTR_RESERVED_MEM_HIGH = 0x6,
    ACL_RT_MEM_POOL_ATTR_USED_MEM_CURRENT = 0x7,
    ACL_RT_MEM_POOL_ATTR_USED_MEM_HIGH = 0x8
} aclrtMemPoolAttr;
Table 1 Enumeration items

Enumeration Item

Description

ACL_RT_MEM_POOL_REUSE_FOLLOW_EVENT_DEPENDENCIES

Event-driven memory reuse switch.

During task execution in a stream, the system searches for other streams associated with this stream through events and reuses the memory previously returned to the memory pool by tasks in those associated streams. This mechanism applies to scenarios where tasks between streams are synchronized through events in user applications.

The attribute value type is uint32_t. The options are as follows:

  • 1: enables event-driven memory reuse.
  • 0: disables event-driven memory reuse.

ACL_RT_MEM_POOL_REUSE_ALLOW_OPPORTUNISTIC

Opportunistic memory reuse switch.

During task execution in a stream, the system searches for reusable memory in the memory pool, but does not guarantee successful memory reuse. If memory reuse fails, the program reports an error and stops.

The attribute value type is uint32_t. The options are as follows:

  • 1: enables opportunistic memory reuse.
  • 0: disables opportunistic memory reuse.

ACL_RT_MEM_POOL_REUSE_ALLOW_INTERNAL_DEPENDENCIES

Internally driven memory reuse switch.

During task execution in a stream, the system searches for reusable memory in the memory pool. If the memory was previously used by another stream but no task dependencies exist between the two streams, the system automatically inserts event synchronization and wait logic between the streams. This ensures that the previous stream has finished accessing the memory, thereby achieving secure memory reuse.

The attribute value type is uint32_t. The options are as follows:

  • 1: enables internally driven memory reuse.
  • 0: disables internally driven memory reuse.

ACL_RT_MEM_POOL_ATTR_RELEASE_THRESHOLD

Threshold for memory reserved in the memory pool upon idle physical memory release, in bytes. The default value is 0.

When the idle physical memory in the memory pool exceeds this threshold, the system attempts to release idle memory during the next stream synchronization (for example, the next aclrtSynchronizeStream call).

The attribute value type is uint64_t.

ACL_RT_MEM_POOL_ATTR_RESERVED_MEM_CURRENT

Total memory allocated from the memory pool. This attribute is read-only.

The attribute value type is uint64_t.

ACL_RT_MEM_POOL_ATTR_RESERVED_MEM_HIGH

Historical peak value of the total memory allocated from the memory pool.

The attribute value type is uint64_t.

You can set this attribute only to 0.

ACL_RT_MEM_POOL_ATTR_USED_MEM_CURRENT

Total memory actually being used in the memory pool. This attribute is read-only.

The attribute value type is uint64_t.

ACL_RT_MEM_POOL_ATTR_USED_MEM_HIGH

Historical peak value of the total memory actually being used in the memory pool.

The attribute value type is uint64_t.

You can set this attribute only to 0.