mirror of
https://github.com/amd/blis.git
synced 2026-04-20 15:48:50 +00:00
GTestSuite: Fix in swap (#266)
This commit is contained in:
committed by
GitHub
parent
979b547876
commit
50f3520c33
@@ -349,47 +349,6 @@ void computediff( std::string var_name, gtint_t n, T *blis_sol, T *ref_sol, gtin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Binary comparison of two vectors with length n and increment inc, printing variable names.
|
||||
*/
|
||||
template <typename T>
|
||||
void computediff( gtint_t n, T *blis_x, T *blis_x_ref, T *blis_y, T *blis_y_ref, gtint_t incx, gtint_t incy, bool nan_inf_check = false )
|
||||
{
|
||||
gtint_t abs_incx = std::abs(incx);
|
||||
gtint_t abs_incy = std::abs(incy);
|
||||
int idx, idy;
|
||||
ComparisonHelper comp_helper(VECTOR);
|
||||
comp_helper.nan_inf_check = nan_inf_check;
|
||||
comp_helper.binary_comparison = true;
|
||||
|
||||
// In case inc is negative in a call to BLIS APIs, we just access it from the end to the beginning,
|
||||
// so practically nothing changes. Access from beginning to end to optimize memory operations.
|
||||
for (gtint_t i = 0; i < n; i++)
|
||||
{
|
||||
comp_helper.i = i;
|
||||
idx = (incx > 0) ? (i * incx) : ( - ( n - i - 1 ) * incx );
|
||||
idy = (incy > 0) ? (i * incy) : ( - ( n - i - 1 ) * incy );
|
||||
ASSERT_PRED_FORMAT4(NumericalComparison<T>, "x", blis_x[idx], blis_y_ref[idy], comp_helper) << "incx = " << incx ;
|
||||
ASSERT_PRED_FORMAT4(NumericalComparison<T>, "y", blis_y[idy], blis_x_ref[idx], comp_helper) << "incy = " << incy; // Go through elements that are part of the array that should not have been modified by the
|
||||
// call to a BLIS API. Use the bitwise comparison for this case.
|
||||
// Random generator fills vector with T{-1.2345e38}
|
||||
if (i < n-1)
|
||||
{
|
||||
for (gtint_t j = 1; j < abs_incx; j++)
|
||||
{
|
||||
idx = (incx > 0) ? (i * incx) : ( - ( n - i - 1 ) * incx );
|
||||
ASSERT_PRED_FORMAT4(NumericalComparison<T>, "x", blis_x[i*abs_incx + j], T{-1.2345e38}, comp_helper) << "incx = " << incx << " This element is expected to not be modified.";
|
||||
}
|
||||
for (gtint_t j = 1; j < abs_incy; j++)
|
||||
{
|
||||
idy = (incy > 0) ? (i * incy) : ( - ( n - i - 1 ) * incy );
|
||||
ASSERT_PRED_FORMAT4(NumericalComparison<T>, "y", blis_y[i*abs_incy + j], T{-1.2345e38}, comp_helper) << "incy = " << incy << " This element is expected to not be modified.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Relative comparison of two vectors with length n and increment inc, printing variable name.
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "swapv.h"
|
||||
#include "level1/ref_swapv.h"
|
||||
#include "inc/check_error.h"
|
||||
|
||||
/**
|
||||
@@ -56,6 +57,7 @@ static void test_swapv( gtint_t n, gtint_t incx, gtint_t incy )
|
||||
std::vector<T> x_ref(x);
|
||||
std::vector<T> y_ref(y);
|
||||
|
||||
testinghelpers::ref_swapv<T>( n, x_ref.data(), incx, y_ref.data(), incy );
|
||||
//----------------------------------------------------------
|
||||
// Call BLIS function.
|
||||
//----------------------------------------------------------
|
||||
@@ -64,7 +66,8 @@ static void test_swapv( gtint_t n, gtint_t incx, gtint_t incy )
|
||||
//----------------------------------------------------------
|
||||
// Compute binary comparison
|
||||
//----------------------------------------------------------
|
||||
computediff<T>( n, x.data(), x_ref.data(), y.data(), y_ref.data(), incx, incy, false );
|
||||
computediff<T>( "x", n, x.data(), x_ref.data(), incx, false );
|
||||
computediff<T>( "y", n, y.data(), y_ref.data(), incy, false );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "level1/ref_swapv.h"
|
||||
#include "level1/swapv/swapv.h"
|
||||
#include "inc/check_error.h"
|
||||
|
||||
@@ -108,10 +108,16 @@ static void test_swapv_ukr( FT ukr, gtint_t n, gtint_t incx, gtint_t incy,
|
||||
// Reset to default signal handler
|
||||
testinghelpers::ProtectedBuffer::stop_signal_handler();
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Call reference implementation to get ref results.
|
||||
//----------------------------------------------------------
|
||||
testinghelpers::ref_swapv<T>( n, x_ref, incx, y_ref, incy );
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Compute binary comparison
|
||||
//----------------------------------------------------------
|
||||
computediff<T>( n, x, x_ref, y, y_ref, incx, incy, false );
|
||||
computediff<T>( "x", n, x, x_ref, incx, false );
|
||||
computediff<T>( "y", n, y, y_ref, incy, false );
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user