From 92aeab1710ff4ac10c04d1caeb8f7b92ab5ffc35 Mon Sep 17 00:00:00 2001 From: Arnav Sharma Date: Thu, 25 Jan 2024 01:12:18 +0530 Subject: [PATCH] Early Return Scenario (ERS) tests for ?SCALV, ?DOTV and ?ASUMV - ERS tests have been added for the above APIs as per the BLAS compliance standards. - Following are the standard tests added: ?SCALV - n <= 0 - incx <= 0 - alpha == 1 ?DOTV - n <= 0 ?ASUMV - n <= 0 - incx <= 0 - Invalid Input Tests are not required for these APIs. - Updated the micro-kernel test files to include the new macros generated for enabling and disabling architecture specific tests. - Updated the function calls for mixed-precision typed_asumv tests. AMD-Internal: [CPUPL-4406] Change-Id: Ib34b2f39809d93075ae1168682b3ef2380e03a5a --- .../testsuite/level1/dotv/dotv_IIT_ERS.cpp | 156 ++++++++++++ .../testsuite/level1/scalv/scalv_IIT_ERS.cpp | 228 ++++++++++++++++++ gtestsuite/testsuite/ukr/dotv/ddotv_ukr.cpp | 6 +- gtestsuite/testsuite/ukr/scalv/dscalv_ukr.cpp | 6 +- gtestsuite/testsuite/util/asumv/asumv.h | 4 +- .../testsuite/util/asumv/asumv_IIT_ERS.cpp | 205 ++++++++++++++++ 6 files changed, 598 insertions(+), 7 deletions(-) create mode 100644 gtestsuite/testsuite/level1/dotv/dotv_IIT_ERS.cpp create mode 100644 gtestsuite/testsuite/level1/scalv/scalv_IIT_ERS.cpp create mode 100644 gtestsuite/testsuite/util/asumv/asumv_IIT_ERS.cpp diff --git a/gtestsuite/testsuite/level1/dotv/dotv_IIT_ERS.cpp b/gtestsuite/testsuite/level1/dotv/dotv_IIT_ERS.cpp new file mode 100644 index 000000000..a34402278 --- /dev/null +++ b/gtestsuite/testsuite/level1/dotv/dotv_IIT_ERS.cpp @@ -0,0 +1,156 @@ +/* + + 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_dotv.h" +#include "common/wrong_inputs_helpers.h" +#include "common/testing_helpers.h" +#include "inc/check_error.h" + +template +class dotv_IIT_ERS_Test : public ::testing::Test {}; +typedef ::testing::Types TypeParam; +TYPED_TEST_SUITE(dotv_IIT_ERS_Test, TypeParam); + +using namespace testinghelpers::IIT; + +#if defined(TEST_BLAS) || defined(TEST_CBLAS) + +/* + BLAS Early Return Scenarios(ERS): + + DOTV is expected to return early in the following cases: + 1. n <= 0 +*/ + +// n < 0, with non-unit stride +TYPED_TEST(dotv_IIT_ERS_Test, n_lt_zero_nonUnitStride) +{ + using T = TypeParam; + gtint_t invalid_n = -1; + gtint_t inc = 5; + + // Initialize vectors with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + std::vector y = testinghelpers::get_random_vector( -10, 10, N, inc ); + + // Initialize rho (BLIS output) to garbage value. + T rho = T{-7.3}; + + // Initialize the expected output to zero. + T rho_ref; + testinghelpers::initzero(rho_ref); + + // Invoking DOTV with an invalid value of n. + dotv( CONJ, CONJ, invalid_n, x.data(), inc, y.data(), inc, &rho ); + + // Computing the difference. + computediff( rho, rho_ref ); +} + +// n == 0, with non-unit stride +TYPED_TEST(dotv_IIT_ERS_Test, n_eq_zero_nonUnitStride) +{ + using T = TypeParam; + gtint_t invalid_n = 0; + gtint_t inc = 5; + + // Initialize vectors with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + std::vector y = testinghelpers::get_random_vector( -10, 10, N, inc ); + + // Initialize rho (BLIS output) to garbage value. + T rho = T{-7.3}; + + // Initialize the expected output to zero. + T rho_ref; + testinghelpers::initzero(rho_ref); + + // Invoking DOTV with an invalid value of n. + dotv( CONJ, CONJ, invalid_n, x.data(), inc, y.data(), inc, &rho ); + + // Computing the difference. + computediff( rho, rho_ref ); +} + +// n < 0, with unit stride +TYPED_TEST(dotv_IIT_ERS_Test, n_lt_zero_unitStride) +{ + using T = TypeParam; + gtint_t invalid_n = -1; + gtint_t unit_inc = 1; + + // Initialize vectors with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, unit_inc ); + std::vector y = testinghelpers::get_random_vector( -10, 10, N, unit_inc ); + + // Initialize rho (BLIS output) to garbage value. + T rho = T{-7.3}; + + // Initialize the expected output to zero. + T rho_ref; + testinghelpers::initzero(rho_ref); + + // Invoking DOTV with an invalid value of n. + dotv( CONJ, CONJ, invalid_n, x.data(), unit_inc, y.data(), unit_inc, &rho ); + + // Computing the difference. + computediff( rho, rho_ref ); +} + +// n == 0, with unit stride +TYPED_TEST(dotv_IIT_ERS_Test, n_eq_zero_unitStride) +{ + using T = TypeParam; + gtint_t invalid_n = 0; + gtint_t unit_inc = 1; + + // Initialize vectors with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, unit_inc ); + std::vector y = testinghelpers::get_random_vector( -10, 10, N, unit_inc ); + + // Initialize rho (BLIS output) to garbage value. + T rho = T{-7.3}; + + // Initialize the expected output to zero. + T rho_ref; + testinghelpers::initzero(rho_ref); + + // Invoking DOTV with an invalid value of n. + dotv( CONJ, CONJ, invalid_n, x.data(), unit_inc, y.data(), unit_inc, &rho ); + + // Computing the difference. + computediff( rho, rho_ref ); +} +#endif \ No newline at end of file diff --git a/gtestsuite/testsuite/level1/scalv/scalv_IIT_ERS.cpp b/gtestsuite/testsuite/level1/scalv/scalv_IIT_ERS.cpp new file mode 100644 index 000000000..54258c675 --- /dev/null +++ b/gtestsuite/testsuite/level1/scalv/scalv_IIT_ERS.cpp @@ -0,0 +1,228 @@ +/* + + 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_scalv.h" +#include "common/wrong_inputs_helpers.h" +#include "common/testing_helpers.h" +#include "inc/check_error.h" + +template +class scalv_IIT_ERS_Test : public ::testing::Test {}; +typedef ::testing::Types TypeParam; +TYPED_TEST_SUITE(scalv_IIT_ERS_Test, TypeParam); + +using namespace testinghelpers::IIT; + +#if defined(TEST_BLAS) || defined(TEST_CBLAS) + +/* + BLAS Early Return Scenarios(ERS): + + SCALV is expected to return early in the following cases: + 1. n <= 0 + 2. inc <= 0 + 3. alpha == 1 +*/ + +// n < 0, with non-unit stride +TYPED_TEST(scalv_IIT_ERS_Test, n_lt_zero_nonUnitStride) +{ + using T = TypeParam; + gtint_t invalid_n = -1; + gtint_t inc = 5; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + std::vector x_ref(x); // copy x to x_ref to verify elements of x are not modified. + + // Using alpha = 3 as a valid input since BLAS expects SCALV to return early + // for alpha = 1. + T alpha = T{3}; + + // Invoking SCALV with an invalid value of n. + scalv( 'n', invalid_n, alpha, x.data(), inc ); + + // Computing bitwise difference. + computediff( N, x.data(), x_ref.data(), inc ); +} + +// n == 0, with non-unit stride +TYPED_TEST(scalv_IIT_ERS_Test, n_eq_zero_nonUnitStride) +{ + using T = TypeParam; + gtint_t invalid_n = 0; + gtint_t inc = 5; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + std::vector x_ref(x); // copy x to x_ref to verify elements of x are not modified. + + // Using alpha = 3 as a valid input since BLAS expects SCALV to return early + // for alpha = 1. + T alpha = T{3}; + + // Invoking SCALV with an invalid value of n. + scalv( 'n', invalid_n, alpha, x.data(), inc ); + + // Computing bitwise difference. + computediff( N, x.data(), x_ref.data(), inc ); +} + +// n < 0, with unit stride +TYPED_TEST(scalv_IIT_ERS_Test, n_lt_zero_unitStride) +{ + using T = TypeParam; + gtint_t invalid_n = -1; + gtint_t unit_inc = 1; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, unit_inc ); + std::vector x_ref(x); // copy x to x_ref to verify elements of x are not modified. + + // Using alpha = 3 as a valid input since BLAS expects SCALV to return early + // for alpha = 1. + T alpha = T{3}; + + // Invoking SCALV with an invalid value of n. + scalv( 'n', invalid_n, alpha, x.data(), unit_inc ); + + // Computing bitwise difference. + computediff( N, x.data(), x_ref.data(), unit_inc ); +} + +// n == 0, with unit stride +TYPED_TEST(scalv_IIT_ERS_Test, n_eq_zero_unitStride) +{ + using T = TypeParam; + gtint_t invalid_n = 0; + gtint_t unit_inc = 1; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, unit_inc ); + std::vector x_ref(x); // copy x to x_ref to verify elements of x are not modified. + + // Using alpha = 3 as a valid input since BLAS expects SCALV to return early + // for alpha = 1. + T alpha = T{3}; + + // Invoking SCALV with an invalid value of n. + scalv( 'n', invalid_n, alpha, x.data(), unit_inc ); + + // Computing bitwise difference. + computediff( N, x.data(), x_ref.data(), unit_inc ); +} + +// inc < 0 +TYPED_TEST(scalv_IIT_ERS_Test, inc_lt_0) +{ + using T = TypeParam; + gtint_t invalid_inc = -1; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, INC ); + std::vector x_ref(x); // copy x to x_ref to verify elements of x are not modified. + + // Using alpha = 3 as a valid input since BLAS expects SCALV to return early + // for alpha = 1. + T alpha = T{3}; + + // Invoking SCALV with an invalid value of n. + scalv( 'n', N, alpha, x.data(), invalid_inc ); + + // Computing bitwise difference. + computediff( N, x.data(), x_ref.data(), INC ); +} + +// inc == 0 +TYPED_TEST(scalv_IIT_ERS_Test, inc_eq_0) +{ + using T = TypeParam; + gtint_t invalid_inc = 0; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, INC ); + std::vector x_ref(x); // copy x to x_ref to verify elements of x are not modified. + + // Using alpha = 3 as a valid input since BLAS expects SCALV to return early + // for alpha = 1. + T alpha = T{3}; + + // Invoking SCALV with an invalid value of n. + scalv( 'n', N, alpha, x.data(), invalid_inc ); + + // Computing bitwise difference. + computediff( N, x.data(), x_ref.data(), INC ); +} + +// alpha == 1, with non-unit stride +TYPED_TEST(scalv_IIT_ERS_Test, alpha_eq_one_nonUnitStride) +{ + using T = TypeParam; + gtint_t inc = 5; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + std::vector x_ref(x); // copy x to x_ref to verify elements of x are not modified. + + T invalid_alpha; + testinghelpers::initone(invalid_alpha); + + // Invoking SCALV with an invalid value of n. + scalv( 'n', N, invalid_alpha, x.data(), inc ); + + // Computing bitwise difference. + computediff( N, x.data(), x_ref.data(), inc ); +} + +// alpha == 1, with unit stride +TYPED_TEST(scalv_IIT_ERS_Test, alpha_eq_one_unitStride) +{ + using T = TypeParam; + gtint_t unit_inc = 1; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, unit_inc ); + std::vector x_ref(x); // copy x to x_ref to verify elements of x are not modified. + + T invalid_alpha; + testinghelpers::initone(invalid_alpha); + + // Invoking SCALV with an invalid value of n. + scalv( 'n', N, invalid_alpha, x.data(), unit_inc ); + + // Computing bitwise difference. + computediff( N, x.data(), x_ref.data(), unit_inc ); +} +#endif \ No newline at end of file diff --git a/gtestsuite/testsuite/ukr/dotv/ddotv_ukr.cpp b/gtestsuite/testsuite/ukr/dotv/ddotv_ukr.cpp index c1c5e0c72..b8d6b5005 100644 --- a/gtestsuite/testsuite/ukr/dotv/ddotv_ukr.cpp +++ b/gtestsuite/testsuite/ukr/dotv/ddotv_ukr.cpp @@ -42,6 +42,8 @@ class ddotvUkrTest : gtint_t, gtint_t, gtint_t>> {}; +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ddotvUkrTest); + // Tests using random integers as vector elements. TEST_P( ddotvUkrTest, RandomData ) @@ -104,7 +106,7 @@ public: // ---------------------------------------------- // ----- Begin ZEN1/2/3 (AVX2) Kernel Tests ----- // ---------------------------------------------- -#ifdef BLIS_KERNELS_ZEN +#if defined(BLIS_KERNELS_ZEN) && defined(GTEST_AVX2FMA3) // Tests for bli_ddotv_zen_int (AVX2) kernel. /** * Loops: @@ -260,7 +262,7 @@ INSTANTIATE_TEST_SUITE_P( // ---------------------------------------------- // ----- Begin ZEN4 (AVX512) Kernel Tests ----- // ---------------------------------------------- -#ifdef BLIS_KERNELS_ZEN4 +#if defined(BLIS_KERNELS_ZEN4) && defined(GTEST_AVX512) // Tests for bli_ddotv_zen_int_avx512 (AVX512) kernel. /** * Loops & If conditions: diff --git a/gtestsuite/testsuite/ukr/scalv/dscalv_ukr.cpp b/gtestsuite/testsuite/ukr/scalv/dscalv_ukr.cpp index 9d5945bd9..a64f3bc1c 100644 --- a/gtestsuite/testsuite/ukr/scalv/dscalv_ukr.cpp +++ b/gtestsuite/testsuite/ukr/scalv/dscalv_ukr.cpp @@ -41,7 +41,7 @@ class dscalvUkrTest : gtint_t, gtint_t, double>> {}; - +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(dscalvUkrTest); // Tests using random integers as vector elements. TEST_P( dscalvUkrTest, RandomData ) @@ -99,7 +99,7 @@ public: // ---------------------------------------------- // ----- Begin ZEN1/2/3 (AVX2) Kernel Tests ----- // ---------------------------------------------- -#ifdef BLIS_KERNELS_ZEN +#if defined(BLIS_KERNELS_ZEN) && defined(GTEST_AVX2FMA3) // Tests for bli_ddotv_zen_int (AVX2) kernel. /** * Loops: @@ -258,7 +258,7 @@ INSTANTIATE_TEST_SUITE_P( // ---------------------------------------------- // ----- Begin ZEN4 (AVX512) Kernel Tests ----- // ---------------------------------------------- -#ifdef BLIS_KERNELS_ZEN4 +#if defined(BLIS_KERNELS_ZEN4) && defined(GTEST_AVX512) // Tests for bli_dscalv_zen_int_avx512 (AVX512) kernel. /** * Loops: diff --git a/gtestsuite/testsuite/util/asumv/asumv.h b/gtestsuite/testsuite/util/asumv/asumv.h index 969cd855f..af978c52e 100644 --- a/gtestsuite/testsuite/util/asumv/asumv.h +++ b/gtestsuite/testsuite/util/asumv/asumv.h @@ -85,9 +85,9 @@ static RT typed_asumv(gtint_t n, T* x, gtint_t incx){ else if constexpr (std::is_same::value) bli_dasumv(n, x, incx, &asum); else if constexpr (std::is_same::value) - bli_scasumv(n, x, incx, &asum); + bli_casumv(n, x, incx, &asum); else if constexpr (std::is_same::value) - bli_dzasumv(n, x, incx, &asum); + bli_zasumv(n, x, incx, &asum); else throw std::runtime_error("Error in testsuite/util/asumv.h: Invalid typename in cblas_asumv()."); return asum; diff --git a/gtestsuite/testsuite/util/asumv/asumv_IIT_ERS.cpp b/gtestsuite/testsuite/util/asumv/asumv_IIT_ERS.cpp new file mode 100644 index 000000000..33f90dce7 --- /dev/null +++ b/gtestsuite/testsuite/util/asumv/asumv_IIT_ERS.cpp @@ -0,0 +1,205 @@ +/* + + 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_asumv.h" +#include "common/wrong_inputs_helpers.h" +#include "common/testing_helpers.h" +#include "inc/check_error.h" + +template +class asumv_IIT_ERS_Test : public ::testing::Test {}; +typedef ::testing::Types TypeParam; +TYPED_TEST_SUITE(asumv_IIT_ERS_Test, TypeParam); + +using namespace testinghelpers::IIT; + +#if defined(TEST_BLAS) || defined(TEST_CBLAS) + +/* + BLAS Early Return Scenarios(ERS): + + ASUMV is expected to return early in the following cases: + 1. n <= 0 + 2. inc <= 0 +*/ + +// n < 0, with non-unit stride +TYPED_TEST(asumv_IIT_ERS_Test, n_lt_zero_nonUnitStride) +{ + using T = TypeParam; + using RT = typename testinghelpers::type_info::real_type; + gtint_t invalid_n = -1; + gtint_t inc = 5; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + + // Initialize asum (BLIS output) to garbage value. + RT asum = RT{-7.3}; + + // Initialize the expected output to zero. + RT asum_ref; + testinghelpers::initzero(asum_ref); + + // Invoking asumV with an invalid value of n. + asum = asumv( invalid_n, x.data(), inc ); + + // Computing the difference. + computediff( asum, asum_ref ); +} + +// n == 0, with non-unit stride +TYPED_TEST(asumv_IIT_ERS_Test, n_eq_zero_nonUnitStride) +{ + using T = TypeParam; + using RT = typename testinghelpers::type_info::real_type; + gtint_t invalid_n = 0; + gtint_t inc = 5; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, inc ); + + // Initialize asum (BLIS output) to garbage value. + RT asum = RT{-7.3}; + + // Initialize the expected output to zero. + RT asum_ref; + testinghelpers::initzero(asum_ref); + + // Invoking asumV with an invalid value of n. + asum = asumv( invalid_n, x.data(), inc ); + + // Computing the difference. + computediff( asum, asum_ref ); +} + +// n < 0, with unit stride +TYPED_TEST(asumv_IIT_ERS_Test, n_lt_zero_unitStride) +{ + using T = TypeParam; + using RT = typename testinghelpers::type_info::real_type; + gtint_t invalid_n = -1; + gtint_t unit_inc = 1; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, unit_inc ); + + // Initialize asum (BLIS output) to garbage value. + RT asum = RT{-7.3}; + + // Initialize the expected output to zero. + RT asum_ref; + testinghelpers::initzero(asum_ref); + + // Invoking asumV with an invalid value of n. + asum = asumv( invalid_n, x.data(), unit_inc ); + + // Computing the difference. + computediff( asum, asum_ref ); +} + +// n == 0, with unit stride +TYPED_TEST(asumv_IIT_ERS_Test, n_eq_zero_unitStride) +{ + using T = TypeParam; + using RT = typename testinghelpers::type_info::real_type; + gtint_t invalid_n = 0; + gtint_t unit_inc = 1; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, unit_inc ); + + // Initialize asum (BLIS output) to garbage value. + RT asum = RT{-7.3}; + + // Initialize the expected output to zero. + RT asum_ref; + testinghelpers::initzero(asum_ref); + + // Invoking asumV with an invalid value of n. + asum = asumv( invalid_n, x.data(), unit_inc ); + + // Computing the difference. + computediff( asum, asum_ref ); +} + +// inc < 0 +TYPED_TEST(asumv_IIT_ERS_Test, inc_lt_0) +{ + using T = TypeParam; + using RT = typename testinghelpers::type_info::real_type; + gtint_t invalid_inc = -1; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, INC ); + + // Initialize asum (BLIS output) to garbage value. + RT asum = RT{-7.3}; + + // Initialize the expected output to zero. + RT asum_ref; + testinghelpers::initzero(asum_ref); + + // Invoking asumV with an invalid value of n. + asum = asumv( N, x.data(), invalid_inc ); + + // Computing the difference. + computediff( asum, asum_ref ); +} + +// inc == 0 +TYPED_TEST(asumv_IIT_ERS_Test, inc_eq_0) +{ + using T = TypeParam; + using RT = typename testinghelpers::type_info::real_type; + gtint_t invalid_inc = 0; + + // Initialize x vector with random numbers. + std::vector x = testinghelpers::get_random_vector( -10, 10, N, INC ); + + // Initialize asum (BLIS output) to garbage value. + RT asum = RT{-7.3}; + + // Initialize the expected output to zero. + RT asum_ref; + testinghelpers::initzero(asum_ref); + + // Invoking asumV with an invalid value of n. + asum = asumv( N, x.data(), invalid_inc ); + + // Computing the difference. + computediff( asum, asum_ref ); +} +#endif \ No newline at end of file