Mojo struct
CacheEviction
struct CacheEviction
Represents cache eviction policies for GPU memory operations.
This struct defines different cache eviction priorities that control how data is evicted from cache when space is needed. The policies affect cache utilization and performance by controlling which data gets evicted first.
Aliases
EVICT_NORMAL = CacheEviction(0)
: Default cache eviction priority. Data cached with normal priority follows standard cache replacement policies. This is the default behavior and suitable for most general-purpose data access patterns where no special caching requirements exist.EVICT_FIRST = CacheEviction(1)
: Highest eviction priority - data will be evicted first. Data cached with this priority is marked as the first candidate for eviction when cache space is needed. This is optimal for:- Streaming data that will not be reused
- Single-pass algorithms
- Data with low temporal locality
EVICT_LAST = CacheEviction(2)
: Lowest eviction priority - data will be evicted last. Data cached with this priority remains in cache until all higher priority data is evicted. Best used for:- Frequently accessed data
- Data needed across multiple kernel launches
- Critical data structures that benefit from cache persistence
EVICT_UNCHANGED = CacheEviction(3)
: Preserves existing cache eviction priority. When this policy is used:- Existing cache entries maintain their current eviction priority
- No changes are made to the cache replacement order
- Useful for operations that should not affect caching behavior
NO_ALLOCATE = CacheEviction(4)
: Prevents cache allocation for accessed data. Data is not cached when using this policy. Optimal for:- Large sequential reads/writes
- Data that will only be accessed once
- Preserving cache space for more critical data
- Streaming operations with no data reuse
Implemented traits
AnyType
,
Copyable
,
ExplicitlyCopyable
,
Movable
,
UnknownDestructibility
Methods
__eq__
__eq__(self, other: Self) -> Bool
Tests if two CacheEviction instances are equal.
Args:
- other (
Self
): The CacheEviction to compare against.
Returns:
True if the eviction policies are equal, False otherwise.
__ne__
__ne__(self, other: Self) -> Bool
Tests if two CacheEviction instances are not equal.
Args:
- other (
Self
): The CacheEviction to compare against.
Returns:
True if the eviction policies are not equal, False otherwise.
__is__
__is__(self, other: Self) -> Bool
Tests if two CacheEviction instances are identical.
Args:
- other (
Self
): The CacheEviction to compare against.
Returns:
True if the eviction policies are identical, False otherwise.
__isnot__
__isnot__(self, other: Self) -> Bool
Tests if two CacheEviction instances are not identical.
Args:
- other (
Self
): The CacheEviction to compare against.
Returns:
True if the eviction policies are not identical, False otherwise.
mnemonic
mnemonic(self) -> StringLiteral
Returns the string mnemonic for this cache eviction policy.
Converts the cache eviction policy into its corresponding string representation used in GPU instructions and debugging.
Returns:
A string literal containing the mnemonic for this eviction policy.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!