Mojo function
keep
keep(val: Bool)
Provides a hint to the compiler to not optimize the variable use away.
This is useful in benchmarking to avoid the compiler not deleting the code to be benchmarked because the variable is not used in a side-effecting manner.
Args:
- val (
Bool
): The value to not optimize away.
keep(val: Int)
Provides a hint to the compiler to not optimize the variable use away.
This is useful in benchmarking to avoid the compiler not deleting the code to be benchmarked because the variable is not used in a side-effecting manner.
Args:
- val (
Int
): The value to not optimize away.
keep[type: DType, simd_width: Int](val: SIMD[type, simd_width])
Provides a hint to the compiler to not optimize the variable use away.
This is useful in benchmarking to avoid the compiler not deleting the code to be benchmarked because the variable is not used in a side-effecting manner.
Parameters:
- type (
DType
): Thedtype
of the input and output SIMD vector. - simd_width (
Int
): The width of the input and output SIMD vector.
Args:
- val (
SIMD[type, simd_width]
): The value to not optimize away.
keep[type: AnyType](val: UnsafePointer[type, 0, 0, alignof[::AnyType,__mlir_type.!kgen.target]() if triple_is_nvidia_cuda() else 1])
Provides a hint to the compiler to not optimize the variable use away.
This is useful in benchmarking to avoid the compiler not deleting the code to be benchmarked because the variable is not used in a side-effecting manner.
Parameters:
- type (
AnyType
): The type of the input.
Args:
- val (
UnsafePointer[type, 0, 0, alignof[::AnyType,__mlir_type.!kgen.target]() if triple_is_nvidia_cuda() else 1]
): The value to not optimize away.
keep[type: AnyTrivialRegType](inout val: type)
Provides a hint to the compiler to not optimize the variable use away.
This is useful in benchmarking to avoid the compiler not deleting the code to be benchmarked because the variable is not used in a side-effecting manner.
Parameters:
- type (
AnyTrivialRegType
): The type of the input.
Args:
- val (
type
): The value to not optimize away.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!