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

tile

def tile[tile_size_list: List[Int]](offset: Int, upperbound: Int, workgroup_function: T)

A generator that launches work groups in specified list of tile sizes.

A workgroup function is a function that can process a configurable consecutive "tile" of workload. E.g. work_on[3](5) should launch computation on item 5,6,7, and should be semantically equivalent to work_on[1](5), work_on[1](6), work_on[1](7).

This generator will try to proceed with the given list of tile sizes on the listed order. E.g. tile[func, (3,2,1)](offset, upperbound) will try to call func[3] starting from offset until remaining work is less than 3 from upperbound and then try func[2], and then func[1], etc.

Parameters:

  • ​tile_size_list (List[Int]): List of tile sizes to launch work.

Args:

  • ​offset (Int): The initial index to start the work from.
  • ​upperbound (Int): The runtime upperbound that the work function should not exceed.
  • ​workgroup_function (T): Workgroup function that processes one tile of workload.

def tile(offset: Int, upperbound: Int, *tile_size_list: Int, *, workgroup_function: T)

A generator that launches work groups in specified list of tile sizes.

This is the version of tile generator for the case where work_group function can take the tile size as a runtime value.

Args:

  • ​offset (Int): The initial index to start the work from.
  • ​upperbound (Int): The runtime upperbound that the work function should not exceed.
  • ​*tile_size_list (Int): List of tile sizes to launch work.
  • ​workgroup_function (T): Workgroup function that processes one tile of workload.

def tile[secondary_tile_size_list: List[Int], secondary_cleanup_tile: Int](offset: Int, upperbound: Int, *primary_tile_size_list: Int, *, primary_cleanup_tile: Int, workgroup_function: T)

A generator that launches work groups in specified list of tile sizes until the sum of primary_tile_sizes has exceeded the upperbound.

Parameters:

  • ​secondary_tile_size_list (List[Int]): List of static tile sizes to launch work.
  • ​secondary_cleanup_tile (Int): Last static tile to use when primary tile sizes don't fit exactly within the upperbound.

Args:

  • ​offset (Int): The initial index to start the work from.
  • ​upperbound (Int): The runtime upperbound that the work function should not exceed.
  • ​*primary_tile_size_list (Int): List of dynamic tile sizes to launch work.
  • ​primary_cleanup_tile (Int): Last dynamic tile to use when primary tile sizes don't fit exactly within the upperbound.
  • ​workgroup_function (T): Workgroup function that processes one tile of workload.

def tile[tile_sizes_x: List[Int], tile_sizes_y: List[Int]](offset_x: Int, offset_y: Int, upperbound_x: Int, upperbound_y: Int, workgroup_function: T)

Launches workgroup_function using the largest tile sizes possible in each dimension, starting from the x and y offset, until the x and y upperbounds are reached.

Parameters:

  • ​tile_sizes_x (List[Int]): List of tile sizes to use for the first parameter of workgroup_function.
  • ​tile_sizes_y (List[Int]): List of tile sizes to use for the second parameter of workgroup_function.

Args:

  • ​offset_x (Int): Initial x offset passed to workgroup_function.
  • ​offset_y (Int): Initial y offset passed to workgroup_function.
  • ​upperbound_x (Int): Max offset in x dimension passed to workgroup function.
  • ​upperbound_y (Int): Max offset in y dimension passed to workgroup function.
  • ​workgroup_function (T): Function that is invoked for each tile and offset.