intrinsics
Defines intrinsics.
You can import these APIs from the complex
package. For example:
from sys.intrinsics import PrefetchLocality
PrefetchLocality
The prefetch locality.
The locality, rw, and cache type correspond to LLVM prefetch intrinsic’s inputs (see LLVM prefetch locality)
Aliases:
-
NONE = PrefetchLocality(0)
: No locality. -
LOW = PrefetchLocality(1)
: Low locality. -
MEDIUM = PrefetchLocality(2)
: Medium locality. -
HIGH = PrefetchLocality(3)
: Extremely local locality (keep in cache).
Fields:
- value (
SIMD[si32, 1]
): The prefetch locality to use. It should be a value in [0, 3].
Implemented traits:
AnyType
Methods:
__init__
__init__(value: Int) -> Self
Constructs a prefetch locality option.
Args:
- value (
Int
): An integer value representing the locality. Should be a value in the range[0, 3]
.
Returns:
The prefetch locality constructed.
PrefetchRW
Prefetch read or write.
Aliases:
-
READ = PrefetchRW(0)
: Read prefetch. -
WRITE = PrefetchRW(1)
: Write prefetch.
Fields:
- value (
SIMD[si32, 1]
): The read-write prefetch. It should be in [0, 1].
Implemented traits:
AnyType
Methods:
__init__
__init__(value: Int) -> Self
Constructs a prefetch read-write option.
Args:
- value (
Int
): An integer value representing the prefetch read-write option to be used. Should be a value in the range[0, 1]
.
Returns:
The prefetch read-write option constructed.
PrefetchCache
Prefetch cache type.
Aliases:
-
INSTRUCTION = PrefetchCache(0)
: The instruction prefetching option. -
DATA = PrefetchCache(1)
: The data prefetching option.
Fields:
- value (
SIMD[si32, 1]
): The cache prefetch. It should be in [0, 1].
Implemented traits:
AnyType
Methods:
__init__
__init__(value: Int) -> Self
Constructs a prefetch option.
Args:
- value (
Int
): An integer value representing the prefetch cache option to be used. Should be a value in the range[0, 1]
.
Returns:
The prefetch cache type that was constructed.
PrefetchOptions
Collection of configuration parameters for a prefetch intrinsic call.
The op configuration follows similar interface as LLVM intrinsic prefetch op, with a “locality” attribute that specifies the level of temporal locality in the application, that is, how soon would the same data be visited again. Possible locality values are: NONE
, LOW
, MEDIUM
, and HIGH
.
The op also takes a “cache tag” attribute giving hints on how the prefetched data will be used. Possible tags are: ReadICache
, ReadDCache
and WriteDCache
.
Note: the actual behavior of the prefetch op and concrete interpretation of these attributes are target-dependent.
Fields:
-
rw (
PrefetchRW
): Indicates prefetching for read or write. -
locality (
PrefetchLocality
): Indicates locality level. -
cache (
PrefetchCache
): Indicates i-cache or d-cache prefetching.
Implemented traits:
AnyType
Methods:
__init__
__init__(inout self: Self)
Constructs an instance of PrefetchOptions with default params.
for_read
for_read(self: Self) -> Self
Sets the prefetch purpose to read.
Returns:
The updated prefetch parameter.
for_write
for_write(self: Self) -> Self
Sets the prefetch purpose to write.
Returns:
The updated prefetch parameter.
no_locality
no_locality(self: Self) -> Self
Sets the prefetch locality to none.
Returns:
The updated prefetch parameter.
low_locality
low_locality(self: Self) -> Self
Sets the prefetch locality to low.
Returns:
The updated prefetch parameter.
medium_locality
medium_locality(self: Self) -> Self
Sets the prefetch locality to medium.
Returns:
The updated prefetch parameter.
high_locality
high_locality(self: Self) -> Self
Sets the prefetch locality to high.
Returns:
The updated prefetch parameter.
to_data_cache
to_data_cache(self: Self) -> Self
Sets the prefetch target to data cache.
Returns:
The updated prefetch parameter.
to_instruction_cache
to_instruction_cache(self: Self) -> Self
Sets the prefetch target to instruction cache.
Returns:
The updated prefetch parameter.
llvm_intrinsic
llvm_intrinsic[intrin: StringLiteral, type: AnyRegType]() -> *"type"
Calls an LLVM intrinsic with no arguments.
Calls an LLVM intrinsic with the name intrin and return type type.
Parameters:
- intrin (
StringLiteral
): The name of the llvm intrinsic. - type (
AnyRegType
): The return type of the intrinsic.
Returns:
The result of calling the llvm intrinsic with no arguments.
llvm_intrinsic[intrin: StringLiteral, type: AnyRegType, T0: AnyRegType](arg0: T0) -> *"type"
Calls an LLVM intrinsic with one argument.
Calls the intrinsic with the name intrin and return type type on argument arg0.
Parameters:
- intrin (
StringLiteral
): The name of the llvm intrinsic. - type (
AnyRegType
): The return type of the intrinsic. - T0 (
AnyRegType
): The type of the first argument to the intrinsic (arg0).
Args:
- arg0 (
T0
): The argument t