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
33 changes: 33 additions & 0 deletions test/therock/hipdnn_install_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

cmake_minimum_required(VERSION 3.25)
project(hipdnn_install_tests LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)

enable_testing()

function(add_hipdnn_install_test)
cmake_parse_arguments(ARG "" "PACKAGE;HEADER" "" ${ARGN})

find_package(${ARG_PACKAGE} CONFIG REQUIRED)
message(STATUS "${ARG_PACKAGE} found")

set(test_name "test_${ARG_PACKAGE}")
set(header "${ARG_HEADER}")
set(pkg_name "${ARG_PACKAGE}")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/test_template.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/${test_name}.cpp"
@ONLY
)
add_executable(${test_name} "${CMAKE_CURRENT_BINARY_DIR}/${test_name}.cpp")
target_link_libraries(${test_name} PRIVATE ${ARG_PACKAGE})
add_test(NAME ${test_name} COMMAND ${test_name})
endfunction()

add_hipdnn_install_test(PACKAGE hipdnn_backend HEADER hipdnn_backend.h)
add_hipdnn_install_test(PACKAGE hipdnn_data_sdk HEADER hipdnn_data_sdk/data_objects/graph_generated.h)
add_hipdnn_install_test(PACKAGE hipdnn_frontend HEADER hipdnn_frontend.hpp)
add_hipdnn_install_test(PACKAGE hipdnn_plugin_sdk HEADER hipdnn_plugin_sdk/PluginApi.h)
add_hipdnn_install_test(PACKAGE hipdnn_test_sdk HEADER hipdnn_test_sdk/utilities/Seeds.hpp)
10 changes: 10 additions & 0 deletions test/therock/hipdnn_install_tests/test_template.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#include <@header@>
#include <iostream>

int main() {
std::cout << "@pkg_name@: package found and linked successfully" << std::endl;
return 0;
}
60 changes: 60 additions & 0 deletions test/therock/test_hipblas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

import logging
import os
import shlex
import subprocess
import sys
from pathlib import Path

THEROCK_BIN_DIR = os.getenv("THEROCK_BIN_DIR")
SCRIPT_DIR = Path(__file__).resolve().parent
THEROCK_DIR = SCRIPT_DIR.parent.parent.parent

# Importing is_asan from github_actions_api.py
sys.path.append(str(THEROCK_DIR / "build_tools" / "github_actions"))
from github_actions_api import is_asan

# GTest sharding
SHARD_INDEX = os.getenv("SHARD_INDEX", 1)
TOTAL_SHARDS = os.getenv("TOTAL_SHARDS", 1)
environ_vars = os.environ.copy()
# For display purposes in the GitHub Action UI, the shard array is 1th indexed. However for shard indexes, we convert it to 0th index.
environ_vars["GTEST_SHARD_INDEX"] = str(int(SHARD_INDEX) - 1)
environ_vars["GTEST_TOTAL_SHARDS"] = str(TOTAL_SHARDS)

if is_asan():
environ_vars["HSA_XNACK"] = "1"

logging.basicConfig(level=logging.INFO)

tests_to_exclude = [
"*known_bug*",
"_/getrs*",
"_/getri_batched.solver*",
"_/gels_batched.solver*",
]

exclusion_list = ":".join(tests_to_exclude)

cmd = [
f"{THEROCK_BIN_DIR}/hipblas-test",
]

# If quick tests are enabled, we run quick tests only.
# Otherwise, we run the normal test suite
test_type = os.getenv("TEST_TYPE", "full")
if test_type == "quick":
cmd += [
"--yaml",
f"{THEROCK_BIN_DIR}/hipblas_smoke.yaml",
f"--gtest_filter=-{exclusion_list}",
]
else:
# TODO(#2616): Enable full tests once known machine issues are resolved
cmd += [f"--gtest_filter=*pre_checkin*-{exclusion_list}"]


logging.info(f"++ Exec [{THEROCK_DIR}]$ {shlex.join(cmd)}")
result = subprocess.run(cmd, cwd=THEROCK_DIR, env=environ_vars)
52 changes: 52 additions & 0 deletions test/therock/test_hipblaslt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

import logging
import os
import shlex
import subprocess
import sys
from pathlib import Path

THEROCK_BIN_DIR = os.getenv("THEROCK_BIN_DIR")
AMDGPU_FAMILIES = os.getenv("AMDGPU_FAMILIES")
platform = os.getenv("RUNNER_OS").lower()
SCRIPT_DIR = Path(__file__).resolve().parent
THEROCK_DIR = SCRIPT_DIR.parent.parent.parent

# Importing is_asan from github_actions_api.py
sys.path.append(str(THEROCK_DIR / "build_tools" / "github_actions"))
from github_actions_api import is_asan

logging.basicConfig(level=logging.INFO)

# GTest sharding
SHARD_INDEX = os.getenv("SHARD_INDEX", 1)
TOTAL_SHARDS = os.getenv("TOTAL_SHARDS", 1)
environ_vars = os.environ.copy()
# For display purposes in the GitHub Action UI, the shard array is 1th indexed. However for shard indexes, we convert it to 0th index.
environ_vars["GTEST_SHARD_INDEX"] = str(int(SHARD_INDEX) - 1)
environ_vars["GTEST_TOTAL_SHARDS"] = str(TOTAL_SHARDS)

if is_asan():
environ_vars["HSA_XNACK"] = "1"
environ_vars["OMP_NUM_THREADS"] = "1"

# If quick tests are enabled, we run quick tests only.
# Otherwise, we run the normal test suite
test_type = os.getenv("TEST_TYPE", "full")

# Only run quick tests (less memory intensive) for Windows strix-halo, issue: https://github.com/ROCm/TheRock/issues/1750
if AMDGPU_FAMILIES == "gfx1151" and platform == "windows":
test_type = "quick"

test_filter = []
if test_type == "quick":
test_filter.append("--gtest_filter=*smoke*")
elif test_type == "quick":
test_filter.append("--gtest_filter=*quick*")

cmd = [f"{THEROCK_BIN_DIR}/hipblaslt-test"] + test_filter

logging.info(f"++ Exec [{THEROCK_DIR}]$ {shlex.join(cmd)}")
subprocess.run(cmd, cwd=THEROCK_DIR, check=True, env=environ_vars)
118 changes: 118 additions & 0 deletions test/therock/test_hipcub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

import logging
import os
import shlex
import subprocess
import platform
from pathlib import Path

THEROCK_BIN_DIR = os.getenv("THEROCK_BIN_DIR")
SCRIPT_DIR = Path(__file__).resolve().parent
THEROCK_DIR = SCRIPT_DIR.parent.parent.parent

logging.basicConfig(level=logging.INFO)

QUICK_TESTS = [
"*ShuffleTests/*.*",
"*WarpStoreTest/*.*",
"AdjacentDifference/*.*",
"AdjacentDifferenceSubtract/*.*",
"BatchCopyTests/*.*",
"BatchMemcpyTests/*.*",
"BlockScan*",
"DeviceScanTests/*.*",
"Discontinuity/*.*",
"DivisionOperatorTests/*.*",
"ExchangeTests",
"GridTests/*.*",
"HistogramEven/*.*",
"HistogramInputArrayTests/*.*",
"HistogramRange/*.*",
"IteratorTests/*.*",
"LoadStoreTestsDirect/*.*",
"LoadStoreTestsStriped/*.*",
"LoadStoreTestsTranspose/*.*",
"LoadStoreTestsVectorize/*.*",
"MergeSort/*.*",
"NCThreadOperatorsTests/*",
"RadixRank/*.*",
"RadixSort/*.*",
"ReduceArgMinMaxSpecialTests/*.*",
"ReduceInputArrayTests/*.*",
"ReduceLargeIndicesTests/*.*",
"ReduceSingleValueTests/*.*",
"ReduceTests/*.*",
"RunLengthDecodeTest/*.*",
"RunLengthEncode/*.*",
"SegmentedReduce/*.*",
"SegmentedReduceArgMinMaxSpecialTests/*.*",
"SegmentedReduceOp/*.*",
"SelectTests/*.*",
"ThreadOperationTests/*.*",
"ThreadOperatorsTests/*.*",
"UtilPtxTests/*.*",
"WarpExchangeTest/*.*",
"WarpLoadTest/*.*",
"WarpMergeSort/*.*",
"WarpReduceTests/*.*",
"WarpScanTests*",
]

# Generate the resource spec file for ctest
rocm_base = Path(THEROCK_BIN_DIR).resolve().parent
ld_paths = [
rocm_base / "lib",
]
ld_paths_str = os.pathsep.join(str(p) for p in ld_paths)
existing_path = os.environ.get("PATH", "")
existing_ld_path = os.environ.get("LD_LIBRARY_PATH", "")
env_vars = os.environ.copy()
env_vars["PATH"] = (
f"{THEROCK_BIN_DIR}{os.pathsep}{existing_path}"
if existing_path
else THEROCK_BIN_DIR
)
env_vars["ROCM_PATH"] = str(rocm_base)
env_vars["LD_LIBRARY_PATH"] = (
f"{ld_paths_str}{os.pathsep}{existing_ld_path}"
if existing_ld_path
else ld_paths_str
)

is_windows = platform.system() == "Windows"
exe_name = "generate_resource_spec.exe" if is_windows else "generate_resource_spec"
exe_dir = rocm_base / "bin" / "hipcub"
resource_spec_file = "resources.json"

res_gen_cmd = [
str(exe_dir / exe_name),
str(exe_dir / resource_spec_file),
]
logging.info(f"++ Exec [{THEROCK_DIR}]$ {shlex.join(res_gen_cmd)}")
subprocess.run(res_gen_cmd, cwd=THEROCK_DIR, check=True, env=env_vars)

# Run ctest with resource spec file
cmd = [
"ctest",
"--test-dir",
f"{THEROCK_BIN_DIR}/hipcub",
"--output-on-failure",
"--parallel",
"8",
"--resource-spec-file",
resource_spec_file,
"--timeout",
"300",
]

# If quick tests are enabled, we run quick tests only.
# Otherwise, we run the normal test suite
environ_vars = os.environ.copy()
test_type = os.getenv("TEST_TYPE", "full")
if test_type == "quick":
environ_vars["GTEST_FILTER"] = ":".join(QUICK_TESTS)

logging.info(f"++ Exec [{THEROCK_DIR}]$ {shlex.join(cmd)}")
subprocess.run(cmd, cwd=THEROCK_DIR, check=True, env=environ_vars)
34 changes: 34 additions & 0 deletions test/therock/test_hipdnn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

import logging
import os
import shlex
import subprocess
from pathlib import Path

THEROCK_BIN_DIR = os.getenv("THEROCK_BIN_DIR")
SCRIPT_DIR = Path(__file__).resolve().parent
THEROCK_DIR = SCRIPT_DIR.parent.parent.parent
AMDGPU_FAMILIES = os.getenv("AMDGPU_FAMILIES")

logging.basicConfig(level=logging.INFO)

cmd = [
"ctest",
"--test-dir",
f"{THEROCK_BIN_DIR}/hipdnn",
"--output-on-failure",
"--parallel",
"8",
"--timeout",
"60",
]

logging.info(f"++ Exec [{THEROCK_DIR}]$ {shlex.join(cmd)}")

subprocess.run(
cmd,
cwd=THEROCK_DIR,
check=True,
)
Loading
Loading