Dateien
rocm-systems/tests/test_analyze_commands.py
T

1673 Zeilen
39 KiB
Python

2022-11-04 14:49:36 -05:00
import os.path
from pathlib import Path
from unittest.mock import patch
import pytest
from importlib.machinery import SourceFileLoader
2024-02-28 11:52:43 -06:00
import shutil
import pandas as pd
2022-11-04 14:49:36 -05:00
omniperf = SourceFileLoader("omniperf", "src/omniperf").load_module()
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
baseline_opts = ["omniperf", "analyze"]
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.misc
2023-10-25 14:09:59 -05:00
def test_valid_path():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
["omniperf", "analyze", "--path", "tests/workloads/vcopy/MI100"],
2022-11-04 14:49:36 -05:00
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
2023-10-25 14:09:59 -05:00
with patch(
"sys.argv",
["omniperf", "analyze", "--path", "tests/workloads/vcopy/MI200"],
2023-10-25 14:09:59 -05:00
):
2022-11-04 14:49:36 -05:00
omniperf.main()
2023-10-25 14:09:59 -05:00
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.misc
2023-10-25 14:09:59 -05:00
def test_list_kernels():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
2023-10-25 14:09:59 -05:00
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--list-stats",
2023-10-25 14:09:59 -05:00
],
):
2022-11-04 14:49:36 -05:00
omniperf.main()
2023-10-25 14:09:59 -05:00
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--list-stats",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.list_metrics
2023-10-25 14:09:59 -05:00
def test_list_metrics_gfx90a():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch("sys.argv", ["omniperf", "analyze", "--list-metrics", "gfx90a"]):
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
2023-10-25 14:09:59 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--list-metrics",
"gfx90a",
],
):
omniperf.main()
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
2023-10-25 14:09:59 -05:00
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--list-metrics",
"gfx90a",
],
):
2022-11-04 14:49:36 -05:00
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.list_metrics
2023-10-25 14:09:59 -05:00
def test_list_metrics_gfx906():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
2023-10-25 14:09:59 -05:00
with patch("sys.argv", ["omniperf", "analyze", "--list-metrics", "gfx906"]):
2022-11-04 14:49:36 -05:00
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--list-metrics",
"gfx906",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--list-metrics",
"gfx906",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.list_metrics
2023-10-25 14:09:59 -05:00
def test_list_metrics_gfx908():
with pytest.raises(SystemExit) as e:
with patch("sys.argv", ["omniperf", "analyze", "--list-metrics", "gfx908"]):
omniperf.main()
assert e.value.code == 1
2023-10-25 14:09:59 -05:00
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--list-metrics",
"gfx908",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--list-metrics",
"gfx908",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
2023-10-25 14:09:59 -05:00
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.filter_metrics
2023-10-25 14:09:59 -05:00
def test_filter_metrics_1():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--metric",
"1",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--metric",
"1",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.filter_metrics
2023-10-25 14:09:59 -05:00
def test_filter_metrics_2():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--metric",
"5",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--metric",
"5",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
2023-10-25 14:09:59 -05:00
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.filter_metrics
2023-10-25 14:09:59 -05:00
def test_filter_metrics_3():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--metric",
"5.2.2",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--metric",
"5.2.2",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.filter_metrics
2023-10-25 14:09:59 -05:00
def test_filter_metrics_4():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--metric",
"6.1",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--metric",
"6.1",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.filter_metrics
2023-10-25 14:09:59 -05:00
def test_filter_metrics_5():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--metric",
"10",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--metric",
"10",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.filter_metrics
2023-10-25 14:09:59 -05:00
def test_filter_metrics_6():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--metric",
"100",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--metric",
"100",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.filter_kernel
2023-10-25 14:09:59 -05:00
def test_filter_kernel_1():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--kernel",
2022-11-04 14:49:36 -05:00
"0",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--kernel",
"0",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.filter_kernel
2023-10-25 14:09:59 -05:00
def test_filter_kernel_2():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--kernel",
"1",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--kernel",
"1",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.filter_kernel
2023-10-25 14:09:59 -05:00
def test_filter_kernel_3():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--kernel",
"0",
"1",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--kernel",
"0",
"1",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.dispatch
2023-10-25 14:09:59 -05:00
def test_dispatch_1():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
2023-10-25 14:09:59 -05:00
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--dispatch",
"0",
],
2022-11-04 14:49:36 -05:00
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
2023-10-25 14:09:59 -05:00
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--dispatch",
"0",
],
):
2022-11-04 14:49:36 -05:00
omniperf.main()
2023-10-25 14:09:59 -05:00
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.dispatch
2023-10-25 14:09:59 -05:00
def test_dispatch_2():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
2023-10-25 14:09:59 -05:00
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--dispatch",
"1",
],
):
2022-11-04 14:49:36 -05:00
omniperf.main()
2023-10-25 14:09:59 -05:00
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--dispatch",
"1",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.dispatch
2023-10-25 14:09:59 -05:00
def test_dispatch_3():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--dispatch",
"2",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--dispatch",
"2",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.dispatch
2023-10-25 14:09:59 -05:00
def test_dispatch_4():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--dispatch",
"1",
"4",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--dispatch",
"1",
"4",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.dispatch
2023-10-25 14:09:59 -05:00
def test_dispatch_5():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--dispatch",
2023-10-25 14:09:59 -05:00
"5",
"6",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--dispatch",
2023-10-25 14:09:59 -05:00
"5",
"6",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 1
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.misc
2023-10-25 14:09:59 -05:00
def test_gpu_ids():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--gpu-id",
"2",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--gpu-id",
"2",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
2023-10-25 14:09:59 -05:00
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.normal_unit
2023-10-25 14:09:59 -05:00
def test_normal_unit_per_wave():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--normal-unit",
"per_wave",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--normal-unit",
"per_wave",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.normal_unit
2023-10-25 14:09:59 -05:00
def test_normal_unit_per_cycle():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--normal-unit",
"per_cycle",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--normal-unit",
"per_cycle",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.normal_unit
2023-10-25 14:09:59 -05:00
def test_normal_unit_per_second():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--normal-unit",
"per_second",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--normal-unit",
"per_second",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.normal_unit
2023-10-25 14:09:59 -05:00
def test_normal_unit_per_kernel():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--normal-unit",
"per_kernel",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--normal-unit",
"per_kernel",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
2023-10-25 14:09:59 -05:00
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
@pytest.mark.max_stat
def test_max_stat_num_1():
2023-10-25 14:09:59 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--max-stat-num",
2023-10-25 14:09:59 -05:00
"0",
],
):
omniperf.main()
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--max-stat-num",
2023-10-25 14:09:59 -05:00
"0",
2022-11-04 14:49:36 -05:00
],
):
omniperf.main()
2023-10-25 14:09:59 -05:00
assert e.value.code == 0
2022-11-04 14:49:36 -05:00
@pytest.mark.max_stat
def test_max_stat_num_2():
2022-11-04 14:49:36 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--max-stat-num",
2023-10-25 14:09:59 -05:00
"5",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--max-stat-num",
2023-10-25 14:09:59 -05:00
"5",
],
):
omniperf.main()
assert e.value.code == 0
@pytest.mark.max_stat
def test_max_stat_num_3():
2023-10-25 14:09:59 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--max-stat-num",
2023-10-25 14:09:59 -05:00
"10",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--max-stat-num",
2023-10-25 14:09:59 -05:00
"10",
],
):
omniperf.main()
assert e.value.code == 0
@pytest.mark.max_stat
def test_max_stat_num_4():
2023-10-25 14:09:59 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--max-stat-num",
2023-10-25 14:09:59 -05:00
"15",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--max-stat-num",
2023-10-25 14:09:59 -05:00
"15",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.time_unit
2023-10-25 14:09:59 -05:00
def test_time_unit_s():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--time-unit",
"s",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--time-unit",
"s",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.time_unit
2023-10-25 14:09:59 -05:00
def test_time_unit_ms():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--time-unit",
"ms",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--time-unit",
"ms",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.time_unit
2023-10-25 14:09:59 -05:00
def test_time_unit_us():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--time-unit",
"us",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--time-unit",
"us",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.time_unit
2023-10-25 14:09:59 -05:00
def test_time_unit_ns():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--time-unit",
"ns",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--time-unit",
"ns",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.decimal
2023-10-25 14:09:59 -05:00
def test_decimal_1():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--decimal",
"0",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--decimal",
"0",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.decimal
2023-10-25 14:09:59 -05:00
def test_decimal_2():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--decimal",
"1",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--decimal",
"1",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.decimal
2023-10-25 14:09:59 -05:00
def test_decimal_3():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--decimal",
"4",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--decimal",
"4",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.misc
2023-10-25 14:09:59 -05:00
def test_save_dfs():
2024-02-28 11:52:43 -06:00
output_path = "tests/workloads/vcopy/saved_analysis"
2023-10-25 14:09:59 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--save-dfs",
2024-02-28 11:52:43 -06:00
output_path,
2023-10-25 14:09:59 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--save-dfs",
2024-02-28 11:52:43 -06:00
output_path,
2023-10-25 14:09:59 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-28 11:52:43 -06:00
files_in_workload = os.listdir(output_path)
single_row_tables = [
"0.1_Top_Kernels.csv",
"13.3_Instruction_Cache_-_L2_Interface.csv",
"18.1_Aggregate_Stats_(All_32_channels).csv",
]
for file_name in files_in_workload:
df = pd.read_csv(output_path + "/" + file_name)
if file_name in single_row_tables:
assert len(df.index) == 1
else:
assert len(df.index) >= 3
shutil.rmtree(output_path)
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--save-dfs",
output_path,
],
):
omniperf.main()
assert e.value.code == 0
files_in_workload = os.listdir(output_path)
for file_name in files_in_workload:
df = pd.read_csv(output_path + "/" + file_name)
if file_name in single_row_tables:
assert len(df.index) == 1
else:
assert len(df.index) >= 3
2023-10-25 14:09:59 -05:00
2024-02-07 12:52:44 -06:00
@pytest.mark.col
2023-10-25 14:09:59 -05:00
def test_col_1():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--cols",
"0",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--cols",
"0",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.col
2023-10-25 14:09:59 -05:00
def test_col_2():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--cols",
"2",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--cols",
"2",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.col
2023-10-25 14:09:59 -05:00
def test_col_3():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--cols",
"0",
"2",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--cols",
"0",
"2",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.misc
2023-10-25 14:09:59 -05:00
def test_g():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"-g",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"-g",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.kernel_verbose
2023-10-25 14:09:59 -05:00
def test_kernel_verbose_0():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"0",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"0",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.kernel_verbose
2023-10-25 14:09:59 -05:00
def test_kernel_verbose_1():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"1",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"1",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.kernel_verbose
2023-10-25 14:09:59 -05:00
def test_kernel_verbose_2():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"2",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"2",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.kernel_verbose
2023-10-25 14:09:59 -05:00
def test_kernel_verbose_3():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"3",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"3",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.kernel_verbose
2023-10-25 14:09:59 -05:00
def test_kernel_verbose_4():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"4",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"4",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.kernel_verbose
2023-10-25 14:09:59 -05:00
def test_kernel_verbose_5():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"5",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"5",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.kernel_verbose
2023-10-25 14:09:59 -05:00
def test_kernel_verbose_6():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"6",
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
"--kernel-verbose",
2023-10-25 14:09:59 -05:00
"6",
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.misc
2023-10-25 14:09:59 -05:00
def test_baseline():
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
"--path",
"tests/workloads/vcopy/MI200",
2023-10-25 14:09:59 -05:00
],
):
omniperf.main()
assert e.value.code == 0
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
"--path",
"tests/workloads/vcopy/MI100",
2023-10-25 14:09:59 -05:00
],
):
omniperf.main()
assert e.value.code == 0
2024-02-07 12:52:44 -06:00
@pytest.mark.misc
def test_dependency_MI100():
2023-10-25 14:09:59 -05:00
with pytest.raises(SystemExit) as e:
with patch(
"sys.argv",
[
"omniperf",
"analyze",
"--path",
"tests/workloads/vcopy/MI100",
2022-11-04 14:49:36 -05:00
"--dependency",
],
):
omniperf.main()
assert e.value.code == 0