-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_consistency.cpp
More file actions
66 lines (51 loc) · 2.66 KB
/
test_consistency.cpp
File metadata and controls
66 lines (51 loc) · 2.66 KB
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
#include "simd/feature_check.hpp"
#include <iostream>
int main() {
std::cout << "===== SIMD Feature Consistency Check =====" << std::endl;
std::cout << "Compile-time feature detection (simd::compile_time::has):" << std::endl;
std::cout << " SSE2: " << (simd::compile_time::has<simd::Feature::SSE2>() ? "Yes" : "No") << std::endl;
std::cout << " AVX: " << (simd::compile_time::has<simd::Feature::AVX>() ? "Yes" : "No") << std::endl;
std::cout << " AVX2: " << (simd::compile_time::has<simd::Feature::AVX2>() ? "Yes" : "No") << std::endl;
std::cout << " AVX512F: " << (simd::compile_time::has<simd::Feature::AVX512F>() ? "Yes" : "No") << std::endl;
std::cout << std::endl;
std::cout << "Macro consistency check (SIMD_HAS_*):" << std::endl;
std::cout << " SIMD_HAS_SSE2: " << (SIMD_HAS_SSE2 ? "Yes" : "No") << std::endl;
std::cout << " SIMD_HAS_AVX: " << (SIMD_HAS_AVX ? "Yes" : "No") << std::endl;
std::cout << " SIMD_HAS_AVX2: " << (SIMD_HAS_AVX2 ? "Yes" : "No") << std::endl;
std::cout << " SIMD_HAS_AVX512F: " << (SIMD_HAS_AVX512F ? "Yes" : "No") << std::endl;
std::cout << std::endl;
std::cout << "Convenience macro check (SIMD_*):" << std::endl;
std::cout << " SIMD_SSE2: " << (SIMD_SSE2 ? "Yes" : "No") << std::endl;
std::cout << " SIMD_AVX: " << (SIMD_AVX ? "Yes" : "No") << std::endl;
std::cout << " SIMD_AVX2: " << (SIMD_AVX2 ? "Yes" : "No") << std::endl;
std::cout << " SIMD_AVX512: " << (SIMD_AVX512 ? "Yes" : "No") << std::endl;
std::cout << std::endl;
bool consistent = true;
if (simd::compile_time::has<simd::Feature::SSE2>() != (SIMD_HAS_SSE2 != 0)) {
std::cout << "ERROR: SSE2 detection inconsistent!" << std::endl;
consistent = false;
}
if (simd::compile_time::has<simd::Feature::AVX>() != (SIMD_HAS_AVX != 0)) {
std::cout << "ERROR: AVX detection inconsistent!" << std::endl;
consistent = false;
}
if (simd::compile_time::has<simd::Feature::AVX2>() != (SIMD_HAS_AVX2 != 0)) {
std::cout << "ERROR: AVX2 detection inconsistent!" << std::endl;
consistent = false;
}
if (SIMD_HAS_AVX != SIMD_AVX) {
std::cout << "ERROR: SIMD_HAS_AVX != SIMD_AVX!" << std::endl;
consistent = false;
}
if (SIMD_HAS_AVX2 != SIMD_AVX2) {
std::cout << "ERROR: SIMD_HAS_AVX2 != SIMD_AVX2!" << std::endl;
consistent = false;
}
if (consistent) {
std::cout << "✓ All feature detection APIs are consistent!" << std::endl;
} else {
std::cout << "✗ Inconsistencies found!" << std::endl;
return 1;
}
return 0;
}