CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
121 lines
3.8 KiB
Python
121 lines
3.8 KiB
Python
# Copyright Advanced Micro Devices, Inc., or its affiliates.
|
||
# SPDX-License-Identifier: MIT
|
||
|
||
"""Shared test utilities for origami tests."""
|
||
|
||
import origami
|
||
|
||
|
||
# Hardware objects for supported architectures
|
||
HARDWARE = {
|
||
"gfx90a": origami.get_hardware_for_arch(
|
||
origami.architecture_t.gfx90a, 110, 64 * 1024, 512 * 1024, 8 * 1024 * 1024, 1700000
|
||
),
|
||
"gfx942": origami.get_hardware_for_arch(
|
||
origami.architecture_t.gfx942, 228, 64 * 1024, 512 * 1024, 24 * 1024 * 1024, 1700000
|
||
),
|
||
"gfx950": origami.get_hardware_for_arch(
|
||
origami.architecture_t.gfx950, 304, 64 * 1024, 512 * 1024, 32 * 1024 * 1024, 2100000
|
||
),
|
||
"gfx1100": origami.get_hardware_for_arch(
|
||
origami.architecture_t.gfx1100, 96, 64 * 1024, 512 * 1024, 6 * 1024 * 1024, 2500000
|
||
),
|
||
"gfx1200": origami.get_hardware_for_arch(
|
||
origami.architecture_t.gfx1200, 32, 128 * 1024, 512 * 1024, 4 * 1024 * 1024, 2700000
|
||
),
|
||
"gfx1201": origami.get_hardware_for_arch(
|
||
origami.architecture_t.gfx1201, 60, 128 * 1024, 512 * 1024, 6 * 1024 * 1024, 2500000
|
||
),
|
||
}
|
||
|
||
|
||
def get_matrix_instructions(
|
||
hardware: origami.hardware_t, dtype: str
|
||
) -> list[tuple[int, int, int]]:
|
||
"""Get valid matrix instructions from hardware for the given dtype."""
|
||
dtype_enum = origami.string_to_datatype(dtype)
|
||
instructions = hardware.get_valid_matrix_instructions(dtype_enum)
|
||
return [(mi.m, mi.n, mi.k) for mi in instructions]
|
||
|
||
|
||
def _generate_mt_pairs(
|
||
mi: tuple[int, int, int],
|
||
mt_sizes: list[int] | None,
|
||
waves: list[list[int]],
|
||
max_mt: int,
|
||
) -> list[tuple[int, int]]:
|
||
"""Generate (mt_m, mt_n) pairs for a given matrix instruction."""
|
||
if mt_sizes is not None:
|
||
return [(mt_m, mt_n) for mt_m in mt_sizes for mt_n in mt_sizes]
|
||
|
||
# Wave-based: MT = MI × wave_tile × wave
|
||
mi_m, mi_n, _ = mi
|
||
min_mt = 16
|
||
pairs = []
|
||
|
||
for wave in waves:
|
||
wave_tile_m = 0
|
||
while True:
|
||
wave_tile_m += 1
|
||
mt_m = mi_m * wave_tile_m * wave[0]
|
||
if mt_m < min_mt:
|
||
continue
|
||
if mt_m > max_mt:
|
||
break
|
||
|
||
wave_tile_n = 0
|
||
while True:
|
||
wave_tile_n += 1
|
||
mt_n = mi_n * wave_tile_n * wave[1]
|
||
if mt_n < min_mt:
|
||
continue
|
||
if mt_n > max_mt:
|
||
break
|
||
pairs.append((mt_m, mt_n))
|
||
|
||
return pairs
|
||
|
||
|
||
def create_config_list(
|
||
hardware: origami.hardware_t,
|
||
dtype: str,
|
||
*,
|
||
mt_sizes: list[int] | None = None,
|
||
depth_unroll: list[int] | None = None,
|
||
occupancy_values: list[int] | None = None,
|
||
wgm_values: list[int] | None = None,
|
||
waves: list[list[int]] | None = None,
|
||
max_mt: int = 512,
|
||
) -> list[origami.config_t]:
|
||
"""Create a list of configurations for testing using dynamic MI discovery."""
|
||
mi_list = get_matrix_instructions(hardware, dtype)
|
||
if not mi_list:
|
||
return []
|
||
|
||
if depth_unroll is None:
|
||
depth_unroll = [16, 32, 64, 128, 256, 512, 1024]
|
||
if occupancy_values is None:
|
||
occupancy_values = [1]
|
||
if wgm_values is None:
|
||
wgm_values = [6]
|
||
if waves is None:
|
||
waves = [[4, 1], [2, 2], [1, 4], [1, 2], [2, 1], [1, 1]]
|
||
|
||
configs = []
|
||
for mi in mi_list:
|
||
mi_m, mi_n, mi_k = mi
|
||
mt_pairs = _generate_mt_pairs(mi, mt_sizes, waves, max_mt)
|
||
|
||
for mt_m, mt_n in mt_pairs:
|
||
for mt_k in depth_unroll:
|
||
for occ in occupancy_values:
|
||
for wgm in wgm_values:
|
||
config = origami.config_t()
|
||
config.mt = origami.dim3_t(mt_m, mt_n, mt_k)
|
||
config.mi = origami.dim3_t(mi_m, mi_n, mi_k)
|
||
config.occupancy = occ
|
||
config.workgroup_mapping = wgm
|
||
configs.append(config)
|
||
|
||
return configs
|