Skip to content

Commit

Permalink
merge with upstream/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
BuiChiTrung committed Aug 29, 2024
2 parents 446322c + 774b1b8 commit 76499d4
Show file tree
Hide file tree
Showing 39 changed files with 495 additions and 388 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def cmake_build(Map conf=[:]){
def package_build = (conf.get("package_build","") == "true")

if (package_build == true) {
make_targets = "miopen_gtest package"
make_targets = "miopen_gtest package miopen_gtest_check"
setup_args = " -DMIOPEN_TEST_DISCRETE=OFF " + setup_args
}

Expand Down Expand Up @@ -557,7 +557,7 @@ pipeline {
NOMLIR_flags = " -DMIOPEN_USE_MLIR=Off"
}
triggers{

cron(env.BRANCH_NAME == env.NIGHTLY_BRANCH ? env.NIGHTLY_SCHEDULE : '')
}
stages{
Expand Down
16 changes: 15 additions & 1 deletion test/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function(add_gtest TEST_NAME TEST_CPP)
if(hipblaslt_FOUND)
target_link_libraries( ${TEST_NAME} roc::hipblaslt )
endif()
# Workaround : change in rocm-cmake was causing linking error so had to add ${CMAKE_DL_LIBS}
# Workaround : change in rocm-cmake was causing linking error so had to add ${CMAKE_DL_LIBS}
# We can remove ${CMAKE_DL_LIBS} once root cause is identified.
target_link_libraries(${TEST_NAME} ${CMAKE_DL_LIBS} GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $<BUILD_INTERFACE:roc::rocblas> )
if(NOT MIOPEN_EMBED_DB STREQUAL "")
Expand Down Expand Up @@ -107,6 +107,20 @@ else()

add_gtest(miopen_gtest "${TESTS_CPP}")

add_custom_command(
OUTPUT test_list
COMMAND miopen_gtest --gtest_list_tests > test_list
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/check_names.py --list test_list
DEPENDS miopen_gtest ${CMAKE_CURRENT_SOURCE_DIR}/check_names.py
COMMENT "Checking test names"
VERBATIM
)

add_custom_target(
miopen_gtest_check
DEPENDS test_list
)

if( NOT ENABLE_ASAN_PACKAGING )
install(TARGETS miopen_gtest
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
Expand Down
110 changes: 110 additions & 0 deletions test/gtest/check_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/usr/bin/env python3
###############################################################################
#
# MIT License
#
# Copyright (c) 2024 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#################################################################################

"""gtest name linter"""
import re
import sys
import argparse
from collections import defaultdict
import logging

logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger("GTest name checker")

"""regexp based on https://github.com/ROCm/MIOpen/wiki/GTest-development#naming"""
re_prefix = re.compile(r"^((Smoke)|(Full)|(Perf)|(Unit.*))$")
re_hw = re.compile(r"^((CPU)|(GPU))$")
re_datatype = re.compile(
r"^((FP((8)|(16)|(32)|(64)))|(BFP((8)|(16)))|(I((8)|(32)))|(NONE))\.$"
)


def parse_args():
"""Function to parse cmd line arguments"""
parser = argparse.ArgumentParser()

parser.add_argument(
"--list",
dest="list",
type=str,
required=True,
help="Specify gtest test list file",
)
args = parser.parse_args()

return args


def parse_tests(args):

mismatches = defaultdict(str)

with open(args.list) as fp:
for line in fp.readlines()[2:]:
if not line.strip():
continue
if line[0] == " ":
continue
line = line.split("#")[0].strip()

full_name = line.split("/")

if len(full_name) == 2:
prefix = re.search(re_prefix, full_name[0])
name = full_name[1].split("_")
else:
prefix = ["empty"]
name = full_name[0].split("_")

hw = re.search(re_hw, name[0])
datatype = re.search(re_datatype, name[-1])
if not prefix:
mismatches[line] += " Prefix"
if not hw:
mismatches[line] += " Hw"
if not datatype:
mismatches[line] += " Datatype"

for l, k in mismatches.items():
logger.warning("Name: " + l + " Mismatch types:" + k)

if mismatches:
logger.critical(
"Tests do not match to the test naming scheme (see https://github.com/ROCm/MIOpen/wiki/GTest-development#naming )"
)
# return -1 # uncomment when all the tests will be renamed
return 0


def main():
"""Main function"""
args = parse_args()
return parse_tests(args)


if __name__ == "__main__":
sys.exit(main())
66 changes: 28 additions & 38 deletions test/gtest/hipblaslt_gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,39 +85,39 @@ static std::vector<TestCase> GetTestCases()
{false, 32, 64, 128, false, true, 1.0f, 1.0f, 10}};
}

class HipBLASLtGEMMTestFloat : public testing::TestWithParam<TestCase>
class GPU_HipBLASLtGEMMTest_FP32 : public testing::TestWithParam<TestCase>
{
};

class HipBLASLtGEMMTestHalf : public testing::TestWithParam<TestCase>
class GPU_HipBLASLtGEMMTest_FP16 : public testing::TestWithParam<TestCase>
{
};

class HipBLASLtGEMMTestBFloat16 : public testing::TestWithParam<TestCase>
class GPU_HipBLASLtGEMMTest_BFP16 : public testing::TestWithParam<TestCase>
{
};

class HipBLASLtGEMMTestFloat8 : public testing::TestWithParam<TestCase>
class GPU_HipBLASLtGEMMTest_FP8 : public testing::TestWithParam<TestCase>
{
};

class HipBLASLtGEMMTestBFloat8 : public testing::TestWithParam<TestCase>
class GPU_HipBLASLtGEMMTest_BFP8 : public testing::TestWithParam<TestCase>
{
};

class HipBLASLtGEMMTestInt64 : public testing::Test
class GPU_HipBLASLtGEMMTest_I64 : public testing::Test
{
};

class HipBLASLtGEMMTestInt : public testing::Test
class GPU_HipBLASLtGEMMTest_I32 : public testing::Test
{
};

class HipBLASLtGEMMTestInt8 : public testing::Test
class GPU_HipBLASLtGEMMTest_I8 : public testing::Test
{
};

class HipBLASLtGEMMTestDouble : public testing::Test
class GPU_HipBLASLtGEMMTest_FP64 : public testing::Test
{
};

Expand Down Expand Up @@ -289,73 +289,65 @@ static void CheckExceptionsWithSkip(miopenDataType_t dataType)
} // namespace hipblaslt_gemm
using namespace hipblaslt_gemm;

TEST_F(HipBLASLtGEMMTestFloat, CheckHipBLASLtGEMMException)
TEST_F(GPU_HipBLASLtGEMMTest_FP32, CheckHipBLASLtGEMMException)
{
using e_mask = enabled<Gpu::gfx94X, Gpu::gfx90A, Gpu::gfx110X>;
using d_mask = disabled<Gpu::gfx103X, Gpu::gfx900, Gpu::gfx906, Gpu::gfx908>;
CheckExceptionsWithSkip<float, d_mask, e_mask>(miopenDataType_t::miopenFloat);
};
TEST_P(HipBLASLtGEMMTestFloat, RunHipBLASLtGEMM)
TEST_P(GPU_HipBLASLtGEMMTest_FP32, RunHipBLASLtGEMM)
{
using e_mask = enabled<Gpu::gfx94X, Gpu::gfx90A, Gpu::gfx110X>;
using d_mask = disabled<Gpu::gfx103X, Gpu::gfx900, Gpu::gfx906, Gpu::gfx908>;
RunGemmDescriptors<float, d_mask, e_mask>(GetParam(), miopenDataType_t::miopenFloat);
};
INSTANTIATE_TEST_SUITE_P(HipBLASLtGEMMTestSet,
HipBLASLtGEMMTestFloat,
testing::ValuesIn(GetTestCases()));
INSTANTIATE_TEST_SUITE_P(Full, GPU_HipBLASLtGEMMTest_FP32, testing::ValuesIn(GetTestCases()));

TEST_F(HipBLASLtGEMMTestHalf, CheckHipBLASLtGEMMException)
TEST_F(GPU_HipBLASLtGEMMTest_FP16, CheckHipBLASLtGEMMException)
{
using e_mask = enabled<Gpu::gfx94X, Gpu::gfx90A, Gpu::gfx110X>;
using d_mask = disabled<Gpu::gfx103X, Gpu::gfx900, Gpu::gfx906, Gpu::gfx908>;
CheckExceptionsWithSkip<float16, d_mask, e_mask>(miopenDataType_t::miopenHalf);
};
TEST_P(HipBLASLtGEMMTestHalf, RunHipBLASLtGEMM)
TEST_P(GPU_HipBLASLtGEMMTest_FP16, RunHipBLASLtGEMM)
{
using e_mask = enabled<Gpu::gfx94X, Gpu::gfx90A, Gpu::gfx110X>;
using d_mask = disabled<Gpu::gfx103X, Gpu::gfx900, Gpu::gfx906, Gpu::gfx908>;
RunGemmDescriptors<float16, d_mask, e_mask>(GetParam(), miopenDataType_t::miopenHalf);
};
INSTANTIATE_TEST_SUITE_P(HipBLASLtGEMMTestSet,
HipBLASLtGEMMTestHalf,
testing::ValuesIn(GetTestCases()));
INSTANTIATE_TEST_SUITE_P(Full, GPU_HipBLASLtGEMMTest_FP16, testing::ValuesIn(GetTestCases()));

TEST_F(HipBLASLtGEMMTestBFloat16, CheckHipBLASLtGEMMException)
TEST_F(GPU_HipBLASLtGEMMTest_BFP16, CheckHipBLASLtGEMMException)
{
using e_mask = enabled<Gpu::gfx94X, Gpu::gfx90A, Gpu::gfx110X>;
using d_mask = disabled<Gpu::gfx103X, Gpu::gfx900, Gpu::gfx906, Gpu::gfx908>;
CheckExceptionsWithSkip<bfloat16, d_mask, e_mask>(miopenDataType_t::miopenBFloat16);
};
TEST_P(HipBLASLtGEMMTestBFloat16, RunHipBLASLtGEMM)
TEST_P(GPU_HipBLASLtGEMMTest_BFP16, RunHipBLASLtGEMM)
{
using e_mask = enabled<Gpu::gfx94X, Gpu::gfx90A, Gpu::gfx110X>;
using d_mask = disabled<Gpu::gfx103X, Gpu::gfx900, Gpu::gfx906, Gpu::gfx908>;
RunGemmDescriptors<bfloat16, d_mask, e_mask>(GetParam(), miopenDataType_t::miopenBFloat16);
};
INSTANTIATE_TEST_SUITE_P(HipBLASLtGEMMTestSet,
HipBLASLtGEMMTestBFloat16,
testing::ValuesIn(GetTestCases()));
INSTANTIATE_TEST_SUITE_P(Full, GPU_HipBLASLtGEMMTest_BFP16, testing::ValuesIn(GetTestCases()));

TEST_F(HipBLASLtGEMMTestFloat8, CheckHipBLASLtGEMMException)
TEST_F(GPU_HipBLASLtGEMMTest_FP8, CheckHipBLASLtGEMMException)
{
using e_mask = enabled<Gpu::gfx94X>;
using d_mask =
disabled<Gpu::gfx103X, Gpu::gfx900, Gpu::gfx906, Gpu::gfx908, Gpu::gfx90A, Gpu::gfx110X>;
CheckExceptionsWithSkip<float8, d_mask, e_mask>(miopenDataType_t::miopenFloat8);
};
TEST_P(HipBLASLtGEMMTestFloat8, RunHipBLASLtGEMM)
TEST_P(GPU_HipBLASLtGEMMTest_FP8, RunHipBLASLtGEMM)
{
using e_mask = enabled<Gpu::gfx94X>;
using d_mask =
disabled<Gpu::gfx103X, Gpu::gfx900, Gpu::gfx906, Gpu::gfx908, Gpu::gfx90A, Gpu::gfx110X>;
RunGemmDescriptors<float8, d_mask, e_mask>(GetParam(), miopenDataType_t::miopenFloat8);
};
INSTANTIATE_TEST_SUITE_P(HipBLASLtGEMMTestSet,
HipBLASLtGEMMTestFloat8,
testing::ValuesIn(GetTestCases()));
INSTANTIATE_TEST_SUITE_P(Full, GPU_HipBLASLtGEMMTest_FP8, testing::ValuesIn(GetTestCases()));

TEST_F(HipBLASLtGEMMTestBFloat8, CheckHipBLASLtGEMMException)
TEST_F(GPU_HipBLASLtGEMMTest_BFP8, CheckHipBLASLtGEMMException)
{
#ifdef ENABLE_HIPBLASLT_BF8
using e_mask = enabled<Gpu::gfx94X>;
Expand All @@ -366,7 +358,7 @@ TEST_F(HipBLASLtGEMMTestBFloat8, CheckHipBLASLtGEMMException)
CheckExceptions<bfloat8>(miopenDataType_t::miopenInt64);
#endif
};
TEST_P(HipBLASLtGEMMTestBFloat8, RunHipBLASLtGEMM)
TEST_P(GPU_HipBLASLtGEMMTest_BFP8, RunHipBLASLtGEMM)
{
#ifdef ENABLE_HIPBLASLT_BF8
using e_mask = enabled<Gpu::gfx94X>;
Expand All @@ -377,26 +369,24 @@ TEST_P(HipBLASLtGEMMTestBFloat8, RunHipBLASLtGEMM)
GTEST_SKIP();
#endif
};
INSTANTIATE_TEST_SUITE_P(HipBLASLtGEMMTestSet,
HipBLASLtGEMMTestBFloat8,
testing::ValuesIn(GetTestCases()));
INSTANTIATE_TEST_SUITE_P(Full, GPU_HipBLASLtGEMMTest_BFP8, testing::ValuesIn(GetTestCases()));

TEST_F(HipBLASLtGEMMTestInt64, CheckHipBLASLtGEMMException)
TEST_F(GPU_HipBLASLtGEMMTest_I64, CheckHipBLASLtGEMMException)
{
CheckExceptions<int64_t>(miopenDataType_t::miopenInt64);
};

TEST_F(HipBLASLtGEMMTestInt, CheckHipBLASLtGEMMException)
TEST_F(GPU_HipBLASLtGEMMTest_I32, CheckHipBLASLtGEMMException)
{
CheckExceptions<int>(miopenDataType_t::miopenInt32);
};

TEST_F(HipBLASLtGEMMTestInt8, CheckHipBLASLtGEMMException)
TEST_F(GPU_HipBLASLtGEMMTest_I8, CheckHipBLASLtGEMMException)
{
CheckExceptions<int8_t>(miopenDataType_t::miopenInt8);
};

TEST_F(HipBLASLtGEMMTestDouble, CheckHipBLASLtGEMMException)
TEST_F(GPU_HipBLASLtGEMMTest_FP64, CheckHipBLASLtGEMMException)
{
CheckExceptions<double>(miopenDataType_t::miopenDouble);
};
Expand Down
Loading

0 comments on commit 76499d4

Please sign in to comment.