File: accuracy_test_checkstride.cpp

package info (click to toggle)
rocfft 6.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,672 kB
  • sloc: cpp: 55,735; python: 5,774; sh: 428; xml: 204; makefile: 56
file content (109 lines) | stat: -rw-r--r-- 4,787 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// 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 "accuracy_test.h"

extern bool fftw_compare;

inline auto param_checkstride()
{
    // checkstride requires us to copy data back to the host for
    // checking, which we only do when comparing against FFTW.
    if(!fftw_compare)
        return std::vector<fft_params>{};

    // tuples of length,stride,nbatch,dist to test.  strides are arranged so
    // there's space either between elements on the fastest dim, or
    // between dims, or both.
    std::vector<std::tuple<std::vector<size_t>, std::vector<size_t>, size_t, size_t>> sizes = {
        // 1D single kernel non-unit stride
        {{64}, {2}, 2, 140},
        // 1D single kernel unit stride but non-contiguous batch
        {{64}, {1}, 2, 80},
        // 1D odd length (to test odd-length R2C/C2R)
        {{15}, {2}, 2, 40},
        // 1D SBCC+SBRC
        {{8192}, {2}, 2, 17000},
        // 1D TRTRT
        {{24000}, {2}, 2, 50000},
        // 2D_RTRT
        {{20, 30}, {80, 2}, 2, 1700},
        {{40, 30}, {80, 2}, 2, 3600},
        // 2D_RTRT unit stride along fast dim
        {{20, 30}, {40, 1}, 2, 1000},
        {{40, 30}, {40, 1}, 2, 2000},
        // 2D_RC
        {{64, 64}, {130, 2}, 2, 8400},
        // 3D_RC
        {{64, 64, 64}, {8400, 130, 2}, 2, 540000},
        // 3D_RTRTRT
        {{2, 3, 4}, {40, 10, 2}, 2, 100},
        // bigger 3D_RTRTRT
        {{30, 40, 50}, {3000, 60, 1}, 2, 100000},
    };

    std::vector<fft_params> params;
    for(const auto trans_type : trans_type_range)
    {
        for(const auto& s : sizes)
        {
            for(const auto precision : precision_range_sp_dp)
            {
                for(const auto& types :
                    generate_types(trans_type, {fft_placement_notinplace}, true))
                {
                    for(bool callback : {true, false})
                    {
                        // callbacks don't work for planar
                        bool is_planar = std::get<2>(types) == fft_array_type_complex_planar
                                         || std::get<2>(types) == fft_array_type_hermitian_planar
                                         || std::get<3>(types) == fft_array_type_complex_planar
                                         || std::get<3>(types) == fft_array_type_hermitian_planar;
                        if(callback && is_planar)
                            continue;

                        fft_params param;

                        param.length               = std::get<0>(s);
                        param.istride              = std::get<1>(s);
                        param.ostride              = std::get<1>(s);
                        param.nbatch               = std::get<2>(s);
                        param.precision            = precision;
                        param.idist                = std::get<3>(s);
                        param.odist                = std::get<3>(s);
                        param.transform_type       = std::get<0>(types);
                        param.placement            = std::get<1>(types);
                        param.itype                = std::get<2>(types);
                        param.otype                = std::get<3>(types);
                        param.run_callbacks        = callback;
                        param.check_output_strides = true;
                        params.push_back(param);
                    }
                }
            }
        }
    }
    return params;
}

INSTANTIATE_TEST_SUITE_P(checkstride,
                         accuracy_test,
                         ::testing::ValuesIn(param_checkstride()),
                         accuracy_test::TestName);