Files
TheRock/rocm-libraries/projects/rocblas/clients/gtest/blas1/rot_gtest.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

225 lines
12 KiB
C++

/* ************************************************************************
* Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell cop-
* ies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM-
* PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNE-
* CTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* ************************************************************************ */
#include "blas1_gtest.hpp"
#include "blas1/common_rot.hpp"
namespace
{
// ----------------------------------------------------------------------------
// BLAS1 testing template
// ----------------------------------------------------------------------------
template <template <typename...> class FILTER, blas1 BLAS1>
struct rot_test_template : public RocBLAS_Test<rot_test_template<FILTER, BLAS1>, FILTER>
{
// Filter for which types apply to this suite
static bool type_filter(const Arguments& arg)
{
return rocblas_blas1_dispatch<rot_test_template::template type_filter_functor>(arg);
}
// Filter for which functions apply to this suite
static bool function_filter(const Arguments& arg);
// Google Test name suffix based on parameters
static std::string name_suffix(const Arguments& arg)
{
RocBLAS_TestName<rot_test_template> name(arg.name);
name << rocblas_datatype2string(arg.a_type);
if(strstr(arg.function, "_bad_arg") != nullptr)
{
name << "_bad_arg";
}
else
{
constexpr bool is_rot = (BLAS1 == blas1::rot || BLAS1 == blas1::rot_batched
|| BLAS1 == blas1::rot_strided_batched);
constexpr bool is_rotg = (BLAS1 == blas1::rotg || BLAS1 == blas1::rotg_batched
|| BLAS1 == blas1::rotg_strided_batched);
constexpr bool is_rotmg = (BLAS1 == blas1::rotmg || BLAS1 == blas1::rotmg_batched
|| BLAS1 == blas1::rotmg_strided_batched);
constexpr bool is_batched
= (BLAS1 == blas1::rot_batched || BLAS1 == blas1::rotm_batched
|| BLAS1 == blas1::rotg_batched || BLAS1 == blas1::rotmg_batched);
constexpr bool is_strided
= (BLAS1 == blas1::rot_strided_batched || BLAS1 == blas1::rotm_strided_batched
|| BLAS1 == blas1::rotg_strided_batched
|| BLAS1 == blas1::rotmg_strided_batched);
if((is_rotg || is_rot) && arg.a_type != arg.b_type)
name << '_' << rocblas_datatype2string(arg.b_type);
if(is_rot && arg.compute_type != arg.a_type)
name << '_' << rocblas_datatype2string(arg.compute_type);
if(!is_rotg && !is_rotmg)
{
name << '_' << arg.N;
name << '_' << arg.incx;
}
if(is_strided && !is_rotg)
{
name << '_' << arg.stride_x;
}
if(is_rot || BLAS1 == blas1::rotm || BLAS1 == blas1::rotm_batched
|| BLAS1 == blas1::rotm_strided_batched)
{
name << '_' << arg.incy;
}
if(BLAS1 == blas1::rot_strided_batched || BLAS1 == blas1::rotm_strided_batched)
{
name << '_' << arg.stride_y;
}
if(BLAS1 == blas1::rotg_strided_batched)
{
name << '_' << arg.stride_a << '_' << arg.stride_b << '_' << arg.stride_c << '_'
<< arg.stride_d;
}
if(BLAS1 == blas1::rotm_strided_batched || BLAS1 == blas1::rotmg_strided_batched)
{
name << '_' << arg.stride_c;
}
if(is_batched || is_strided)
{
name << "_" << arg.batch_count;
}
}
if(arg.api & c_API_64)
{
name << "_I64";
}
if(arg.api & c_API_FORTRAN)
{
name << "_F";
}
return std::move(name);
}
};
// This tells whether the BLAS1 tests are enabled
template <blas1 BLAS1, typename Ti, typename To, typename Tc>
using rot_enabled = std::integral_constant<
bool,
((BLAS1 == blas1::rot || BLAS1 == blas1::rot_batched || BLAS1 == blas1::rot_strided_batched)
&& ((std::is_same_v<Ti, float> && std::is_same_v<Ti, To> && std::is_same_v<To, Tc>)
|| (std::is_same_v<Ti, double> && std::is_same_v<Ti, To> && std::is_same_v<To, Tc>)
|| (std::is_same_v<
Ti,
rocblas_float_complex> && std::is_same_v<To, float> && std::is_same_v<Tc, rocblas_float_complex>)
|| (std::is_same_v<
Ti,
rocblas_float_complex> && std::is_same_v<To, float> && std::is_same_v<Tc, float>)
|| (std::is_same_v<
Ti,
rocblas_double_complex> && std::is_same_v<To, double> && std::is_same_v<Tc, rocblas_double_complex>)
|| (std::is_same_v<
Ti,
rocblas_double_complex> && std::is_same_v<To, double> && std::is_same_v<Tc, double>)))
|| ((BLAS1 == blas1::rotg || BLAS1 == blas1::rotg_batched
|| BLAS1 == blas1::rotg_strided_batched)
&& std::is_same_v<To, Tc> && ((std::is_same_v<Ti, float> && std::is_same_v<Ti, To>) || (std::is_same_v<Ti, double> && std::is_same_v<Ti, To>) || (std::is_same_v<Ti, rocblas_float_complex> && std::is_same_v<To, float>) || (std::is_same_v<Ti, rocblas_double_complex> && std::is_same_v<To, double>)))
|| ((BLAS1 == blas1::rotm || BLAS1 == blas1::rotm_batched
|| BLAS1 == blas1::rotm_strided_batched)
&& std::is_same_v<
To,
Ti> && std::is_same_v<To, Tc> && (std::is_same_v<Ti, float> || std::is_same_v<Ti, double>))
|| ((BLAS1 == blas1::rotmg || BLAS1 == blas1::rotmg_batched
|| BLAS1 == blas1::rotmg_strided_batched)
&& std::is_same_v<
To,
Ti> && std::is_same_v<To, Tc> && (std::is_same_v<Ti, float> || std::is_same_v<Ti, double>))>;
// Creates tests for one of the BLAS 1 functions
// ARG passes 1-3 template arguments to the testing_* function
#define BLAS1_TESTING(NAME, ARG) \
struct blas1_##NAME \
{ \
template <typename Ti, typename To = Ti, typename Tc = To, typename = void> \
struct testing : rocblas_test_invalid \
{ \
}; \
\
template <typename Ti, typename To, typename Tc> \
struct testing<Ti, To, Tc, std::enable_if_t<rot_enabled<blas1::NAME, Ti, To, Tc>{}>> \
: rocblas_test_valid \
{ \
void operator()(const Arguments& arg) \
{ \
if(!strcmp(arg.function, #NAME)) \
testing_##NAME<ARG(Ti, To, Tc)>(arg); \
else if(!strcmp(arg.function, #NAME "_bad_arg")) \
testing_##NAME##_bad_arg<ARG(Ti, To, Tc)>(arg); \
else \
FAIL() << "Internal error: Test called with unknown function: " \
<< arg.function; \
} \
}; \
}; \
\
using NAME = rot_test_template<blas1_##NAME::template testing, blas1::NAME>; \
\
template <> \
inline bool NAME::function_filter(const Arguments& arg) \
{ \
return !strcmp(arg.function, #NAME) || !strcmp(arg.function, #NAME "_bad_arg"); \
} \
\
TEST_P(NAME, blas1) \
{ \
RUN_TEST_ON_THREADS_STREAMS( \
rocblas_blas1_dispatch<blas1_##NAME::template testing>(GetParam())); \
} \
\
INSTANTIATE_TEST_CATEGORIES(NAME)
#define ARG1(Ti, To, Tc) Ti
#define ARG2(Ti, To, Tc) Ti, To
#define ARG3(Ti, To, Tc) Ti, To, Tc
BLAS1_TESTING(rot, ARG3)
BLAS1_TESTING(rot_batched, ARG3)
BLAS1_TESTING(rot_strided_batched, ARG3)
BLAS1_TESTING(rotg, ARG2)
BLAS1_TESTING(rotg_batched, ARG2)
BLAS1_TESTING(rotg_strided_batched, ARG2)
BLAS1_TESTING(rotm, ARG1)
BLAS1_TESTING(rotm_batched, ARG1)
BLAS1_TESTING(rotm_strided_batched, ARG1)
BLAS1_TESTING(rotmg, ARG1)
BLAS1_TESTING(rotmg_batched, ARG1)
BLAS1_TESTING(rotmg_strided_batched, ARG1)
} // namespace