From 16aaafc8ec9eab9c3e43a54ee8ceda14830b1833 Mon Sep 17 00:00:00 2001 From: Vignesh Balasubramanian Date: Wed, 14 Feb 2024 16:14:14 +0530 Subject: [PATCH] Added memory testing for DAXPY, DAXPBY and DCOPY kernels. - Utilized the memory testing feature in GTestsuite to update the testing interfaces for micro-kernel testing of DAXPY, DAXPBY and DCOPY APIs. - The interface allocates memory using objects of ProtectedBuffer class, which define the redzones and greenzones as per the requirement. - Updated the test fixture classes, test-case loggers and the instantiators to use the new testing interface for memory testing. - Added special cases of alpha and beta values to API level functionality tests, to check for any possible framework level optimizations against the standard. - Code cleanup of ?_generic.cpp and ?_evt_testing.cpp files of DAXPY, DAXPBY and DCOPY APIs. AMD-Internal: [CPUPL-4402] Change-Id: Id945cabbbb42604d76a9e34269bff0f9f6712604 --- .../level1/axpbyv/daxpbyv_evt_testing.cpp | 64 +++---- .../level1/axpbyv/daxpbyv_generic.cpp | 42 +++-- .../level1/axpyv/daxpyv_evt_testing.cpp | 68 +++---- .../testsuite/level1/axpyv/daxpyv_generic.cpp | 72 ++++---- .../testsuite/level1/copyv/dcopyv_generic.cpp | 10 +- .../testsuite/ukr/axpbyv/daxpbyv_ukr.cpp | 126 +++++++------ .../testsuite/ukr/axpbyv/test_axpbyv_ukr.h | 92 +++++++--- gtestsuite/testsuite/ukr/axpyv/daxpyv_ukr.cpp | 172 +++++++++--------- .../testsuite/ukr/axpyv/test_axpyv_ukr.h | 92 +++++++--- gtestsuite/testsuite/ukr/copyv/dcopyv_ukr.cpp | 53 +++--- .../testsuite/ukr/copyv/test_copyv_ukr.h | 91 ++++++--- 11 files changed, 525 insertions(+), 357 deletions(-) diff --git a/gtestsuite/testsuite/level1/axpbyv/daxpbyv_evt_testing.cpp b/gtestsuite/testsuite/level1/axpbyv/daxpbyv_evt_testing.cpp index 75b5008ca..4bcd3c8be 100644 --- a/gtestsuite/testsuite/level1/axpbyv/daxpbyv_evt_testing.cpp +++ b/gtestsuite/testsuite/level1/axpbyv/daxpbyv_evt_testing.cpp @@ -35,7 +35,7 @@ #include #include "test_axpbyv.h" -class daxpbyvEVTTest : +class daxpbyvEVT : public ::testing::TestWithParam> {}; // beta // Tests using random values as vector elements, // with exception values on the passed indices. -TEST_P(daxpbyvEVTTest, ExceptionData) +TEST_P(daxpbyvEVT, ExceptionData) { using T = double; //---------------------------------------------------------- @@ -88,7 +88,7 @@ TEST_P(daxpbyvEVTTest, ExceptionData) // Test-case logger : Used to print the test-case details when vectors have exception value. // The string format is as follows : -// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_X_(xi)_(xexval)_(yi)_(yexval)_a(alpha_val)_b(beta_val) +// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_X_(xi)_(xexval)_(yi)_(yexval)_alpha(alpha_val)_beta(beta_val) class daxpbyvEVTVecPrint { public: @@ -106,17 +106,17 @@ public: double alpha = std::get<8>(str.param); double beta = std::get<9>(str.param); #ifdef TEST_BLAS - std::string str_name = "daxpby_"; + std::string str_name = "blas_"; #elif TEST_CBLAS - std::string str_name = "cblas_daxpby"; -#else // #elif TEST_BLIS_TYPED - std::string str_name = "bli_daxpbyv"; + std::string str_name = "cblas_"; +#else //#elif TEST_BLIS_TYPED + std::string str_name = "bli_"; #endif str_name += "_n" + std::to_string(n); str_name += ( conjx == 'n' )? "_noconjx" : "_conjx"; - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_incx" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_incy" + incy_str; std::string xexval_str = testinghelpers::get_value_string(xexval); std::string yexval_str = testinghelpers::get_value_string(yexval); @@ -126,15 +126,15 @@ public: str_name = str_name + "_" + yexval_str; std::string alpha_str = testinghelpers::get_value_string(alpha); std::string beta_str = testinghelpers::get_value_string(beta); - str_name = str_name + "_a" + alpha_str; - str_name = str_name + "_b" + beta_str; + str_name = str_name + "_alpha" + alpha_str; + str_name = str_name + "_beta" + beta_str; return str_name; } }; // Test-case logger : Used to print the test-case details when alpha/beta have exception value. // The string format is as follows : -// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_a(alpha_val)_b(beta_val) +// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_alpha(alpha_val)_beta(beta_val) class daxpbyvAlphaBetaPrint { public: @@ -156,14 +156,14 @@ public: #endif str_name += "_n" + std::to_string(n); str_name += ( conjx == 'n' )? "_noconjx" : "_conjx"; - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_incx" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_incy" + incy_str; std::string alpha_str = testinghelpers::get_value_string(alpha); std::string beta_str = testinghelpers::get_value_string(beta); - str_name = str_name + "_a" + alpha_str; - str_name = str_name + "_b" + beta_str; + str_name = str_name + "_alpha" + alpha_str; + str_name = str_name + "_beta" + beta_str; return str_name; } }; @@ -199,8 +199,8 @@ static double Inf = std::numeric_limits::infinity(); */ // Exception value testing(on X vector alone) with unit strides INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecX_unitStrides, - daxpbyvEVTTest, + vecX_unitStrides, + daxpbyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -212,7 +212,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(1)), // stride size for x ::testing::Values(gtint_t(1)), // stride size for y ::testing::Values(gtint_t(0), gtint_t(79), gtint_t(99), - gtint_t(107), gtint_t(111), gtint_t(114)), // indices to set exception values on x + gtint_t(107), gtint_t(111), gtint_t(114)), // indices to set exception values on x ::testing::Values(NaN, -Inf, Inf), // exception values to set on x ::testing::Values(gtint_t(0)), // dummy index on y ::testing::Values(double(0.0)), // dummy value on y @@ -223,8 +223,8 @@ INSTANTIATE_TEST_SUITE_P( // Exception value testing(on Y vector alone) with unit strides INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecY_unitStrides, - daxpbyvEVTTest, + vecY_unitStrides, + daxpbyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -238,7 +238,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(0)), // dummy index on x ::testing::Values(double(0.0)), // dummy value on x ::testing::Values(gtint_t(0), gtint_t(79), gtint_t(99), - gtint_t(107), gtint_t(111), gtint_t(114)), // indices to set exception values on y + gtint_t(107), gtint_t(111), gtint_t(114)), // indices to set exception values on y ::testing::Values(NaN, -Inf, Inf), // exception values to set on y ::testing::Values(double(0.0), double(1.0), double(-1.0), double(-3.3)), // alpha ::testing::Values(double(0.0), double(1.0), double(-1.0), double(4.5)) // beta @@ -247,8 +247,8 @@ INSTANTIATE_TEST_SUITE_P( // Exception value testing(on X and Y vectors) with unit strides INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecXY_unitStrides, - daxpbyvEVTTest, + vecXY_unitStrides, + daxpbyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -260,10 +260,10 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(1)), // stride size for x ::testing::Values(gtint_t(1)), // stride size for y ::testing::Values(gtint_t(0), gtint_t(79), gtint_t(99), - gtint_t(107), gtint_t(111), gtint_t(114)), // indices to set exception values on x + gtint_t(107), gtint_t(111), gtint_t(114)), // indices to set exception values on x ::testing::Values(NaN, -Inf, Inf), // exception values to set on x ::testing::Values(gtint_t(0), gtint_t(79), gtint_t(99), - gtint_t(107), gtint_t(111), gtint_t(114)), // indices to set exception values on y + gtint_t(107), gtint_t(111), gtint_t(114)), // indices to set exception values on y ::testing::Values(NaN, -Inf, Inf), // exception values to set on y ::testing::Values(double(0.0), double(1.0), double(-1.0), double(-3.3)), // alpha ::testing::Values(double(0.0), double(1.0), double(-1.0), double(4.5)) // beta @@ -274,8 +274,8 @@ INSTANTIATE_TEST_SUITE_P( // We have to test a single scalar loop. The indices are such // that we cover _vecX_, _vecY_ and _vecXY_ cases together. INSTANTIATE_TEST_SUITE_P( - exceptionValue_vec_nonUnitStrides, - daxpbyvEVTTest, + vec_nonUnitStrides, + daxpbyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -308,8 +308,8 @@ INSTANTIATE_TEST_SUITE_P( */ // Exception value testing(on alpha/beta) with unit strided vectors INSTANTIATE_TEST_SUITE_P( - exceptionValue_alphaBeta_unitStrides, - daxpbyvEVTTest, + alphaBeta_unitStrides, + daxpbyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -331,8 +331,8 @@ INSTANTIATE_TEST_SUITE_P( // Exception value testing(on alpha/beta) with non-unit strided vectors INSTANTIATE_TEST_SUITE_P( - exceptionValue_alphaBeta_nonUnitStrides, - daxpbyvEVTTest, + alphaBeta_nonUnitStrides, + daxpbyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED diff --git a/gtestsuite/testsuite/level1/axpbyv/daxpbyv_generic.cpp b/gtestsuite/testsuite/level1/axpbyv/daxpbyv_generic.cpp index 7e66674b1..befa6a5d0 100644 --- a/gtestsuite/testsuite/level1/axpbyv/daxpbyv_generic.cpp +++ b/gtestsuite/testsuite/level1/axpbyv/daxpbyv_generic.cpp @@ -87,22 +87,22 @@ public: double alpha = std::get<4>(str.param); double beta = std::get<5>(str.param); #ifdef TEST_BLAS - std::string str_name = "daxpby_"; + std::string str_name = "blas_"; #elif TEST_CBLAS - std::string str_name = "cblas_daxpby"; + std::string str_name = "cblas_"; #else //#elif TEST_BLIS_TYPED - std::string str_name = "bli_daxpbyv"; + std::string str_name = "bli_"; #endif str_name += "_n" + std::to_string(n); str_name += ( conjx == 'n' )? "_noconjx" : "_conjx"; - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_incx" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_incy" + incy_str; - std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); - str_name = str_name + "_a" + alpha_str; - std::string beta_str = ( beta > 0) ? std::to_string(int(beta)) : "m" + std::to_string(int(std::abs(beta))); - str_name = str_name + "_b" + beta_str; + std::string alpha_str = ( alpha >= 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); + str_name = str_name + "_alpha" + alpha_str; + std::string beta_str = ( beta >= 0) ? std::to_string(int(beta)) : "m" + std::to_string(int(std::abs(beta))); + str_name = str_name + "_beta" + beta_str; return str_name; } }; @@ -116,8 +116,10 @@ INSTANTIATE_TEST_SUITE_P( ::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)), // stride size for x ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(2.3), double(-3.7), double(0.0)), // alpha - ::testing::Values(double(-4.9), double(1.2), double(0.0)) // beta + ::testing::Values(double(2.3), double(1.0), + double(-1.0), double(0.0)), // alpha + ::testing::Values(double(-4.9), double(1.0), + double(-1.0), double(0.0)) // beta ), ::daxpbyvGenericTestPrint() ); @@ -134,8 +136,10 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(3), gtint_t(30), gtint_t(112)), // m size of vector ::testing::Values(gtint_t(1)), // stride size for x ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(2.0)), // alpha - ::testing::Values(double(1.0)) // beta + ::testing::Values(double(2.3), double(1.0), + double(-1.0), double(0.0)), // alpha + ::testing::Values(double(-4.9), double(1.0), + double(-1.0), double(0.0)), // beta ), ::daxpbyvGenericTestPrint() ); @@ -156,8 +160,10 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Range(gtint_t(10), gtint_t(31), 10), // m size of vector takes values from 10 to 100 with step size of 10. ::testing::Values(gtint_t(7)), // stride size for x ::testing::Values(gtint_t(3)), // stride size for y - ::testing::Values(double(4.3), double(0.0)), // alpha - ::testing::Values(double(-1.9), double(0.0)) // beta + ::testing::Values(double(2.3), double(1.0), + double(-1.0), double(0.0)), // alpha + ::testing::Values(double(-4.9), double(1.0), + double(-1.0), double(0.0)) // beta ), ::daxpbyvGenericTestPrint() ); @@ -174,8 +180,10 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Range(gtint_t(10), gtint_t(31), 10), // m size of vector takes values from 10 to 100 with step size of 10. ::testing::Values(gtint_t(11), gtint_t(-11)), // stride size for x ::testing::Values(gtint_t(-3), gtint_t(4)), // stride size for y - ::testing::Values(double(4.7)), // alpha - ::testing::Values(double(-2.5)) // beta + ::testing::Values(double(2.3), double(1.0), + double(-1.0), double(0.0)), // alpha + ::testing::Values(double(-4.9), double(1.0), + double(-1.0), double(0.0)) // beta ), ::daxpbyvGenericTestPrint() ); diff --git a/gtestsuite/testsuite/level1/axpyv/daxpyv_evt_testing.cpp b/gtestsuite/testsuite/level1/axpyv/daxpyv_evt_testing.cpp index 2e1664bbf..6ada9ca75 100644 --- a/gtestsuite/testsuite/level1/axpyv/daxpyv_evt_testing.cpp +++ b/gtestsuite/testsuite/level1/axpyv/daxpyv_evt_testing.cpp @@ -35,7 +35,7 @@ #include #include "test_axpyv.h" -class daxpyvEVTTest : +class daxpyvEVT : public ::testing::TestWithParam> {}; // alpha // Tests using random values as vector elements, // with exception values on the passed indices. -TEST_P(daxpyvEVTTest, ExceptionData) +TEST_P(daxpyvEVT, ExceptionData) { using T = double; //---------------------------------------------------------- @@ -85,7 +85,7 @@ TEST_P(daxpyvEVTTest, ExceptionData) // Test-case logger : Used to print the test-case details when vectors have exception value. // The string format is as follows : -// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_X_(xi)_(xexval)_(yi)_(yexval)_a(alpha_val) +// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_X_(xi)_(xexval)_(yi)_(yexval)_alpha(alpha_val) class daxpyvEVTVecPrint { public: @@ -102,17 +102,17 @@ public: double yexval = std::get<7>(str.param); double alpha = std::get<8>(str.param); #ifdef TEST_BLAS - std::string str_name = "daxpy_"; + std::string str_name = "blas_"; #elif TEST_CBLAS - std::string str_name = "cblas_daxpy"; -#else // #elif TEST_BLIS_TYPED - std::string str_name = "bli_daxpyv"; + std::string str_name = "cblas_"; +#else //#elif TEST_BLIS_TYPED + std::string str_name = "bli_"; #endif str_name += "_n" + std::to_string(n); str_name += ( conjx == 'n' )? "_noconjx" : "_conjx"; - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_incx" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_incy" + incy_str; std::string xexval_str = testinghelpers::get_value_string(xexval); std::string yexval_str = testinghelpers::get_value_string(yexval); @@ -121,14 +121,14 @@ public: str_name = str_name + "_Y_" + std::to_string(yj); str_name = str_name + "_" + yexval_str; std::string alpha_str = testinghelpers::get_value_string(alpha); - str_name = str_name + "_a" + alpha_str; + str_name = str_name + "_alpha" + alpha_str; return str_name; } }; // Test-case logger : Used to print the test-case details when alpha/beta have exception value. // The string format is as follows : -// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_a(alpha_val) +// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_alpha(alpha_val) class daxpyvAlphaBetaPrint { public: @@ -149,12 +149,12 @@ public: #endif str_name += "_n" + std::to_string(n); str_name += ( conjx == 'n' )? "_noconjx" : "_conjx"; - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_incx" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_incy" + incy_str; std::string alpha_str = testinghelpers::get_value_string(alpha); - str_name = str_name + "_a" + alpha_str; + str_name = str_name + "_alpha" + alpha_str; return str_name; } }; @@ -204,8 +204,8 @@ static double Inf = std::numeric_limits::infinity(); // Exception value testing(on X vector alone) with unit strides INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecX_unitStrides_zen3, - daxpyvEVTTest, + vecX_unitStrides_zen3, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -228,8 +228,8 @@ INSTANTIATE_TEST_SUITE_P( // Exception value testing(on Y vector alone) with unit strides INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecY_unitStrides_zen3, - daxpyvEVTTest, + vecY_unitStrides_zen3, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -252,8 +252,8 @@ INSTANTIATE_TEST_SUITE_P( // Exception value testing(on X and Y vectors) with unit strides INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecXY_unitStrides_zen3, - daxpyvEVTTest, + vecXY_unitStrides_zen3, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -307,8 +307,8 @@ INSTANTIATE_TEST_SUITE_P( */ // Exception value testing(on X vector alone) with unit strides INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecX_unitStrides_zen4, - daxpyvEVTTest, + vecX_unitStrides_zen4, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -331,8 +331,8 @@ INSTANTIATE_TEST_SUITE_P( // Exception value testing(on Y vector alone) with unit strides INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecY_unitStrides_zen4, - daxpyvEVTTest, + vecY_unitStrides_zen4, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -355,8 +355,8 @@ INSTANTIATE_TEST_SUITE_P( // Exception value testing(on X and Y vectors) with unit strides INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecXY_unitStrides_zen4, - daxpyvEVTTest, + vecXY_unitStrides_zen4, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -383,8 +383,8 @@ INSTANTIATE_TEST_SUITE_P( // We have to test a single scalar loop. The indices are such // that we cover _vecX_, _vecY_ and _vecXY_ cases together. INSTANTIATE_TEST_SUITE_P( - exceptionValue_vecXY_nonUnitStrides, - daxpyvEVTTest, + vecXY_nonUnitStrides, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -413,8 +413,8 @@ INSTANTIATE_TEST_SUITE_P( that code coverage is ensured in the respective kernels. */ INSTANTIATE_TEST_SUITE_P( - exceptionValue_alpha_unitStrides_zen3, - daxpyvEVTTest, + alpha_unitStrides_zen3, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -435,8 +435,8 @@ INSTANTIATE_TEST_SUITE_P( // Exception value testing(on alpha) with unit strided vectors INSTANTIATE_TEST_SUITE_P( - exceptionValue_alpha_unitStrides_zen4, - daxpyvEVTTest, + alpha_unitStrides_zen4, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED @@ -457,8 +457,8 @@ INSTANTIATE_TEST_SUITE_P( // Exception value testing(on alpha) with non-unit strided vectors INSTANTIATE_TEST_SUITE_P( - exceptionValue_alpha_nonUnitStrides, - daxpyvEVTTest, + alpha_nonUnitStrides, + daxpyvEVT, ::testing::Combine( ::testing::Values('n' // n: use x, c: use conj(x) #ifdef TEST_BLIS_TYPED diff --git a/gtestsuite/testsuite/level1/axpyv/daxpyv_generic.cpp b/gtestsuite/testsuite/level1/axpyv/daxpyv_generic.cpp index 6a133430d..fcc9b2866 100644 --- a/gtestsuite/testsuite/level1/axpyv/daxpyv_generic.cpp +++ b/gtestsuite/testsuite/level1/axpyv/daxpyv_generic.cpp @@ -71,31 +71,31 @@ TEST_P( daxpyvGenericTest, RandomData ) // Test-case logger : Used to print the test-case details when alpha/beta have exception value. // The string format is as follows : -// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_a(alpha_val) +// n(vec_size)_(conjx/noconjx)_incx(m)(abs_incx)_incy(m)(abs_incy)_alpha(alpha_val) class daxpyvGenericTestPrint { public: std::string operator()( testing::TestParamInfo> str) const { - char conjx = std::get<0>(str.param); + char conjx = std::get<0>(str.param); gtint_t n = std::get<1>(str.param); gtint_t incx = std::get<2>(str.param); gtint_t incy = std::get<3>(str.param); double alpha = std::get<4>(str.param); #ifdef TEST_BLAS - std::string str_name = "daxpy_"; + std::string str_name = "blas_"; #elif TEST_CBLAS - std::string str_name = "cblas_daxpy"; + std::string str_name = "cblas_"; #else //#elif TEST_BLIS_TYPED - std::string str_name = "bli_daxpyv"; + std::string str_name = "bli_"; #endif str_name += "_n" + std::to_string(n); str_name += ( conjx == 'n' )? "_noconjx" : "_conjx"; - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_incx" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_incy" + incy_str; - std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); - str_name = str_name + "_a" + alpha_str; + std::string alpha_str = ( alpha >= 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); + str_name = str_name + "_alpha" + alpha_str; return str_name; } }; @@ -109,7 +109,8 @@ INSTANTIATE_TEST_SUITE_P( ::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)), // stride size for x ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(2.3), double(-4.1)) // alpha + ::testing::Values(double(0.0), double(1.0), + double(-1.0), double(4.1)) // alpha ), ::daxpyvGenericTestPrint() ); @@ -126,7 +127,8 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(3), gtint_t(30), gtint_t(112)), // m size of vector ::testing::Values(gtint_t(1)), // stride size for x ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(2.0)) // alpha + ::testing::Values(double(0.0), double(1.0), + double(-1.0), double(4.1)) // alpha ), ::daxpyvGenericTestPrint() ); @@ -143,7 +145,8 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(gtint_t(3), gtint_t(30), gtint_t(112)), // m size of vector ::testing::Values(gtint_t(2)), // stride size for x ::testing::Values(gtint_t(3)), // stride size for y - ::testing::Values(double(4.1)) // alpha + ::testing::Values(double(0.0), double(1.0), + double(-1.0), double(4.1)) // alpha ), ::daxpyvGenericTestPrint() ); @@ -160,7 +163,8 @@ INSTANTIATE_TEST_SUITE_P( ::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(-4)), // stride size for x ::testing::Values(gtint_t(-3)), // stride size for y - ::testing::Values(double(4.1)) // alpha + ::testing::Values(double(0.0), double(1.0), + double(-1.0), double(4.1)) // alpha ), ::daxpyvGenericTestPrint() ); @@ -174,18 +178,19 @@ INSTANTIATE_TEST_SUITE_P( aoclDynamicThresholds_unitStrides, daxpyvGenericTest, ::testing::Combine( - ::testing::Values('n'), // n: use x, c: use conj(x) + ::testing::Values('n'), // n: use x, c: use conj(x) ::testing::Values(// Sizes are based on the thresholds - gtint_t(4000), // nt_ideal = 1 - gtint_t(11000), // nt_ideal = 4 - gtint_t(300000), // nt_ideal = 8 - gtint_t(750000), // nt_ideal = 16 - gtint_t(2600000), // nt_ideal = 32 - gtint_t(4000000)), // nt_ideal = 64 + gtint_t(4000), // nt_ideal = 1 + gtint_t(11000), // nt_ideal = 4 + gtint_t(300000), // nt_ideal = 8 + gtint_t(750000), // nt_ideal = 16 + gtint_t(2600000), // nt_ideal = 32 + gtint_t(4000000)), // nt_ideal = 64 - ::testing::Values(gtint_t(1)), // stride size for x - ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(4.1)) // alpha + ::testing::Values(gtint_t(1)), // stride size for x + ::testing::Values(gtint_t(1)), // stride size for y + ::testing::Values(double(0.0), double(1.0), + double(-1.0), double(4.1)) // alpha ), ::daxpyvGenericTestPrint() ); @@ -195,18 +200,19 @@ INSTANTIATE_TEST_SUITE_P( aoclDynamicThresholds_nonUnitStrides, daxpyvGenericTest, ::testing::Combine( - ::testing::Values('n'), // n: use x, c: use conj(x) + ::testing::Values('n'), // n: use x, c: use conj(x) ::testing::Values(// Sizes are based on the thresholds - gtint_t(4000), // nt_ideal = 1 - gtint_t(11000), // nt_ideal = 4 - gtint_t(300000), // nt_ideal = 8 - gtint_t(750000), // nt_ideal = 16 - gtint_t(2600000), // nt_ideal = 32 - gtint_t(4000000)), // nt_ideal = 64 + gtint_t(4000), // nt_ideal = 1 + gtint_t(11000), // nt_ideal = 4 + gtint_t(300000), // nt_ideal = 8 + gtint_t(750000), // nt_ideal = 16 + gtint_t(2600000), // nt_ideal = 32 + gtint_t(4000000)), // nt_ideal = 64 - ::testing::Values(gtint_t(3)), // stride size for x - ::testing::Values(gtint_t(3)), // stride size for y - ::testing::Values(double(4.1)) // alpha + ::testing::Values(gtint_t(3)), // stride size for x + ::testing::Values(gtint_t(3)), // stride size for y + ::testing::Values(double(0.0), double(1.0), + double(-1.0), double(4.1)) // alpha ), ::daxpyvGenericTestPrint() ); diff --git a/gtestsuite/testsuite/level1/copyv/dcopyv_generic.cpp b/gtestsuite/testsuite/level1/copyv/dcopyv_generic.cpp index 1c7824b8f..118562812 100644 --- a/gtestsuite/testsuite/level1/copyv/dcopyv_generic.cpp +++ b/gtestsuite/testsuite/level1/copyv/dcopyv_generic.cpp @@ -80,17 +80,17 @@ public: gtint_t incx = std::get<2>(str.param); gtint_t incy = std::get<3>(str.param); #ifdef TEST_BLAS - std::string str_name = "dcopy_"; + std::string str_name = "blas_"; #elif TEST_CBLAS - std::string str_name = "cblas_dcopy"; + std::string str_name = "cblas_"; #else //#elif TEST_BLIS_TYPED - std::string str_name = "bli_dcopyv"; + std::string str_name = "bli_"; #endif str_name += "_" + std::to_string(n); str_name += "_" + std::string(&conjx, 1); - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_" + incy_str; return str_name; } diff --git a/gtestsuite/testsuite/ukr/axpbyv/daxpbyv_ukr.cpp b/gtestsuite/testsuite/ukr/axpbyv/daxpbyv_ukr.cpp index 601b794c2..91b355412 100644 --- a/gtestsuite/testsuite/ukr/axpbyv/daxpbyv_ukr.cpp +++ b/gtestsuite/testsuite/ukr/axpbyv/daxpbyv_ukr.cpp @@ -42,7 +42,8 @@ class daxpbyvUkrTest : gtint_t, // incx gtint_t, // incy double, // alpha - double>> {}; // beta + double, // beta + bool>> {}; // is_memory_test GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(daxpbyvUkrTest); @@ -70,6 +71,8 @@ TEST_P( daxpbyvUkrTest, AccuracyCheck ) T alpha = std::get<5>(GetParam()); // beta T beta = std::get<6>(GetParam()); + // is_memory_test + bool is_memory_test = std::get<7>(GetParam()); // Set the threshold for the errors: double thresh = 3 * testinghelpers::getEpsilon(); @@ -77,7 +80,7 @@ TEST_P( daxpbyvUkrTest, AccuracyCheck ) //---------------------------------------------------------- // Call generic test body using those parameters //---------------------------------------------------------- - test_axpbyv_ukr( ukr_fp, conj_x, n, incx, incy, alpha, beta, thresh ); + test_axpbyv_ukr( ukr_fp, conj_x, n, incx, incy, alpha, beta, thresh, is_memory_test ); } // Test-case logger : Used to print the test-case details for unit testing the kernels. @@ -86,25 +89,27 @@ TEST_P( daxpbyvUkrTest, AccuracyCheck ) class daxpbyvUkrTestPrint { public: std::string operator()( - testing::TestParamInfo> str) const { + testing::TestParamInfo> str) const { char conjx = std::get<1>(str.param); gtint_t n = std::get<2>(str.param); gtint_t incx = std::get<3>(str.param); gtint_t incy = std::get<4>(str.param); double alpha = std::get<5>(str.param); double beta = std::get<6>(str.param); + bool is_memory_test = std::get<7>(str.param); std::string str_name = "daxpbyv_ukr"; str_name += "_n" + std::to_string(n); str_name += ( conjx == 'n' )? "_noconjx" : "_conjx"; - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_incx" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_incy" + incy_str; - std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); - str_name = str_name + "_a" + alpha_str; - std::string beta_str = ( beta > 0) ? std::to_string(int(beta)) : "m" + std::to_string(int(std::abs(beta))); - str_name = str_name + "_b" + beta_str; + std::string alpha_str = ( alpha >= 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); + str_name = str_name + "_alpha" + alpha_str; + std::string beta_str = ( beta >= 0) ? std::to_string(int(beta)) : "m" + std::to_string(int(std::abs(beta))); + str_name = str_name + "_beta" + beta_str; + str_name += ( is_memory_test ) ? "_mem_test_enabled" : "_mem_test_disabled"; return str_name; } }; @@ -128,29 +133,29 @@ INSTANTIATE_TEST_SUITE_P( bli_daxpbyv_zen_int10_unitStrides, daxpbyvUkrTest, ::testing::Combine( - ::testing::Values(bli_daxpbyv_zen_int10), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values(bli_daxpbyv_zen_int10), // kernel address + ::testing::Values('n'), // use x, not conj(x) (since it is real) ::testing::Values(// Testing the loops standalone - gtint_t(40), // size n, for L40 - gtint_t(20), // L20 - gtint_t(8), // L8 - gtint_t(4), // L4 - gtint_t(2), // LScalar + gtint_t(40), // size n, for L40 + gtint_t(20), // L20 + gtint_t(8), // L8 + gtint_t(4), // L4 + gtint_t(2), // LScalar // Testing the loops with combination - // 3*L40 - gtint_t(120), - // 3*L40 + L20 - gtint_t(140), - // 3*L40 + L20 + L8 - gtint_t(148), - // 3*L40 + L20 + L8 + L4 - gtint_t(152), - // 3*L40 + L20 + L8 + L4 + LScalar - gtint_t(155)), - ::testing::Values(gtint_t(1)), // stride size for x - ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(2.2)), // alpha - ::testing::Values(double(-1.8)) // beta + gtint_t(120), // 3*L40 + gtint_t(140), // 3*L40 + L20 + gtint_t(148), // 3*L40 + L20 + L8 + gtint_t(152), // 3*L40 + L20 + L8 + L4 + gtint_t(155)), // 3*L40 + L20 + L8 + L4 + 3(LScalar) + ::testing::Values(gtint_t(1)), // stride size for x + ::testing::Values(gtint_t(1)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // beta + ::testing::Values(false, true) // is_memory_test ), ::daxpbyvUkrTestPrint() ); @@ -160,14 +165,19 @@ INSTANTIATE_TEST_SUITE_P( bli_daxpbyv_zen_int10_nonUnitStrides, daxpbyvUkrTest, ::testing::Combine( - ::testing::Values(bli_daxpbyv_zen_int10), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) - ::testing::Values(gtint_t(10), // n, size of the vector + ::testing::Values(bli_daxpbyv_zen_int10), // kernel address + ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values(gtint_t(10), // n, size of the vector gtint_t(25)), - ::testing::Values(gtint_t(5)), // stride size for x - ::testing::Values(gtint_t(3)), // stride size for y - ::testing::Values(double(2.2)), // alpha - ::testing::Values(double(-1.8)) // beta + ::testing::Values(gtint_t(5)), // stride size for x + ::testing::Values(gtint_t(3)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // beta + ::testing::Values(false, true) // is_memory_test ), ::daxpbyvUkrTestPrint() ); @@ -186,15 +196,20 @@ INSTANTIATE_TEST_SUITE_P( bli_daxpbyv_zen_int_unitStrides, daxpbyvUkrTest, ::testing::Combine( - ::testing::Values(bli_daxpbyv_zen_int), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) - ::testing::Values(gtint_t(16), // size n, for L16 - gtint_t(48), // 3*L16 - gtint_t(57)), // 3*L16 + 9(LScalar) - ::testing::Values(gtint_t(1)), // stride size for x - ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(2.2)), // alpha - ::testing::Values(double(-1.8)) // beta + ::testing::Values(bli_daxpbyv_zen_int), // kernel address + ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values(gtint_t(16), // size n, for L16 + gtint_t(48), // 3*L16 + gtint_t(57)), // 3*L16 + 9(LScalar) + ::testing::Values(gtint_t(1)), // stride size for x + ::testing::Values(gtint_t(1)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // beta + ::testing::Values(false, true) // is_memory_test ), ::daxpbyvUkrTestPrint() ); @@ -204,14 +219,19 @@ INSTANTIATE_TEST_SUITE_P( bli_daxpbyv_zen_int_nonUnitStrides, daxpbyvUkrTest, ::testing::Combine( - ::testing::Values(bli_daxpbyv_zen_int), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) - ::testing::Values(gtint_t(10), // n, size of the vector + ::testing::Values(bli_daxpbyv_zen_int), // kernel address + ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values(gtint_t(10), // n, size of the vector gtint_t(25)), - ::testing::Values(gtint_t(5)), // stride size for x - ::testing::Values(gtint_t(3)), // stride size for y - ::testing::Values(double(-4.1)), // alpha - ::testing::Values(double(3.9)) // beta + ::testing::Values(gtint_t(5)), // stride size for x + ::testing::Values(gtint_t(3)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // beta + ::testing::Values(false, true) // is_memory_test ), ::daxpbyvUkrTestPrint() ); diff --git a/gtestsuite/testsuite/ukr/axpbyv/test_axpbyv_ukr.h b/gtestsuite/testsuite/ukr/axpbyv/test_axpbyv_ukr.h index 0ecca3010..7c37a6bed 100644 --- a/gtestsuite/testsuite/ukr/axpbyv/test_axpbyv_ukr.h +++ b/gtestsuite/testsuite/ukr/axpbyv/test_axpbyv_ukr.h @@ -34,9 +34,11 @@ #pragma once +#include #include "level1/axpbyv/axpbyv.h" #include "level1/ref_axpbyv.h" #include "inc/check_error.h" +#include "common/testing_helpers.h" /** * @brief Generic test body for axpby operation. @@ -45,46 +47,84 @@ // The function is templatized based on the datatype and function-pointer type to the kernel. template static void test_axpbyv_ukr( FT ukr_fp, char conjx, gtint_t n, gtint_t incx, gtint_t incy, - T alpha, T beta, double thresh ) + T alpha, T beta, double thresh, bool is_memory_test = false ) { - //---------------------------------------------------------- - // Allocate the fixed memory and initialize - // vectors with random numbers. - //---------------------------------------------------------- + // Pointers to obtain the required memory. + T *x, *y, *y_ref, *x_copy; + gtint_t size_x = testinghelpers::buff_dim( n, incx ) * sizeof( T ); + gtint_t size_y = testinghelpers::buff_dim( n, incy ) * sizeof( T ); - T *x, *y, *y_ref; - gtint_t size_x = testinghelpers::buff_dim( n, incx ); - gtint_t size_y = testinghelpers::buff_dim( n, incy ); - x = ( T* )malloc( sizeof( T ) * size_x ); - y = ( T* )malloc( sizeof( T ) * size_y ); - y_ref = ( T* )malloc( sizeof( T ) * size_y ); + // Create the objects for the input and output operands + // The kernel does not expect the memory to be aligned + testinghelpers::ProtectedBuffer x_buffer( size_x, false, is_memory_test ); + testinghelpers::ProtectedBuffer y_buffer( size_y, false, is_memory_test ); + // For y_ref, we don't need different greenzones and any redzone. + // Thus, we pass is_memory_test as false + testinghelpers::ProtectedBuffer y_ref_buffer( size_y, false, false ); + // Creating x_copy, to save the contents of x(without any redzones) + testinghelpers::ProtectedBuffer x_copy_buffer( size_x, false, false ); + + // Acquire the first set of greenzones for x and y + x = ( T* )x_buffer.greenzone_1; + y = ( T* )y_buffer.greenzone_1; + y_ref = ( T* )y_ref_buffer.greenzone_1; // For y_ref, there is no greenzone_2 + x_copy = ( T* )x_copy_buffer.greenzone_1; // For x_copy, there is no greenzone_2 + + // Initiaize the memory with random data testinghelpers::datagenerators::randomgenerators( -10, 10, n, incx, x ); testinghelpers::datagenerators::randomgenerators( -10, 10, n, incy, y ); - // Copying y to y_ref, for comparision after computation - for( gtint_t i = 0; i < size_y; i += 1 ) - *( y_ref + i ) = *( y + i ); + // Copying the contents of y to y_ref and x to x_copy + memcpy( y_ref, y, size_y ); + memcpy( x_copy, x, size_x ); + + // Char conjx to BLIS conjx conversion + conj_t blis_conjx; + testinghelpers::char_to_blis_conj( conjx, &blis_conjx ); + + // Add signal handler for segmentation fault + testinghelpers::ProtectedBuffer::start_signal_handler(); + try + { + // Call the ukr function. + // This call is made irrespective of is_memory_test. + // This will check for out of bounds access with first redzone(if memory test is true) + // Else, it will just call the ukr function. + ukr_fp( blis_conjx, n, &alpha, x, incx, &beta, y, incy, nullptr ); + + if ( is_memory_test ) + { + // Acquire the pointers near the second redzone + x = ( T* )x_buffer.greenzone_2; + y = ( T* )y_buffer.greenzone_2; + + // Copy the data for x and y accordingly + memcpy( x, x_copy, size_x ); + memcpy( y, y_ref, size_y ); + + // Call the ukr function, to check with the second redzone. + ukr_fp( blis_conjx, n, &alpha, x, incx, &beta, y, incy, nullptr ); + } + } + catch(const std::exception& e) + { + // Reset to default signal handler + testinghelpers::ProtectedBuffer::stop_signal_handler(); + + // Show failure in case seg fault was detected + FAIL() << "Memory Test Failed"; + } + // Reset to default signal handler + testinghelpers::ProtectedBuffer::stop_signal_handler(); //---------------------------------------------------------- // Call reference implementation to get ref results. //---------------------------------------------------------- testinghelpers::ref_axpbyv( conjx, n, alpha, x, incx, beta, y_ref, incy ); - //---------------------------------------------------------- - // Call BLIS function. - //---------------------------------------------------------- - - conj_t blis_conjx; - testinghelpers::char_to_blis_conj( conjx, &blis_conjx ); - ukr_fp( blis_conjx, n, &alpha, x, incx, &beta, y, incy, nullptr ); - //---------------------------------------------------------- // Compute component-wise error. //---------------------------------------------------------- computediff( n, y, y_ref, incy, thresh ); - - free( x ); - free( y ); - free( y_ref ); } \ No newline at end of file diff --git a/gtestsuite/testsuite/ukr/axpyv/daxpyv_ukr.cpp b/gtestsuite/testsuite/ukr/axpyv/daxpyv_ukr.cpp index ebdfb5f90..614e8ba40 100644 --- a/gtestsuite/testsuite/ukr/axpyv/daxpyv_ukr.cpp +++ b/gtestsuite/testsuite/ukr/axpyv/daxpyv_ukr.cpp @@ -36,12 +36,13 @@ #include "test_axpyv_ukr.h" class daxpyvUkrTest : - public ::testing::TestWithParam> {}; // alpha + double, // alpha + bool>> {}; // is_memory_test GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(daxpyvUkrTest); @@ -67,6 +68,8 @@ TEST_P( daxpyvUkrTest, AccuracyCheck ) gtint_t incy = std::get<4>(GetParam()); // alpha T alpha = std::get<5>(GetParam()); + // is_memory_test + bool is_memory_test = std::get<6>(GetParam()); // Set the threshold for the errors: double thresh = 2 * testinghelpers::getEpsilon(); @@ -74,7 +77,7 @@ TEST_P( daxpyvUkrTest, AccuracyCheck ) //---------------------------------------------------------- // Call generic test body using those parameters //---------------------------------------------------------- - test_axpyv_ukr( ukr_fp, conj_x, n, incx, incy, alpha, thresh ); + test_axpyv_ukr( ukr_fp, conj_x, n, incx, incy, alpha, thresh, is_memory_test ); } // Test-case logger : Used to print the test-case details for unit testing the kernels. @@ -83,22 +86,24 @@ TEST_P( daxpyvUkrTest, AccuracyCheck ) class daxpyvUkrTestPrint { public: std::string operator()( - testing::TestParamInfo> str) const { + testing::TestParamInfo> str) const { char conjx = std::get<1>(str.param); gtint_t n = std::get<2>(str.param); gtint_t incx = std::get<3>(str.param); gtint_t incy = std::get<4>(str.param); double alpha = std::get<5>(str.param); + bool is_memory_test = std::get<6>(str.param); std::string str_name = "daxpyv_ukr"; str_name += "_n" + std::to_string(n); str_name += ( conjx == 'n' )? "_noconjx" : "_conjx"; - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_incx" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_incy" + incy_str; - std::string alpha_str = ( alpha > 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); - str_name = str_name + "_a" + alpha_str; + std::string alpha_str = ( alpha >= 0) ? std::to_string(int(alpha)) : "m" + std::to_string(int(std::abs(alpha))); + str_name = str_name + "_alpha" + alpha_str; + str_name += ( is_memory_test ) ? "_mem_test_enabled" : "_mem_test_disabled"; return str_name; } }; @@ -123,34 +128,30 @@ INSTANTIATE_TEST_SUITE_P( bli_daxpyv_zen_int10_unitStrides, daxpyvUkrTest, ::testing::Combine( - ::testing::Values(bli_daxpyv_zen_int10), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values(bli_daxpyv_zen_int10), // kernel address + ::testing::Values('n'), // use x, not conj(x) (since it is real) ::testing::Values(// Testing the loops standalone - gtint_t(52), // size n, for L52 - gtint_t(40), // L40 - gtint_t(20), // L20 - gtint_t(16), // L16 - gtint_t(8), // L8 - gtint_t(4), // L4 - gtint_t(2), // LScalar + gtint_t(52), // size n, for L52 + gtint_t(40), // L40 + gtint_t(20), // L20 + gtint_t(16), // L16 + gtint_t(8), // L8 + gtint_t(4), // L4 + gtint_t(2), // LScalar // Testing the loops with combination - // 3*L52 - gtint_t(156), - // 3*L52 + L40 - gtint_t(196), - // 3*L52 + L40 + L8 - gtint_t(204), - // 3*L52 + L40 + L4 + LScalar(3) - gtint_t(203), - // 3*L52 + L20 - gtint_t(176), - // 3*L52 + L20 + L16 - gtint_t(192), - // 3*L52 + L20 + L8 + L4 + LScalar - gtint_t(191)), - ::testing::Values(gtint_t(1)), // stride size for x - ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(2.2)) // alpha + gtint_t(156), // 3*L52 + gtint_t(196), // 3*L52 + L40 + gtint_t(204), // 3*L52 + L40 + L8 + gtint_t(203), // 3*L52 + L40 + L4 + 3(LScalar) + gtint_t(176), // 3*L52 + L20 + gtint_t(192), // 3*L52 + L20 + L16 + gtint_t(191)), // 3*L52 + L20 + L8 + L4 + 3(LScalar) + ::testing::Values(gtint_t(1)), // stride size for x + ::testing::Values(gtint_t(1)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(false, true) // is_memory_test ), ::daxpyvUkrTestPrint() ); @@ -160,13 +161,16 @@ INSTANTIATE_TEST_SUITE_P( bli_daxpyv_zen_int10_nonUnitStrides, daxpyvUkrTest, ::testing::Combine( - ::testing::Values(bli_daxpyv_zen_int10), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) - ::testing::Values(gtint_t(10), // n, size of the vector + ::testing::Values(bli_daxpyv_zen_int10), // kernel address + ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values(gtint_t(10), // n, size of the vector gtint_t(25)), - ::testing::Values(gtint_t(5)), // stride size for x - ::testing::Values(gtint_t(3)), // stride size for y - ::testing::Values(double(-4.1)) // alpha + ::testing::Values(gtint_t(5)), // stride size for x + ::testing::Values(gtint_t(3)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(false, true) // is_memory_test ), ::daxpyvUkrTestPrint() ); @@ -185,14 +189,17 @@ INSTANTIATE_TEST_SUITE_P( bli_daxpyv_zen_int_unitStrides, daxpyvUkrTest, ::testing::Combine( - ::testing::Values(bli_daxpyv_zen_int), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) - ::testing::Values(gtint_t(16), // size n, for L16 - gtint_t(48), // 3*L16 - gtint_t(89)), // 5*L16 + 9(scalar) - ::testing::Values(gtint_t(1)), // stride size for x - ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(-4.1)) // alpha + ::testing::Values(bli_daxpyv_zen_int), // kernel address + ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values(gtint_t(16), // size n, for L16 + gtint_t(48), // 3*L16 + gtint_t(89)), // 5*L16 + 9(scalar) + ::testing::Values(gtint_t(1)), // stride size for x + ::testing::Values(gtint_t(1)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(false, true) // is_memory_test ), ::daxpyvUkrTestPrint() ); @@ -202,13 +209,16 @@ INSTANTIATE_TEST_SUITE_P( bli_daxpyv_zen_int_nonUnitStrides, daxpyvUkrTest, ::testing::Combine( - ::testing::Values(bli_daxpyv_zen_int), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) - ::testing::Values(gtint_t(10), // n, size of the vector + ::testing::Values(bli_daxpyv_zen_int), // kernel address + ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values(gtint_t(10), // n, size of the vector gtint_t(25)), - ::testing::Values(gtint_t(5)), // stride size for x - ::testing::Values(gtint_t(3)), // stride size for y - ::testing::Values(double(2.2)) // alpha + ::testing::Values(gtint_t(5)), // stride size for x + ::testing::Values(gtint_t(3)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(false, true) // is_memory_test ), ::daxpyvUkrTestPrint() ); @@ -234,30 +244,27 @@ INSTANTIATE_TEST_SUITE_P( daxpyvUkrTest, ::testing::Combine( ::testing::Values(bli_daxpyv_zen_int_avx512), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values('n'), // use x, not conj(x) (since it is real) ::testing::Values(// Testing the loops standalone - gtint_t(64), // size n, for L64 - gtint_t(32), // L32 - gtint_t(16), // L16 - gtint_t(8), // L8 - gtint_t(4), // L4 - gtint_t(3), // LScalar + gtint_t(64), // size n, for L64 + gtint_t(32), // L32 + gtint_t(16), // L16 + gtint_t(8), // L8 + gtint_t(4), // L4 + gtint_t(3), // LScalar // Testing the loops with combinations - // 5*L64 - gtint_t(320), - // 3*L64 + L32 - gtint_t(352), - // 3*L64 + L32 + L16 - gtint_t(368), - // 3*L64 + L32 + L16 + L8 - gtint_t(376), - // 3*L64 + L32 + L16 + L8 + L4 - gtint_t(380), - // 3*L64 + L32 + L16 + L8 + L4 + LScalar - gtint_t(383)), - ::testing::Values(gtint_t(1)), // stride size for x - ::testing::Values(gtint_t(1)), // stride size for y - ::testing::Values(double(2.2)) // alpha + gtint_t(320), // 5*L64 + gtint_t(352), // 5*L64 + L32 + gtint_t(368), // 5*L64 + L32 + L16 + gtint_t(376), // 5*L64 + L32 + L16 + L8 + gtint_t(380), // 5*L64 + L32 + L16 + L8 + L4 + gtint_t(383)), // 5*L64 + L32 + L16 + L8 + L4 + 3(LScalar) + ::testing::Values(gtint_t(1)), // stride size for x + ::testing::Values(gtint_t(1)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(false, true) // is_memory_test ), ::daxpyvUkrTestPrint() ); @@ -268,12 +275,15 @@ INSTANTIATE_TEST_SUITE_P( daxpyvUkrTest, ::testing::Combine( ::testing::Values(bli_daxpyv_zen_int_avx512), // kernel address - ::testing::Values('n'), // use x, not conj(x) (since it is real) - ::testing::Values(gtint_t(10), // n, size of the vector + ::testing::Values('n'), // use x, not conj(x) (since it is real) + ::testing::Values(gtint_t(10), // n, size of the vector gtint_t(25)), - ::testing::Values(gtint_t(5)), // stride size for x - ::testing::Values(gtint_t(3)), // stride size for y - ::testing::Values(double(-4.1)) // alpha + ::testing::Values(gtint_t(5)), // stride size for x + ::testing::Values(gtint_t(3)), // stride size for y + ::testing::Values(double(1.0), double(-1.0), + double(2.2), double(-4.1), + double(0.0)), // alpha + ::testing::Values(false, true) // is_memory_test ), ::daxpyvUkrTestPrint() ); diff --git a/gtestsuite/testsuite/ukr/axpyv/test_axpyv_ukr.h b/gtestsuite/testsuite/ukr/axpyv/test_axpyv_ukr.h index 364337ee9..25c42d065 100644 --- a/gtestsuite/testsuite/ukr/axpyv/test_axpyv_ukr.h +++ b/gtestsuite/testsuite/ukr/axpyv/test_axpyv_ukr.h @@ -34,9 +34,11 @@ #pragma once +#include #include "level1/axpyv/axpyv.h" #include "level1/ref_axpyv.h" #include "inc/check_error.h" +#include "common/testing_helpers.h" /** * @brief Generic test body for axpby operation. @@ -45,45 +47,85 @@ // The function is templatized based on the datatype and function-pointer type to the kernel. template static void test_axpyv_ukr( FT ukr_fp, char conjx, gtint_t n, gtint_t incx, gtint_t incy, - T alpha, double thresh ) + T alpha, double thresh, bool is_memory_test = false ) { - //---------------------------------------------------------- - // Allocate the fixed memory and initialize - // vectors with random numbers. - //---------------------------------------------------------- + // Pointers to obtain the required memory. + T *x, *y, *y_ref, *x_copy; + gtint_t size_x = testinghelpers::buff_dim( n, incx ) * sizeof( T ); + gtint_t size_y = testinghelpers::buff_dim( n, incy ) * sizeof( T ); - T *x, *y, *y_ref; - gtint_t size_x = testinghelpers::buff_dim( n, incx ); - gtint_t size_y = testinghelpers::buff_dim( n, incy ); - x = ( T* )malloc( sizeof( T ) * size_x ); - y = ( T* )malloc( sizeof( T ) * size_y ); - y_ref = ( T* )malloc( sizeof( T ) * size_y ); + // Create the objects for the input and output operands + // The kernel does not expect the memory to be aligned + testinghelpers::ProtectedBuffer x_buffer( size_x, false, is_memory_test ); + testinghelpers::ProtectedBuffer y_buffer( size_y, false, is_memory_test ); + // For y_ref, we don't need different greenzones and any redzone. + // Thus, we pass is_memory_test as false + testinghelpers::ProtectedBuffer y_ref_buffer( size_y, false, false ); + // Creating x_copy, to save the contents of x(without any redzones) + testinghelpers::ProtectedBuffer x_copy_buffer( size_x, false, false ); + + // Acquire the first set of greenzones for x and y + x = ( T* )x_buffer.greenzone_1; + y = ( T* )y_buffer.greenzone_1; + y_ref = ( T* )y_ref_buffer.greenzone_1; // For y_ref, there is no greenzone_2 + x_copy = ( T* )x_copy_buffer.greenzone_1; // For x_copy, there is no greenzone_2 + + // Initiaize the memory with random data testinghelpers::datagenerators::randomgenerators( -10, 10, n, incx, x ); testinghelpers::datagenerators::randomgenerators( -10, 10, n, incy, y ); - // Copying y to y_ref, for comparision after computation - for( gtint_t i = 0; i < size_y; i += 1 ) - *( y_ref + i ) = *( y + i ); + // Copying the contents of y to y_ref and x to x_copy + memcpy( y_ref, y, size_y ); + memcpy( x_copy, x, size_x ); + + // Char conjx to BLIS conjx conversion + conj_t blis_conjx; + testinghelpers::char_to_blis_conj( conjx, &blis_conjx ); + + // Add signal handler for segmentation fault + testinghelpers::ProtectedBuffer::start_signal_handler(); + try + { + // Call the ukr function. + // This call is made irrespective of is_memory_test. + // This will check for out of bounds access with first redzone(if memory test is true) + // Else, it will just call the ukr function. + ukr_fp( blis_conjx, n, &alpha, x, incx, y, incy, nullptr ); + + if ( is_memory_test ) + { + // Acquire the pointers near the second redzone + x = ( T* )x_buffer.greenzone_2; + y = ( T* )y_buffer.greenzone_2; + + // Copy the data for x and y accordingly + memcpy( x, x_copy, size_x ); + memcpy( y, y_ref, size_y ); + + // Call the ukr function, to check with the second redzone. + ukr_fp( blis_conjx, n, &alpha, x, incx, y, incy, nullptr ); + } + } + catch(const std::exception& e) + { + // Reset to default signal handler + testinghelpers::ProtectedBuffer::stop_signal_handler(); + + // Show failure in case seg fault was detected + FAIL() << "Memory Test Failed"; + } + // Reset to default signal handler + testinghelpers::ProtectedBuffer::stop_signal_handler(); //---------------------------------------------------------- // Call reference implementation to get ref results. //---------------------------------------------------------- testinghelpers::ref_axpyv( conjx, n, alpha, x, incx, y_ref, incy ); - //---------------------------------------------------------- - // Call BLIS function. - //---------------------------------------------------------- - conj_t blis_conjx; - testinghelpers::char_to_blis_conj( conjx, &blis_conjx ); - ukr_fp( blis_conjx, n, &alpha, x, incx, y, incy, nullptr ); - //---------------------------------------------------------- // Compute component-wise error. //---------------------------------------------------------- computediff( n, y, y_ref, incy, thresh ); - - free( x ); - free( y ); - free( y_ref ); + } \ No newline at end of file diff --git a/gtestsuite/testsuite/ukr/copyv/dcopyv_ukr.cpp b/gtestsuite/testsuite/ukr/copyv/dcopyv_ukr.cpp index aaeaa3af3..5d5653dc3 100644 --- a/gtestsuite/testsuite/ukr/copyv/dcopyv_ukr.cpp +++ b/gtestsuite/testsuite/ukr/copyv/dcopyv_ukr.cpp @@ -36,11 +36,12 @@ #include "test_copyv_ukr.h" class dcopyvUkrTest : - public ::testing::TestWithParam> {}; + public ::testing::TestWithParam> {}; // is_memory_test GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(dcopyvUkrTest); @@ -61,6 +62,8 @@ TEST_P( dcopyvUkrTest, AccuracyCheck ) gtint_t incx = std::get<3>(GetParam()); // stride size for y: gtint_t incy = std::get<4>(GetParam()); + // is_memory_test + bool is_memory_test = std::get<5>(GetParam()); // Set the threshold for the errors: double thresh = testinghelpers::getEpsilon(); @@ -68,7 +71,7 @@ TEST_P( dcopyvUkrTest, AccuracyCheck ) //---------------------------------------------------------- // Call generic test body using those parameters //---------------------------------------------------------- - test_copyv_ukr( ukr_fp, conjx, n, incx, incy, thresh ); + test_copyv_ukr( ukr_fp, conjx, n, incx, incy, thresh, is_memory_test ); } // Used to generate a test case with a sensible name. @@ -78,19 +81,21 @@ TEST_P( dcopyvUkrTest, AccuracyCheck ) class dcopyvUkrTestPrint { public: std::string operator()( - testing::TestParamInfo> str) const { + testing::TestParamInfo> str) const { char conjx = std::get<1>(str.param); gtint_t n = std::get<2>(str.param); gtint_t incx = std::get<3>(str.param); gtint_t incy = std::get<4>(str.param); + bool is_memory_test = std::get<5>(str.param); std::string str_name = "dcopyv_ukr"; str_name += "_n" + std::to_string(n); str_name += "_conjx" + std::string(&conjx, 1); - std::string incx_str = ( incx > 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); + std::string incx_str = ( incx >= 0) ? std::to_string(incx) : "m" + std::to_string(std::abs(incx)); str_name += "_incx" + incx_str; - std::string incy_str = ( incy > 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); + std::string incy_str = ( incy >= 0) ? std::to_string(incy) : "m" + std::to_string(std::abs(incy)); str_name += "_incy" + incy_str; + str_name += ( is_memory_test ) ? "_mem_test_enabled" : "_mem_test_disabled"; return str_name; } }; @@ -124,20 +129,15 @@ INSTANTIATE_TEST_SUITE_P( gtint_t(4), // L4 gtint_t(3), // LScalar // Testing the loops with combinations - // 5*L64 - gtint_t(320), - // 3*L64 + L32 - gtint_t(352), - // 3*L64 + L32 + L16 - gtint_t(368), - // 3*L64 + L32 + L16 + L8 - gtint_t(376), - // 3*L64 + L32 + L16 + L8 + L4 - gtint_t(380), - // 3*L64 + L32 + L16 + L8 + L4 + LScalar - gtint_t(383)), - ::testing::Values(gtint_t(1)), // stride size for x - ::testing::Values(gtint_t(1)) // stride size for y + gtint_t(320), // 5*L64 + gtint_t(352), // 5*L64 + L32 + gtint_t(368), // 5*L64 + L32 + L16 + gtint_t(376), // 5*L64 + L32 + L16 + L8 + gtint_t(380), // 5*L64 + L32 + L16 + L8 + L4 + gtint_t(383)), // 5*L64 + L32 + L16 + L8 + L4 + 3(LScalar) + ::testing::Values(gtint_t(1)), // stride size for x + ::testing::Values(gtint_t(1)), // stride size for y + ::testing::Values(false, true) // is_memory_test ), ::dcopyvUkrTestPrint() ); @@ -148,10 +148,11 @@ INSTANTIATE_TEST_SUITE_P( dcopyvUkrTest, ::testing::Combine( ::testing::Values(bli_dcopyv_zen_int), - ::testing::Values('n'), // conjugate parameter, 'n' for dcopyv + ::testing::Values('n'), // conjugate parameter, 'n' for dcopyv ::testing::Values(gtint_t(25), gtint_t(37)), // size of the vector - ::testing::Values(gtint_t(5)), // stride size for x - ::testing::Values(gtint_t(3)) // stride size for y + ::testing::Values(gtint_t(5)), // stride size for x + ::testing::Values(gtint_t(3)), // stride size for y + ::testing::Values(false, true) // is_memory_test ), ::dcopyvUkrTestPrint() ); diff --git a/gtestsuite/testsuite/ukr/copyv/test_copyv_ukr.h b/gtestsuite/testsuite/ukr/copyv/test_copyv_ukr.h index 0a6705bc6..e8c816a8e 100644 --- a/gtestsuite/testsuite/ukr/copyv/test_copyv_ukr.h +++ b/gtestsuite/testsuite/ukr/copyv/test_copyv_ukr.h @@ -34,35 +34,87 @@ #pragma once +#include #include "level1/copyv/copyv.h" #include "level1/ref_copyv.h" #include "inc/check_error.h" +#include "common/testing_helpers.h" /** * @brief Generic test body for copyv operation. */ template -static void test_copyv_ukr( FT ukr_fp, char conjx, gtint_t n, gtint_t incx, gtint_t incy, double thresh ) +static void test_copyv_ukr( FT ukr_fp, char conjx, gtint_t n, gtint_t incx, gtint_t incy, double thresh, bool is_memory_test = false ) { - //---------------------------------------------------------- - // Allocate the fixed memory and initialize - // vectors with random numbers. - //---------------------------------------------------------- + // Pointers to obtain the required memory. + T *x, *y, *y_ref, *x_copy; + gtint_t size_x = testinghelpers::buff_dim( n, incx ) * sizeof( T ); + gtint_t size_y = testinghelpers::buff_dim( n, incy ) * sizeof( T ); - T *x, *y, *y_ref; - gtint_t size_x = testinghelpers::buff_dim( n, incx ); - gtint_t size_y = testinghelpers::buff_dim( n, incy ); - x = ( T* )malloc( sizeof( T ) * size_x ); - y = ( T* )malloc( sizeof( T ) * size_y ); - y_ref = ( T* )malloc( sizeof( T ) * size_y ); + // Create the objects for the input and output operands + // The kernel does not expect the memory to be aligned + testinghelpers::ProtectedBuffer x_buffer( size_x, false, is_memory_test ); + testinghelpers::ProtectedBuffer y_buffer( size_y, false, is_memory_test ); + // For y_ref, we don't need different greenzones and any redzone. + // Thus, we pass is_memory_test as false + testinghelpers::ProtectedBuffer y_ref_buffer( size_y, false, false ); + // Creating x_copy, to save the contents of x(without any redzones) + testinghelpers::ProtectedBuffer x_copy_buffer( size_x, false, false ); + + // Acquire the first set of greenzones for x and y + x = ( T* )x_buffer.greenzone_1; + y = ( T* )y_buffer.greenzone_1; + y_ref = ( T* )y_ref_buffer.greenzone_1; // For y_ref, there is no greenzone_2 + x_copy = ( T* )x_copy_buffer.greenzone_1; // For x_copy, there is no greenzone_2 + + // Initiaize the memory with random data testinghelpers::datagenerators::randomgenerators( -10, 10, n, incx, x ); testinghelpers::datagenerators::randomgenerators( -10, 10, n, incy, y ); - // Copying y to y_ref, for comparision after computation - for( gtint_t i = 0; i < size_y; i += 1 ) - *( y_ref + i ) = *( y + i ); + // Copying the contents of y to y_ref and x to x_copy + memcpy( y_ref, y, size_y ); + memcpy( x_copy, x, size_x ); + + // Char conjx to BLIS conjx conversion + conj_t blis_conjx; + testinghelpers::char_to_blis_conj( conjx, &blis_conjx ); + + // Add signal handler for segmentation fault + testinghelpers::ProtectedBuffer::start_signal_handler(); + try + { + // Call the ukr function. + // This call is made irrespective of is_memory_test. + // This will check for out of bounds access with first redzone(if memory test is true) + // Else, it will just call the ukr function. + ukr_fp( blis_conjx, n, x, incx, y, incy, nullptr ); + + if ( is_memory_test ) + { + // Acquire the pointers near the second redzone + x = ( T* )x_buffer.greenzone_2; + y = ( T* )y_buffer.greenzone_2; + + // Copy the data for x and y accordingly + memcpy( x, x_copy, size_x ); + memcpy( y, y_ref, size_y ); + + // Call the ukr function, to check with the second redzone. + ukr_fp( blis_conjx, n, x, incx, y, incy, nullptr ); + } + } + catch(const std::exception& e) + { + // Reset to default signal handler + testinghelpers::ProtectedBuffer::stop_signal_handler(); + + // Show failure in case seg fault was detected + FAIL() << "Memory Test Failed"; + } + // Reset to default signal handler + testinghelpers::ProtectedBuffer::stop_signal_handler(); //---------------------------------------------------------- // Call reference implementation to get ref results. @@ -70,19 +122,8 @@ static void test_copyv_ukr( FT ukr_fp, char conjx, gtint_t n, gtint_t incx, gtin testinghelpers::ref_copyv( conjx, n, x, incx, y_ref, incy ); - //---------------------------------------------------------- - // Call BLIS function. - //---------------------------------------------------------- - conj_t blis_conjx; - testinghelpers::char_to_blis_conj( conjx, &blis_conjx ); - ukr_fp( blis_conjx, n, x, incx, y, incy, nullptr ); - //---------------------------------------------------------- // Compute error. //---------------------------------------------------------- computediff( n, y, y_ref, incy ); - - free( x ); - free( y ); - free( y_ref ); } \ No newline at end of file