mirror of
https://github.com/amd/blis.git
synced 2026-05-25 02:44:31 +00:00
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
This commit is contained in:
committed by
Arnav Sharma
parent
58b63f149f
commit
92aeab1710
156
gtestsuite/testsuite/level1/dotv/dotv_IIT_ERS.cpp
Normal file
156
gtestsuite/testsuite/level1/dotv/dotv_IIT_ERS.cpp
Normal file
@@ -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 <gtest/gtest.h>
|
||||
#include "test_dotv.h"
|
||||
#include "common/wrong_inputs_helpers.h"
|
||||
#include "common/testing_helpers.h"
|
||||
#include "inc/check_error.h"
|
||||
|
||||
template <typename T>
|
||||
class dotv_IIT_ERS_Test : public ::testing::Test {};
|
||||
typedef ::testing::Types<float, double, scomplex, dcomplex> 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, inc );
|
||||
std::vector<T> y = testinghelpers::get_random_vector<T>( -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<T>(rho_ref);
|
||||
|
||||
// Invoking DOTV with an invalid value of n.
|
||||
dotv<T>( CONJ, CONJ, invalid_n, x.data(), inc, y.data(), inc, &rho );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, inc );
|
||||
std::vector<T> y = testinghelpers::get_random_vector<T>( -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<T>(rho_ref);
|
||||
|
||||
// Invoking DOTV with an invalid value of n.
|
||||
dotv<T>( CONJ, CONJ, invalid_n, x.data(), inc, y.data(), inc, &rho );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, unit_inc );
|
||||
std::vector<T> y = testinghelpers::get_random_vector<T>( -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<T>(rho_ref);
|
||||
|
||||
// Invoking DOTV with an invalid value of n.
|
||||
dotv<T>( CONJ, CONJ, invalid_n, x.data(), unit_inc, y.data(), unit_inc, &rho );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, unit_inc );
|
||||
std::vector<T> y = testinghelpers::get_random_vector<T>( -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<T>(rho_ref);
|
||||
|
||||
// Invoking DOTV with an invalid value of n.
|
||||
dotv<T>( CONJ, CONJ, invalid_n, x.data(), unit_inc, y.data(), unit_inc, &rho );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<T>( rho, rho_ref );
|
||||
}
|
||||
#endif
|
||||
228
gtestsuite/testsuite/level1/scalv/scalv_IIT_ERS.cpp
Normal file
228
gtestsuite/testsuite/level1/scalv/scalv_IIT_ERS.cpp
Normal file
@@ -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 <gtest/gtest.h>
|
||||
#include "test_scalv.h"
|
||||
#include "common/wrong_inputs_helpers.h"
|
||||
#include "common/testing_helpers.h"
|
||||
#include "inc/check_error.h"
|
||||
|
||||
template <typename T>
|
||||
class scalv_IIT_ERS_Test : public ::testing::Test {};
|
||||
typedef ::testing::Types<float, double, scomplex, dcomplex> 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, inc );
|
||||
std::vector<T> 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<T>( 'n', invalid_n, alpha, x.data(), inc );
|
||||
|
||||
// Computing bitwise difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, inc );
|
||||
std::vector<T> 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<T>( 'n', invalid_n, alpha, x.data(), inc );
|
||||
|
||||
// Computing bitwise difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, unit_inc );
|
||||
std::vector<T> 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<T>( 'n', invalid_n, alpha, x.data(), unit_inc );
|
||||
|
||||
// Computing bitwise difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, unit_inc );
|
||||
std::vector<T> 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<T>( 'n', invalid_n, alpha, x.data(), unit_inc );
|
||||
|
||||
// Computing bitwise difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, INC );
|
||||
std::vector<T> 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<T>( 'n', N, alpha, x.data(), invalid_inc );
|
||||
|
||||
// Computing bitwise difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, INC );
|
||||
std::vector<T> 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<T>( 'n', N, alpha, x.data(), invalid_inc );
|
||||
|
||||
// Computing bitwise difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, inc );
|
||||
std::vector<T> x_ref(x); // copy x to x_ref to verify elements of x are not modified.
|
||||
|
||||
T invalid_alpha;
|
||||
testinghelpers::initone<T>(invalid_alpha);
|
||||
|
||||
// Invoking SCALV with an invalid value of n.
|
||||
scalv<T>( 'n', N, invalid_alpha, x.data(), inc );
|
||||
|
||||
// Computing bitwise difference.
|
||||
computediff<T>( 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<T> x = testinghelpers::get_random_vector<T>( -10, 10, N, unit_inc );
|
||||
std::vector<T> x_ref(x); // copy x to x_ref to verify elements of x are not modified.
|
||||
|
||||
T invalid_alpha;
|
||||
testinghelpers::initone<T>(invalid_alpha);
|
||||
|
||||
// Invoking SCALV with an invalid value of n.
|
||||
scalv<T>( 'n', N, invalid_alpha, x.data(), unit_inc );
|
||||
|
||||
// Computing bitwise difference.
|
||||
computediff<T>( N, x.data(), x_ref.data(), unit_inc );
|
||||
}
|
||||
#endif
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -85,9 +85,9 @@ static RT typed_asumv(gtint_t n, T* x, gtint_t incx){
|
||||
else if constexpr (std::is_same<T, double>::value)
|
||||
bli_dasumv(n, x, incx, &asum);
|
||||
else if constexpr (std::is_same<T, scomplex>::value)
|
||||
bli_scasumv(n, x, incx, &asum);
|
||||
bli_casumv(n, x, incx, &asum);
|
||||
else if constexpr (std::is_same<T, dcomplex>::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;
|
||||
|
||||
205
gtestsuite/testsuite/util/asumv/asumv_IIT_ERS.cpp
Normal file
205
gtestsuite/testsuite/util/asumv/asumv_IIT_ERS.cpp
Normal file
@@ -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 <gtest/gtest.h>
|
||||
#include "test_asumv.h"
|
||||
#include "common/wrong_inputs_helpers.h"
|
||||
#include "common/testing_helpers.h"
|
||||
#include "inc/check_error.h"
|
||||
|
||||
template <typename T>
|
||||
class asumv_IIT_ERS_Test : public ::testing::Test {};
|
||||
typedef ::testing::Types<float, double, scomplex, dcomplex> 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<T>::real_type;
|
||||
gtint_t invalid_n = -1;
|
||||
gtint_t inc = 5;
|
||||
|
||||
// Initialize x vector with random numbers.
|
||||
std::vector<T> x = testinghelpers::get_random_vector<T>( -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<RT>(asum_ref);
|
||||
|
||||
// Invoking asumV with an invalid value of n.
|
||||
asum = asumv<T>( invalid_n, x.data(), inc );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<RT>( 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<T>::real_type;
|
||||
gtint_t invalid_n = 0;
|
||||
gtint_t inc = 5;
|
||||
|
||||
// Initialize x vector with random numbers.
|
||||
std::vector<T> x = testinghelpers::get_random_vector<T>( -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<RT>(asum_ref);
|
||||
|
||||
// Invoking asumV with an invalid value of n.
|
||||
asum = asumv<T>( invalid_n, x.data(), inc );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<RT>( 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<T>::real_type;
|
||||
gtint_t invalid_n = -1;
|
||||
gtint_t unit_inc = 1;
|
||||
|
||||
// Initialize x vector with random numbers.
|
||||
std::vector<T> x = testinghelpers::get_random_vector<T>( -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<RT>(asum_ref);
|
||||
|
||||
// Invoking asumV with an invalid value of n.
|
||||
asum = asumv<T>( invalid_n, x.data(), unit_inc );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<RT>( 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<T>::real_type;
|
||||
gtint_t invalid_n = 0;
|
||||
gtint_t unit_inc = 1;
|
||||
|
||||
// Initialize x vector with random numbers.
|
||||
std::vector<T> x = testinghelpers::get_random_vector<T>( -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<RT>(asum_ref);
|
||||
|
||||
// Invoking asumV with an invalid value of n.
|
||||
asum = asumv<T>( invalid_n, x.data(), unit_inc );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<RT>( asum, asum_ref );
|
||||
}
|
||||
|
||||
// inc < 0
|
||||
TYPED_TEST(asumv_IIT_ERS_Test, inc_lt_0)
|
||||
{
|
||||
using T = TypeParam;
|
||||
using RT = typename testinghelpers::type_info<T>::real_type;
|
||||
gtint_t invalid_inc = -1;
|
||||
|
||||
// Initialize x vector with random numbers.
|
||||
std::vector<T> x = testinghelpers::get_random_vector<T>( -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<RT>(asum_ref);
|
||||
|
||||
// Invoking asumV with an invalid value of n.
|
||||
asum = asumv<T>( N, x.data(), invalid_inc );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<RT>( asum, asum_ref );
|
||||
}
|
||||
|
||||
// inc == 0
|
||||
TYPED_TEST(asumv_IIT_ERS_Test, inc_eq_0)
|
||||
{
|
||||
using T = TypeParam;
|
||||
using RT = typename testinghelpers::type_info<T>::real_type;
|
||||
gtint_t invalid_inc = 0;
|
||||
|
||||
// Initialize x vector with random numbers.
|
||||
std::vector<T> x = testinghelpers::get_random_vector<T>( -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<RT>(asum_ref);
|
||||
|
||||
// Invoking asumV with an invalid value of n.
|
||||
asum = asumv<T>( N, x.data(), invalid_inc );
|
||||
|
||||
// Computing the difference.
|
||||
computediff<RT>( asum, asum_ref );
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user