// Copyright (C) 2024-2025 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 // copies 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 // IMPLIED, 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 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #pragma once #include #include #include #include #include #include #include #include #include #include #include "../testing/unittest/random.h" #include "bitwise_repro/bwr_db.hpp" #include /** * test_param_fixtures contains all parameters for typed_test suites */ // Input type parameter template > struct Params { using input_type = InputType; using execution_policy = thrust::detail::host_t; }; template struct Params, ExecutionPolicy> { using input_type = thrust::device_vector; using execution_policy = ExecutionPolicy; }; // Definition of typed test cases with given parameter type #define TESTS_DEFINE(x, y) \ template \ class x : public ::testing::Test \ { \ public: \ using input_type = typename Params::input_type; \ using execution_policy = typename Params::execution_policy; \ }; \ \ TYPED_TEST_SUITE(x, y); // Set of test parameter types class large_data { public: __host__ __device__ large_data() { data[0] = 0; } __host__ __device__ large_data(large_data const& val) { data[0] = val.data[0]; } __host__ __device__ large_data(int n) { data[0] = static_cast(n); } large_data& __host__ __device__ operator=(large_data const& val) { data[0] = val.data[0]; return *this; } bool __host__ __device__ operator==(large_data const& val) const { return data[0] == val.data[0]; } large_data& __host__ __device__ operator++() { ++data[0]; return *this; } __host__ __device__ operator int() const { return static_cast(data[0]); } int8_t data[512]; }; template bool __host__ __device__ operator==(T const& lhs, large_data const& rhs) { return static_cast(lhs).data[0] == rhs.data[0]; } // Host and device vectors of all type as a test parameter using FullTestsParams = ::testing::Types< Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params, std::decay_t>, Params>, Params>, Params>, Params>, Params>, Params, std::decay_t>, Params, std::decay_t>, Params>>; using FullWithLargeTypesTestsParams = ::testing::Types< Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params, std::decay_t>, Params>, Params>, Params>, Params>, Params>, Params, std::decay_t>, Params, std::decay_t>, Params>, Params>>; // Host and device vectors of signed type using VectorSignedTestsParams = ::testing::Types>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>>; // Host and device vectors of integer types as a test parameter using VectorIntegerTestsParams = ::testing::Types< Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>, Params>>; // Host and device vectors of signed integer types as a test parameter using VectorSignedIntegerTestsParams = ::testing::Types>, Params>, Params>, Params>, Params>, Params>>; // Host vectors of numerical types as a test parameter using HostVectorTestsParams = ::testing::Types>, Params>, Params>, Params>, Params>, Params>, Params>, Params>>; // Host vectors of integer types as a test parameter using HostVectorIntegerTestsParams = ::testing::Types>, Params>, Params>, Params>, Params>, Params>>; // Scalar numerical types using NumericalTestsParams = ::testing::Types, Params, Params, Params, Params, Params, Params, Params>; // Scalar integer types using IntegerTestsParams = ::testing::Types, Params, Params, Params, Params, Params>; // Scalar signed integer types using SignedIntegerTestsParams = ::testing::Types, Params, Params>; #if defined(_WIN32) && defined(__HIP__) // Scalar unsigned integer types of all lengths using UnsignedIntegerTestsParams = ::testing::Types, Params, Params>; using AllIntegerTestsParams = ::testing::Types, Params, Params, Params, Params, Params, Params, Params, Params>; #else // Scalar unsigned integer types of all lengths using UnsignedIntegerTestsParams = ::testing::Types, Params, Params, Params>; // Scalar all integer types using AllIntegerTestsParams = ::testing::Types, Params, Params, Params, Params, Params, Params, Params, Params, Params>; #endif // Scalar float types using FloatTestsParams = ::testing::Types, Params>; // --------------------Input Output test parameters-------- template struct ParamsInOut { using input_type = Input; using output_type = Output; }; // Definition of typed test cases with given parameter type #define TESTS_INOUT_DEFINE(x, y) \ template \ class x : public ::testing::Test \ { \ public: \ using input_type = typename ParamsInOut::input_type; \ using output_type = typename ParamsInOut::output_type; \ }; \ \ TYPED_TEST_SUITE(x, y); using AllInOutTestsParams = ::testing::Types< ParamsInOut, ParamsInOut, ParamsInOut, ParamsInOut, ParamsInOut, ParamsInOut, ParamsInOut, ParamsInOut, ParamsInOut, ParamsInOut, ParamsInOut>; // --------------------Pairs test parameters-------- template struct ParamsPairs { using first_type = T; using second_type = U; }; #define TESTS_PAIRS_DEFINE(x, y) \ template \ class x : public ::testing::Test \ { \ public: \ using first_type = typename ParamsPairs::first_type; \ using second_type = typename ParamsPairs::second_type; \ }; \ TYPED_TEST_SUITE(x, y); using PairsTestsParams = ::testing:: Types, ParamsPairs, ParamsPairs, ParamsPairs>;