Files
blis/gtestsuite/testsuite/level2/tpmv/ctpmv/ctpmv_generic.cpp
Smyth, Edward c32247678c GTestSuite: Packed APIs (hpmv, spmv, tpmv, tpsv)
Create gtestsuite programs for subset of packed matrix APIs. Priority is to
create framework with a basic set of tests - refinement of problem sizes
can be investigated later.

AMD-Internal: [CPUPL-7386]
2026-01-16 12:08:36 +00:00

151 lines
6.1 KiB
C++

/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2026, 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 "level2/tpmv/test_tpmv.h"
class ctpmvGeneric :
public ::testing::TestWithParam<std::tuple<char, // storage format
char, // uplo
char, // trans
char, // diag
gtint_t, // n
gtint_t // incx
>> {};
TEST_P( ctpmvGeneric, API )
{
using T = scomplex;
//----------------------------------------------------------
// Initialize values from the parameters passed through
// test suite instantiation (INSTANTIATE_TEST_SUITE_P).
//----------------------------------------------------------
// matrix storage format(row major, column major)
char storage = std::get<0>(GetParam());
// denotes whether matrix A is u,l
char uploa = std::get<1>(GetParam());
// denotes whether matrix A is n,c,t,h
char transa = std::get<2>(GetParam());
// denotes whether matrix diag is u,n
char diaga = std::get<3>(GetParam());
// matrix size n
gtint_t n = std::get<4>(GetParam());
// increment for x (incx):
gtint_t incx = std::get<5>(GetParam());
// Set the threshold for the errors:
// Check gtestsuite tpmv.h or netlib source code for reminder of the
// functionality from which we estimate operation count per element
// of output, and hence the multipler for epsilon.
double thresh;
if (n == 0)
thresh = 0.0;
else
thresh = 2*n*testinghelpers::getEpsilon<T>();
//----------------------------------------------------------
// Call test body using these parameters
//----------------------------------------------------------
#ifdef OPENMP_NESTED_1diff
#pragma omp parallel default(shared)
{
vary_num_threads();
//std::cout << "Inside 1diff parallel regions\n";
test_tpmv<T>( storage, uploa, transa, diaga, n, incx, thresh );
}
#elif OPENMP_NESTED_2
#pragma omp parallel default(shared)
{
#pragma omp parallel default(shared)
{
//std::cout << "Inside 2 parallel regions\n";
test_tpmv<T>( storage, uploa, transa, diaga, n, incx, thresh );
}
}
#elif OPENMP_NESTED_1
#pragma omp parallel default(shared)
{
//std::cout << "Inside 1 parallel region\n";
test_tpmv<T>( storage, uploa, transa, diaga, n, incx, thresh );
}
#else
//std::cout << "Not inside parallel region\n";
test_tpmv<T>( storage, uploa, transa, diaga, n, incx, thresh );
#endif
}
// Black box testing.
INSTANTIATE_TEST_SUITE_P(
BlackboxSmall,
ctpmvGeneric,
::testing::Combine(
::testing::Values('c'
#ifndef TEST_BLAS_LIKE
,'r'
#endif
), // storage format
::testing::Values('u','l'), // uploa
::testing::Values('n','t','c'), // transa
::testing::Values('n','u'), // diaga , n=NONUNIT_DIAG u=UNIT_DIAG
::testing::Range(gtint_t(1),gtint_t(21),1), // n
::testing::Values(gtint_t(-1),gtint_t(1), gtint_t(7)) // incx
),
::tpmvGenericPrint<scomplex>()
);
// Black box testing.
INSTANTIATE_TEST_SUITE_P(
BlackboxMedium,
ctpmvGeneric,
::testing::Combine(
::testing::Values('c'
#ifndef TEST_BLAS_LIKE
,'r'
#endif
), // storage format
::testing::Values('u','l'), // uploa
::testing::Values('n','t','c'), // transa
::testing::Values('n','u'), // diaga , n=NONUNIT_DIAG u=UNIT_DIAG
::testing::Values(gtint_t(25),
gtint_t(33),
gtint_t(98),
gtint_t(173),
gtint_t(211)
), // n
::testing::Values(gtint_t(-1),gtint_t(1), gtint_t(7)) // incxs
),
::tpmvGenericPrint<scomplex>()
);