// MIT License
//
// Copyright (c) 2022 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.

#include "test_hipcub_device_segmented_sort.hpp"

#define SUITE HipcubDeviceSegmentedSort

#define INSTANTIATE(...) INSTANTIATE_TYPED_TEST(SUITE, __VA_ARGS__)

#cmakedefine HIPCUB_TEST_SUITE_SLICE @HIPCUB_TEST_SUITE_SLICE@
#cmakedefine HIPCUB_TEST_TYPE_SLICE  @HIPCUB_TEST_TYPE_SLICE@

#if   HIPCUB_TEST_SUITE_SLICE == 0
    TYPED_TEST_P(SUITE, SortKeys                ) { sort_keys<TestFixture>(); }
    REGISTER_TYPED_TEST_SUITE_P(SUITE, SortKeys);
#elif HIPCUB_TEST_SUITE_SLICE == 1
    TYPED_TEST_P(SUITE, SortPairs               ) { sort_pairs<TestFixture>(); }
    REGISTER_TYPED_TEST_SUITE_P(SUITE, SortPairs);
#elif HIPCUB_TEST_SUITE_SLICE == 2
    TYPED_TEST_P(SUITE, SortKeysDoubleBuffer    ) { sort_keys_double_buffer<TestFixture>(); }
    REGISTER_TYPED_TEST_SUITE_P(SUITE, SortKeysDoubleBuffer);
#elif HIPCUB_TEST_SUITE_SLICE == 3
    TYPED_TEST_P(SUITE, SortPairsDoubleBuffer   ) { sort_pairs_double_buffer<TestFixture>(); }
    REGISTER_TYPED_TEST_SUITE_P(SUITE, SortPairsDoubleBuffer);
#endif

#if   HIPCUB_TEST_TYPE_SLICE == 0
    INSTANTIATE(params<int,       int, SortMethod::SortAscending,         0,      100>) 
    INSTANTIATE(params<int,       int, SortMethod::SortDescending,        0,      100>) 
    INSTANTIATE(params<int,       int, SortMethod::StableSortAscending,   0,      100>) 
    INSTANTIATE(params<int,       int, SortMethod::StableSortDescending,  0,      100>) 

    INSTANTIATE(params<unsigned,  int, SortMethod::SortAscending,         10,     312>) 
    INSTANTIATE(params<unsigned,  int, SortMethod::SortDescending,        10,     312>) 
    INSTANTIATE(params<unsigned,  int, SortMethod::StableSortAscending,   10,     312>) 
    INSTANTIATE(params<unsigned,  int, SortMethod::StableSortDescending,  10,     312>) 

    INSTANTIATE(params<char,      int, SortMethod::SortAscending,         1,      1239>) 
    INSTANTIATE(params<char,      int, SortMethod::SortDescending,        1,      1239>) 
#elif HIPCUB_TEST_TYPE_SLICE == 1
    INSTANTIATE(params<char,      int, SortMethod::StableSortAscending,   1,      1239>) 
    INSTANTIATE(params<char,      int, SortMethod::StableSortDescending,  1,      1239>) 

    INSTANTIATE(params<float,     int, SortMethod::SortAscending,         0,      322>) 
    INSTANTIATE(params<float,     int, SortMethod::SortDescending,        0,      322>) 
    INSTANTIATE(params<float,     int, SortMethod::StableSortAscending,   0,      322>) 
    INSTANTIATE(params<float,     int, SortMethod::StableSortDescending,  0,      322>) 

    INSTANTIATE(params<double,    int, SortMethod::SortAscending,         321,    555>) 
    INSTANTIATE(params<double,    int, SortMethod::SortDescending,        321,    555>) 
    INSTANTIATE(params<double,    int, SortMethod::StableSortAscending,   321,    555>) 
    INSTANTIATE(params<double,    int, SortMethod::StableSortDescending,  321,    555>) 
#endif
