Coverage Report

Created: 2025-08-11 07:29

/src/Simd/src/Test/TestConfig.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* Tests for Simd Library (http://ermig1979.github.io/Simd).
3
*
4
* Copyright (c) 2011-2025 Yermalayeu Ihar.
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to deal
8
* in the Software without restriction, including without limitation the rights
9
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
* copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*/
24
#ifndef __TestConfig_h__
25
#define __TestConfig_h__
26
27
#if defined(NDEBUG)
28
#define TEST_PERFORMANCE_TEST_ENABLE
29
#endif
30
31
#ifndef _CRT_SECURE_NO_WARNINGS
32
#define _CRT_SECURE_NO_WARNINGS
33
#endif
34
35
#include <stdlib.h>
36
37
#include <iostream>
38
#include <fstream>
39
#include <string>
40
#include <vector>
41
#include <list>
42
#include <map>
43
#include <algorithm>
44
#include <sstream>
45
#include <limits>
46
#include <iomanip>
47
#include <memory>
48
#include <exception>
49
#include <stdexcept>
50
#include <thread>
51
#include <mutex>
52
#include <cstring>
53
54
#define SIMD_STATIC
55
#include "Simd/SimdConfig.h"
56
#include "Simd/SimdLib.hpp"
57
58
#include "Simd/SimdConst.h"
59
#include "Simd/SimdMath.h"
60
#include "Simd/SimdEnable.h"
61
#include "Simd/SimdMemory.h"
62
#include "Simd/SimdBase.h"
63
#include "Simd/SimdSse41.h"
64
#include "Simd/SimdAvx2.h"
65
#include "Simd/SimdAvx512bw.h"
66
#include "Simd/SimdAvx512vnni.h"
67
#include "Simd/SimdAmxBf16.h"
68
#include "Simd/SimdNeon.h"
69
70
namespace Test
71
{
72
    template <class T> class Tensor;
73
74
    typedef std::string String;
75
    typedef std::vector<String> Strings;
76
    typedef Simd::View<Simd::Allocator> View;
77
    typedef std::vector<View> Views;
78
    typedef Simd::Point<ptrdiff_t> Point;
79
    typedef std::vector<Point> Points;
80
    typedef Point Size;
81
    typedef Simd::Rectangle<ptrdiff_t> Rect;
82
    typedef uint32_t Histogram[Simd::HISTOGRAM_SIZE];
83
    typedef std::vector<int> Ints;
84
    typedef std::vector<uint32_t> Sums;
85
    typedef std::vector<uint64_t> Sums64;
86
    typedef std::vector<float, Simd::Allocator<float> > Buffer32f;
87
    typedef std::vector<uint8_t> Buffer8u;
88
    typedef std::vector<float*> FloatPtrs;
89
    typedef std::vector<uint16_t*> UInt16Ptrs;
90
    typedef std::vector<uint8_t*> UInt8Ptrs;
91
    typedef std::vector<size_t> Shape;
92
    typedef Tensor<float> Tensor32f;
93
    typedef Tensor<uint8_t> Tensor8u;
94
    typedef Tensor<int8_t> Tensor8i;
95
    typedef Tensor<int32_t> Tensor32i;
96
    typedef Tensor<uint16_t> Tensor16u;
97
98
    const int E = 10;
99
    const int O = 9;
100
101
    extern double MINIMAL_TEST_EXECUTION_TIME;
102
    //extern double WARM_UP_TIME;
103
104
    const int DW = 48;
105
    const int DH = 64;
106
107
    const float EPS = 0.001f;
108
109
    extern int C;
110
    extern int H;    
111
    extern int W;
112
113
    extern uint32_t DISABLED_EXTENSIONS;
114
115
    extern String ROOT_PATH;
116
    extern String REAL_IMAGE;
117
118
    extern int LITTER_CPU_CACHE;
119
120
    enum DifferenceType
121
    {
122
        DifferenceAbsolute,
123
        DifferenceRelative,
124
        DifferenceBoth,
125
        DifferenceAny,
126
        DifferenceLogical,
127
    };
128
129
    //-------------------------------------------------------------------------------------------------
130
131
    SIMD_INLINE bool TestBase()
132
0
    {
133
0
        return (DISABLED_EXTENSIONS & 0x000000001) == 0;
134
0
    }
135
136
    SIMD_INLINE bool TestSse41()
137
0
    {
138
0
        return (DISABLED_EXTENSIONS & 0x000000002) == 0;
139
0
    }
140
141
    SIMD_INLINE bool TestAvx2()
142
0
    {
143
0
        return (DISABLED_EXTENSIONS & 0x000000004) == 0;
144
0
    }
145
146
147
    SIMD_INLINE bool TestAvx512bw()
148
0
    {
149
0
        return (DISABLED_EXTENSIONS & 0x000000008) == 0;
150
0
    }
151
152
153
    SIMD_INLINE bool TestAvx512vnni()
154
0
    {
155
0
        return (DISABLED_EXTENSIONS & 0x000000010) == 0;
156
0
    }
157
158
159
    SIMD_INLINE bool TestAmxBf16()
160
0
    {
161
0
        return (DISABLED_EXTENSIONS & 0x000000020) == 0;
162
0
    }
163
164
165
    SIMD_INLINE bool TestNeon()
166
0
    {
167
0
        return (DISABLED_EXTENSIONS & 0x000000002) == 0;
168
0
    }
169
}
170
171
#endif//__TestConfig_h__