Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ add_subdirectory(lib)
# C API needs all dialects for registration, but should be built before tests.
add_subdirectory(lib/CAPI)

# Process utils before test so that targets defined there (e.g.
# ci-performance-scripts, which copies performance scripts onto the lit PATH)
# exist when the test suite registers its build dependencies.
add_subdirectory(utils)

if (MLIR_INCLUDE_TESTS)
add_definitions(-DMLIR_INCLUDE_TESTS)
add_custom_target(RocMLIRUnitTests)
Expand All @@ -64,4 +69,3 @@ if (MLIR_INCLUDE_TESTS)
add_subdirectory(test)
endif()
add_subdirectory(tools)
add_subdirectory(utils)
7 changes: 7 additions & 0 deletions mlir/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ if (TARGET amd_arch_db)
list(APPEND ROCMLIR_TEST_DEPENDS amd_arch_db)
endif()

# Performance scripts (e.g. tuningRunner.py) are copied into ROCMLIR_BIN_DIR,
# which is on the lit PATH, by the ci-performance-scripts target. Tests that
# invoke these scripts directly need them copied before the test suite runs.
if (TARGET ci-performance-scripts)
list(APPEND ROCMLIR_TEST_DEPENDS ci-performance-scripts)
endif()

if(MLIR_ENABLE_ROCM_RUNNER)
list(APPEND ROCMLIR_TEST_DEPENDS
mlir_runner_utils
Expand Down
17 changes: 17 additions & 0 deletions mlir/test/perf-scripts/runtime/tuningRunner-gemm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Using a tiny GEMM with --debug-quick-tune-data. This emits a `.debug`
# TSV of the per-config table entries (PerfConfig + TFlops) but, unlike the
# full ``--debug`` flag, omits the heavy per-iteration ``MeasurementsMs``
# arrays. Verify the debug file is produced, has the expected header and
# per-config rows, and that the measurements column is absent.
#
# tuningRunner.py drives real GPU tuning, so it needs the ROCm runner / GPU
# runtime.
# REQUIRES: rocm-runner
# RUN: rm -f %t2.tsv %t2.tsv.state %t2.tsv.debug
# RUN: tuningRunner.py --op gemm --tuning-space=quick --debug-quick-tune-data \
# RUN: --config='-g 1 -m 64 -n 64 -k 64 -t f32 -out_datatype f32 -transA 0 -transB 0' \
# RUN: -q -o %t2.tsv
# RUN: FileCheck %s --check-prefix=DEBUG --implicit-check-not=MeasurementsMs < %t2.tsv.debug
#
# DEBUG: PerfConfig{{.*}}TFlops
# DEBUG: {{v[0-9]+:}}
2 changes: 2 additions & 0 deletions mlir/utils/performance/tests/test_tuningRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def _options(self, output_path, arch="gfx900", num_cu=64, num_chiplets=1, tuning
num_cu=num_cu,
num_chiplets=num_chiplets,
debug=False,
debug_quick_tune_data=False,
quiet=False,
verbose=False,
tuning_space_kind=tuning_space,
Expand Down Expand Up @@ -452,6 +453,7 @@ def test_cache_loaded_with_canonical_key(self):
num_cu=64,
num_chiplets=1,
debug=False,
debug_quick_tune_data=False,
quiet=False,
verbose=False,
tuning_space_kind="full",
Expand Down
15 changes: 12 additions & 3 deletions mlir/utils/performance/tuningRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def get_gpu_logger(gpu_id: int) -> logging.LoggerAdapter:
class Options:
"""Configuration options for the tuning process."""
debug: bool
debug_quick_tune_data: bool
Comment thread
erizheng-amd marked this conversation as resolved.
tuning_space_kind: str
quiet: bool
verbose: bool
Expand Down Expand Up @@ -1640,8 +1641,9 @@ def tune_configs(ctx: TuningContext, status_only: bool) -> bool:

has_errors = False

debug_enabled = ctx.options.debug and ctx.options.output != '-'
if ctx.options.debug and not debug_enabled:
debug_requested = ctx.options.debug or ctx.options.debug_quick_tune_data
debug_enabled = debug_requested and ctx.options.output != '-'
if debug_requested and not debug_enabled:
logger.warning("Debug output disabled when writing to stdout")

with (OutputFileWriter(ctx.options.output, ctx.options) as results_writer,
Expand Down Expand Up @@ -1939,7 +1941,13 @@ def parse_arguments(gpu_topology: GpuTopology,
"--debug",
action='store_true',
default=False,
help="Enable debug output including detailed measurements")
help="Enable debug output including detailed per-iteration measurements")

parser.add_argument("--debug-quick-tune-data",
action='store_true',
default=False,
help="Enable debug output for quick tuning data generation without the "
"detailed per-iteration measurement arrays")

parser.add_argument("--tuning-space",
default="full",
Expand Down Expand Up @@ -2125,6 +2133,7 @@ def main(args=None):
num_cu=num_cu,
num_chiplets=num_chiplets,
debug=parsed_args.debug,
debug_quick_tune_data=parsed_args.debug_quick_tune_data,
quiet=parsed_args.quiet,
verbose=parsed_args.verbose,
tuning_space_kind=parsed_args.tuning_space,
Expand Down
Loading