Mojo function
tile
tile[: origin.set, //, workgroup_function: fn[Int](Int) capturing -> None, tile_size_list: VariadicList[Int]](offset: Int, upperbound: Int)
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:
- workgroup_function (
fn[Int](Int) capturing -> None
): Workgroup function that processes one tile of workload. - tile_size_list (
VariadicList[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.
tile[: origin.set, //, workgroup_function: fn(Int, Int) capturing -> None](offset: Int, upperbound: Int, tile_size_list: VariadicList[Int])
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.
Parameters:
- workgroup_function (
fn(Int, Int) capturing -> None
): Workgroup function that processes one tile of workload.
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 (
VariadicList[Int]
): List of tile sizes to launch work.
tile[: origin.set, //, secondary_tile_size_list: VariadicList[Int], secondary_cleanup_tile: Int, workgroup_function: fn[Int](Int, Int) capturing -> None](offset: Int, upperbound: Int, primary_tile_size_list: VariadicList[Int], primary_cleanup_tile: Int)
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 (
VariadicList[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. - workgroup_function (
fn[Int](Int, Int) capturing -> None
): Workgroup function that processes one tile of workload.
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 (
VariadicList[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.
tile[: origin.set, //, workgroup_function: fn[Int, Int](Int, Int) capturing -> None, tile_sizes_x: VariadicList[Int], tile_sizes_y: VariadicList[Int]](offset_x: Int, offset_y: Int, upperbound_x: Int, upperbound_y: Int)
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:
- workgroup_function (
fn[Int, Int](Int, Int) capturing -> None
): Function that is invoked for each tile and offset. - tile_sizes_x (
VariadicList[Int]
): List of tile sizes to use for the first parameter of workgroup_function. - tile_sizes_y (
VariadicList[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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!