Skip to main content
Log in

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): The dtype 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])

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]): The value to not optimize away.

keep[type: AnyTrivialRegType](mut 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.