IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

bencher_iter_custom

def bencher_iter_custom[FuncType: def(DeviceContext) raises -> None](mut self_: Bencher, func: FuncType, ctx: DeviceContext)

Times a target GPU closure with custom number of iterations via DeviceContext ctx.

Notes:

Nested launch closures that capture benchmark-local state are closure values. This value-taking overload forwards the closure to DeviceContext.execution_time() so FuncType carries the captured state.

Parameters:

  • ​FuncType (def(DeviceContext) raises -> None): The target GPU kernel launch closure type.

Args:

  • ​self_ (Bencher): The bencher state.
  • ​func (FuncType): The closure carrying the captured state of the kernel launch.
  • ​ctx (DeviceContext): The GPU DeviceContext for launching kernel.

def bencher_iter_custom[FuncType: def(DeviceContext, Int) raises -> None](mut self_: Bencher, func: FuncType, ctx: DeviceContext)

Times a target GPU closure with custom number of iterations via DeviceContext ctx.

Notes:

Nested launch closures that capture benchmark-local state are closure values. This value-taking overload forwards the closure to DeviceContext.execution_time_iter() so FuncType carries the captured state.

Parameters:

  • ​FuncType (def(DeviceContext, Int) raises -> None): The target GPU kernel launch closure type.

Args:

  • ​self_ (Bencher): The bencher state.
  • ​func (FuncType): The closure carrying the captured state of the kernel launch.
  • ​ctx (DeviceContext): The GPU DeviceContext for launching kernel.

Was this page helpful?