diff --git a/gtestsuite/testsuite/level1/subv/csubv_generic.cpp b/gtestsuite/testsuite/level1/subv/csubv_generic.cpp index 70797d5e5..300b400d3 100644 --- a/gtestsuite/testsuite/level1/subv/csubv_generic.cpp +++ b/gtestsuite/testsuite/level1/subv/csubv_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -36,11 +36,12 @@ #include "test_subv.h" class csubvGenericTest : + // input params: x or conj(x), vector length, stride size of x, stride size of y public ::testing::TestWithParam> {}; GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(csubvGenericTest); -TEST_P( csubvGenericTest, RandomData ) +TEST_P( csubvGenericTest, FunctionalTest ) { using T = scomplex; //---------------------------------------------------------- @@ -75,26 +76,48 @@ public: gtint_t incx = std::get<2>(str.param); gtint_t incy = std::get<3>(str.param); std::string str_name = "bli_csubv"; - str_name += "_" + std::to_string(n); - str_name += "_" + std::string(&conj, 1); + str_name += "_n_" + std::to_string(n); + str_name += "_conj_" + std::string(&conj, 1); std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); - str_name += "_" + incx_str; + str_name += "_incx_" + incx_str; std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); - str_name += "_" + incy_str; + str_name += "_incy_" + incy_str; return str_name; } }; #ifdef TEST_BLIS_TYPED -// Black box testing. INSTANTIATE_TEST_SUITE_P( - Blackbox, + PositiveIncrements, csubvGenericTest, ::testing::Combine( - ::testing::Values('n','c'), // n: not transpose for x, c: conjugate for x - ::testing::Range(gtint_t(10), gtint_t(101), 10), // m size of vector takes values from 10 to 100 with step size of 10. - ::testing::Values(gtint_t(1), gtint_t(4)), // stride size for x - ::testing::Values(gtint_t(1), gtint_t(7)) // stride size for y + // n: use x, c: use conj(x) + ::testing::Values('n','c'), + // n: size of vector. + // as we don't have BLIS vectorized kernels for subv, + // having fewer sizes or maybe a Range would be sufficient + // to ensure code coverage of the reference kernel. + ::testing::Values( + gtint_t( 1), + gtint_t( 2), + gtint_t( 3), + gtint_t( 5), + gtint_t( 7), + gtint_t( 9), + gtint_t(10), + gtint_t(15), + gtint_t(20), + gtint_t(55), + gtint_t(99) + ), + // incx: stride of x vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ), + // incy: stride of y vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ) ), ::csubvGenericTestPrint() ); diff --git a/gtestsuite/testsuite/level1/subv/dsubv_generic.cpp b/gtestsuite/testsuite/level1/subv/dsubv_generic.cpp index 63a63a927..cc45ac04f 100644 --- a/gtestsuite/testsuite/level1/subv/dsubv_generic.cpp +++ b/gtestsuite/testsuite/level1/subv/dsubv_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -36,11 +36,12 @@ #include "test_subv.h" class dsubvGenericTest : + // input params : x or conj(x), vector length, stride size of x, stride size of y public ::testing::TestWithParam> {}; GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(dsubvGenericTest); -TEST_P( dsubvGenericTest, RandomData ) +TEST_P( dsubvGenericTest, FunctionalTest ) { using T = double; //---------------------------------------------------------- @@ -75,26 +76,74 @@ public: gtint_t incx = std::get<2>(str.param); gtint_t incy = std::get<3>(str.param); std::string str_name = "bli_dsubv"; - str_name += "_" + std::to_string(n); - str_name += "_" + std::string(&conj, 1); + str_name += "_n_" + std::to_string(n); + str_name += "_conj_" + std::string(&conj, 1); std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); - str_name += "_" + incx_str; + str_name += "_incx_" + incx_str; std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); - str_name += "_" + incy_str; + str_name += "_incy_" + incy_str; return str_name; } }; #ifdef TEST_BLIS_TYPED -// Black box testing. INSTANTIATE_TEST_SUITE_P( - Blackbox, + PositiveIncrements, dsubvGenericTest, ::testing::Combine( - ::testing::Values('n'), // n: not transpose for x - ::testing::Range(gtint_t(10), gtint_t(101), 10), // m size of vector takes values from 10 to 100 with step size of 10. - ::testing::Values(gtint_t(1), gtint_t(4)), // stride size for x - ::testing::Values(gtint_t(1), gtint_t(7)) // stride size for y + // n: use x, c: use conj(x) + ::testing::Values('n'), + // n: size of vector. + // as we don't have BLIS vectorized kernels for subv, + // having fewer sizes or maybe a Range would be sufficient + // to ensure code coverage of the reference kernel. + ::testing::Values( + gtint_t( 1), + gtint_t( 2), + gtint_t( 3), + gtint_t( 5), + gtint_t( 7), + gtint_t( 9), + gtint_t(10), + gtint_t(15), + gtint_t(20), + gtint_t(55), + gtint_t(99) + ), + // incx: stride of x vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ), + // incy: stride of y vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ) + ), + ::dsubvGenericTestPrint() + ); +#endif + +#ifdef TEST_BLIS_TYPED +INSTANTIATE_TEST_SUITE_P( + PositiveIncrementforConjugate, + dsubvGenericTest, + ::testing::Combine( + // c: conjugate for x + ::testing::Values('c'), + // n: size of vector. + // as conjugate of a real number x is x, + // so adding a single test that uses 'c' as an option for sanity check. + ::testing::Values( + gtint_t( 1),gtint_t( 7) + ), + // incx: stride of x vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ), + // incy: stride of y vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ) ), ::dsubvGenericTestPrint() ); diff --git a/gtestsuite/testsuite/level1/subv/ssubv_generic.cpp b/gtestsuite/testsuite/level1/subv/ssubv_generic.cpp index 50e004cb0..997b85fd9 100644 --- a/gtestsuite/testsuite/level1/subv/ssubv_generic.cpp +++ b/gtestsuite/testsuite/level1/subv/ssubv_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -36,11 +36,12 @@ #include "test_subv.h" class ssubvGenericTest : + // input params: x or conj(x), vector length, stride size of x, stride size of y public ::testing::TestWithParam> {}; GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ssubvGenericTest); -TEST_P( ssubvGenericTest, RandomData ) +TEST_P( ssubvGenericTest, FunctionalTest ) { using T = float; //---------------------------------------------------------- @@ -75,26 +76,74 @@ public: gtint_t incx = std::get<2>(str.param); gtint_t incy = std::get<3>(str.param); std::string str_name = "bli_ssubv"; - str_name += "_" + std::to_string(n); - str_name += "_" + std::string(&conj, 1); + str_name += "_n_" + std::to_string(n); + str_name += "_conj_" + std::string(&conj, 1); std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); - str_name += "_" + incx_str; + str_name += "_incx_" + incx_str; std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); - str_name += "_" + incy_str; + str_name += "_incy_" + incy_str; return str_name; } }; #ifdef TEST_BLIS_TYPED -// Black box testing. INSTANTIATE_TEST_SUITE_P( - Blackbox, + PositiveIncrements, ssubvGenericTest, ::testing::Combine( - ::testing::Values('n'), // n: not transpose for x - ::testing::Range(gtint_t(10), gtint_t(101), 10), // m size of vector takes values from 10 to 100 with step size of 10. - ::testing::Values(gtint_t(1), gtint_t(4)), // stride size for x - ::testing::Values(gtint_t(1), gtint_t(7)) // stride size for y + // n: use x, c: use conj(x) + ::testing::Values('n'), + // n: size of vector. + // as don't have BLIS vectorized kernels for subv, + // having fewer sizes or maybe a Range would be sufficient + // to ensure code coverage of the reference kernel. + ::testing::Values( + gtint_t( 1), + gtint_t( 2), + gtint_t( 3), + gtint_t( 5), + gtint_t( 7), + gtint_t( 9), + gtint_t(10), + gtint_t(15), + gtint_t(20), + gtint_t(55), + gtint_t(99) + ), + // incx: stride of x vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ), + // incy: stride of y vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ) + ), + ::ssubvGenericTestPrint() + ); +#endif + +#ifdef TEST_BLIS_TYPED +INSTANTIATE_TEST_SUITE_P( + PositiveIncrementforConjugate, + ssubvGenericTest, + ::testing::Combine( + // c: conjugate for x + ::testing::Values('c'), + // n: size of vector. + // as conjugate of a real number x is x, + // so adding a single test that uses 'c' as an option for sanity check. + ::testing::Values( + gtint_t( 1),gtint_t( 7) + ), + // incx: stride of x vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ), + // incy: stride of y vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ) ), ::ssubvGenericTestPrint() ); diff --git a/gtestsuite/testsuite/level1/subv/subv_IIT_ERS.cpp b/gtestsuite/testsuite/level1/subv/subv_IIT_ERS.cpp new file mode 100644 index 000000000..f10fb290f --- /dev/null +++ b/gtestsuite/testsuite/level1/subv/subv_IIT_ERS.cpp @@ -0,0 +1,140 @@ +/* + + BLIS + An object-based framework for developing high-performance BLAS-like + libraries. + + Copyright (C) 2024, Advanced Micro Devices, Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name(s) of the copyright holder(s) nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include "test_subv.h" +#include "common/wrong_inputs_helpers.h" +#include "common/testing_helpers.h" +#include "inc/check_error.h" + +template +class subv_IIT_ERS_Test : public ::testing::Test {}; +typedef ::testing::Types TypeParam; +TYPED_TEST_SUITE(subv_IIT_ERS_Test, TypeParam); + +using namespace testinghelpers::IIT; + +#if defined(TEST_BLIS_TYPED) + +/* + BLIS Early Return Scenarios(ERS): + + SUBV is expected to return early in the following cases: + 1. n <= 0 +*/ + +// n < 0, with non-unit stride +TYPED_TEST(subv_IIT_ERS_Test, n_lt_zero_nonUnitStride) +{ + using T = TypeParam; + gtint_t invalid_n = -1; + gtint_t inc = 5; + + // Defining the X & Y vectors with values for debugging purposes + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + std::vector y = testinghelpers::get_random_vector( -10, 10, N, inc ); + + // Copy so that we check that the elements of Y are not modified. + std::vector y_ref(y); + + // Call BLIS subv with a invalid value for n==-1 & non-unit stride inc = 5. + subv( 'n', invalid_n, x.data(), inc, y.data(), inc ); + + // Use bitwise comparison (no threshold). + computediff( N, y.data(), y_ref.data(), inc ); +} + +// n < 0, with unit stride +TYPED_TEST(subv_IIT_ERS_Test, n_lt_zero_unitStride) +{ + using T = TypeParam; + gtint_t invalid_n = -1; + gtint_t inc = 1; + + // Defining the X & Y vectors with values for debugging purposes + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + std::vector y = testinghelpers::get_random_vector( -10, 10, N, inc ); + + // Copy so that we check that the elements of Y are not modified. + std::vector y_ref(y); + + // Call BLIS subv with a invalid value for n==-1 & unit stride inc = 1. + subv( 'n', invalid_n, x.data(), inc, y.data(), inc ); + + // Use bitwise comparison (no threshold). + computediff( N, y.data(), y_ref.data(), inc ); +} + +// n == 0, with non-unit stride +TYPED_TEST(subv_IIT_ERS_Test, n_eq_zero_nonUnitStride) +{ + using T = TypeParam; + gtint_t invalid_n = 0; + gtint_t inc = 2; + + // Defining the X & Y vectors with values for debugging purposes + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + std::vector y = testinghelpers::get_random_vector( -10, 10, N, inc ); + + // Copy so that we check that the elements of Y are not modified. + std::vector y_ref(y); + + // Call BLIS subv with a invalid value for n==0 & non-unit stride inc = 2. + subv( 'n', invalid_n, x.data(), inc, y.data(), inc ); + + // Use bitwise comparison (no threshold). + computediff( N, y.data(), y_ref.data(), inc ); +} + +// n == 0, with unit stride +TYPED_TEST(subv_IIT_ERS_Test, n_eq_zero_unitStride) +{ + using T = TypeParam; + gtint_t invalid_n = 0; + gtint_t inc = 1; + + // Defining the X & Y vectors with values for debugging purposes + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + std::vector y = testinghelpers::get_random_vector( -10, 10, N, inc ); + + // Copy so that we check that the elements of Y are not modified. + std::vector y_ref(y); + + // Call BLIS subv with a invalid value for n==0 & unit stride inc = 1. + subv( 'n', invalid_n, x.data(), inc, y.data(), inc ); + + // Use bitwise comparison (no threshold). + computediff( N, y.data(), y_ref.data(), inc ); +} +#endif diff --git a/gtestsuite/testsuite/level1/subv/zsubv_generic.cpp b/gtestsuite/testsuite/level1/subv/zsubv_generic.cpp index f4e634f4c..c1042e5fb 100644 --- a/gtestsuite/testsuite/level1/subv/zsubv_generic.cpp +++ b/gtestsuite/testsuite/level1/subv/zsubv_generic.cpp @@ -4,7 +4,7 @@ An object-based framework for developing high-performance BLAS-like libraries. - Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -36,11 +36,12 @@ #include "test_subv.h" class zsubvGenericTest : + // input params: x or conj(x), vector length, stride size of x, stride size of y public ::testing::TestWithParam> {}; GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(zsubvGenericTest); -TEST_P( zsubvGenericTest, RandomData ) +TEST_P( zsubvGenericTest, FunctionalTest ) { using T = dcomplex; //---------------------------------------------------------- @@ -75,26 +76,48 @@ public: gtint_t incx = std::get<2>(str.param); gtint_t incy = std::get<3>(str.param); std::string str_name = "bli_zsubv"; - str_name += "_" + std::to_string(n); - str_name += "_" + std::string(&conj, 1); + str_name += "_n_" + std::to_string(n); + str_name += "_conj_" + std::string(&conj, 1); std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); - str_name += "_" + incx_str; + str_name += "_incx_" + incx_str; std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); - str_name += "_" + incy_str; + str_name += "_incy_" + incy_str; return str_name; } }; #ifdef TEST_BLIS_TYPED -// Black box testing. INSTANTIATE_TEST_SUITE_P( - Blackbox, + PositiveIncrements, zsubvGenericTest, ::testing::Combine( - ::testing::Values('n','c'), // n: not transpose for x, c: conjugate for x - ::testing::Range(gtint_t(10), gtint_t(101), 10), // m size of vector takes values from 10 to 100 with step size of 10. - ::testing::Values(gtint_t(1), gtint_t(4)), // stride size for x - ::testing::Values(gtint_t(1), gtint_t(7)) // stride size for y + // n: use x, c: use conj(x) + ::testing::Values('n','c'), + // n: size of vector. + // as don't have BLIS vectorized kernels for subv, + // having fewer sizes or maybe a Range would be sufficient + // to ensure code coverage of the reference kernel. + ::testing::Values( + gtint_t( 1), + gtint_t( 2), + gtint_t( 3), + gtint_t( 5), + gtint_t( 7), + gtint_t( 9), + gtint_t(10), + gtint_t(15), + gtint_t(20), + gtint_t(55), + gtint_t(99) + ), + // incx: stride of x vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ), + // incy: stride of y vector. + ::testing::Values( + gtint_t(1),gtint_t(5) + ) ), ::zsubvGenericTestPrint() );