OLD | NEW |
1 //===- subzero/crosstest/test_sync_atomic_main.cpp - Driver for tests -----===// | 1 //===- subzero/crosstest/test_sync_atomic_main.cpp - Driver for tests -----===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // Driver for cross testing atomic intrinsics, via the sync builtins. | 10 // Driver for cross testing atomic intrinsics, via the sync builtins. |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // Include test_sync_atomic.h twice - once normally, and once within the | 27 // Include test_sync_atomic.h twice - once normally, and once within the |
28 // Subzero_ namespace, corresponding to the llc and Subzero translated | 28 // Subzero_ namespace, corresponding to the llc and Subzero translated |
29 // object files, respectively. | 29 // object files, respectively. |
30 #include "test_sync_atomic.h" | 30 #include "test_sync_atomic.h" |
31 namespace Subzero_ { | 31 namespace Subzero_ { |
32 #include "test_sync_atomic.h" | 32 #include "test_sync_atomic.h" |
33 } | 33 } |
34 | 34 |
35 volatile uint64_t Values[] = { | 35 volatile uint64_t Values[] = { |
36 0, 1, | 36 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff, 0x8000, 0x8001, |
37 0x7e, 0x7f, | 37 0xfffe, 0xffff, 0x007fffff /*Max subnormal + */, 0x00800000 /*Min+ */, |
38 0x80, 0x81, | 38 0x7f7fffff /*Max+ */, 0x7f800000 /*+Inf*/, 0xff800000 /*-Inf*/, |
39 0xfe, 0xff, | 39 0x7fa00000 /*SNaN*/, 0x7fc00000 /*QNaN*/, 0x7ffffffe, 0x7fffffff, |
40 0x7ffe, 0x7fff, | 40 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff, 0x100000000ll, |
41 0x8000, 0x8001, | 41 0x100000001ll, 0x000fffffffffffffll /*Max subnormal + */, |
42 0xfffe, 0xffff, | 42 0x0010000000000000ll /*Min+ */, 0x7fefffffffffffffll /*Max+ */, |
43 0x007fffff /*Max subnormal + */, 0x00800000 /*Min+ */, | 43 0x7ff0000000000000ll /*+Inf*/, 0xfff0000000000000ll /*-Inf*/, |
44 0x7f7fffff /*Max+ */, 0x7f800000 /*+Inf*/, | 44 0x7ff0000000000001ll /*SNaN*/, 0x7ff8000000000000ll /*QNaN*/, |
45 0xff800000 /*-Inf*/, 0x7fa00000 /*SNaN*/, | 45 0x7ffffffffffffffell, 0x7fffffffffffffffll, 0x8000000000000000ll, |
46 0x7fc00000 /*QNaN*/, 0x7ffffffe, | 46 0x8000000000000001ll, 0xfffffffffffffffell, 0xffffffffffffffffll}; |
47 0x7fffffff, 0x80000000, | |
48 0x80000001, 0xfffffffe, | |
49 0xffffffff, 0x100000000ll, | |
50 0x100000001ll, 0x000fffffffffffffll /*Max subnormal + */, | |
51 0x0010000000000000ll /*Min+ */, 0x7fefffffffffffffll /*Max+ */, | |
52 0x7ff0000000000000ll /*+Inf*/, 0xfff0000000000000ll /*-Inf*/, | |
53 0x7ff0000000000001ll /*SNaN*/, 0x7ff8000000000000ll /*QNaN*/, | |
54 0x7ffffffffffffffell, 0x7fffffffffffffffll, | |
55 0x8000000000000000ll, 0x8000000000000001ll, | |
56 0xfffffffffffffffell, 0xffffffffffffffffll}; | |
57 | 47 |
58 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 48 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
59 | 49 |
60 struct { | 50 struct { |
61 volatile uint8_t l8; | 51 volatile uint8_t l8; |
62 volatile uint16_t l16; | 52 volatile uint16_t l16; |
63 volatile uint32_t l32; | 53 volatile uint32_t l32; |
64 volatile uint64_t l64; | 54 volatile uint64_t l64; |
65 } AtomicLocs; | 55 } AtomicLocs; |
66 | 56 |
67 template <typename Type> | 57 template <typename Type> |
68 void testAtomicRMW(volatile Type *AtomicLoc, size_t &TotalTests, size_t &Passes, | 58 void testAtomicRMW(volatile Type *AtomicLoc, size_t &TotalTests, size_t &Passes, |
69 size_t &Failures) { | 59 size_t &Failures) { |
70 typedef Type (*FuncType)(bool, volatile Type *, Type); | 60 typedef Type (*FuncType)(bool, volatile Type *, Type); |
71 static struct { | 61 static struct { |
72 const char *Name; | 62 const char *Name; |
73 FuncType FuncLlc; | 63 FuncType FuncLlc; |
74 FuncType FuncSz; | 64 FuncType FuncSz; |
75 } Funcs[] = { | 65 } Funcs[] = { |
76 #define X(inst) \ | 66 #define X(inst) \ |
77 { STR(inst), test_##inst, Subzero_::test_##inst } \ | 67 { STR(inst), test_##inst, Subzero_::test_##inst } \ |
78 , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \ | 68 , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \ |
79 {STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst}, | 69 {STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst}, |
80 RMWOP_TABLE | 70 RMWOP_TABLE |
81 #undef X | 71 #undef X |
82 }; | 72 }; |
83 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 73 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
84 | 74 |
85 for (size_t f = 0; f < NumFuncs; ++f) { | 75 for (size_t f = 0; f < NumFuncs; ++f) { |
86 for (size_t i = 0; i < NumValues; ++i) { | 76 for (size_t i = 0; i < NumValues; ++i) { |
87 Type Value1 = static_cast<Type>(Values[i]); | 77 Type Value1 = static_cast<Type>(Values[i]); |
88 for (size_t j = 0; j < NumValues; ++j) { | 78 for (size_t j = 0; j < NumValues; ++j) { |
89 Type Value2 = static_cast<Type>(Values[j]); | 79 Type Value2 = static_cast<Type>(Values[j]); |
90 for (size_t k = 0; k < 2; ++k) { | 80 for (size_t k = 0; k < 2; ++k) { |
91 bool fetch_first = k; | 81 bool fetch_first = k; |
92 ++TotalTests; | 82 ++TotalTests; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 size_t &Passes, size_t &Failures) { | 171 size_t &Passes, size_t &Failures) { |
182 typedef Type (*FuncType)(bool, volatile Type *, Type); | 172 typedef Type (*FuncType)(bool, volatile Type *, Type); |
183 static struct { | 173 static struct { |
184 const char *Name; | 174 const char *Name; |
185 FuncType FuncLlc; | 175 FuncType FuncLlc; |
186 FuncType FuncSz; | 176 FuncType FuncSz; |
187 } Funcs[] = { | 177 } Funcs[] = { |
188 #define X(inst) \ | 178 #define X(inst) \ |
189 { STR(inst), test_##inst, Subzero_::test_##inst } \ | 179 { STR(inst), test_##inst, Subzero_::test_##inst } \ |
190 , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, | 180 , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, |
191 RMWOP_TABLE | 181 RMWOP_TABLE |
192 #undef X | 182 #undef X |
193 }; | 183 }; |
194 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 184 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
195 | 185 |
196 // Just test a few values, otherwise it takes a *really* long time. | 186 // Just test a few values, otherwise it takes a *really* long time. |
197 volatile uint64_t ValuesSubset[] = {1, 0x7e, 0x000fffffffffffffffll}; | 187 volatile uint64_t ValuesSubset[] = {1, 0x7e, 0x000fffffffffffffffll}; |
198 const size_t NumValuesSubset = sizeof(ValuesSubset) / sizeof(*ValuesSubset); | 188 const size_t NumValuesSubset = sizeof(ValuesSubset) / sizeof(*ValuesSubset); |
199 | 189 |
200 for (size_t f = 0; f < NumFuncs; ++f) { | 190 for (size_t f = 0; f < NumFuncs; ++f) { |
201 for (size_t i = 0; i < NumValuesSubset; ++i) { | 191 for (size_t i = 0; i < NumValuesSubset; ++i) { |
202 Type Value1 = static_cast<Type>(ValuesSubset[i]); | 192 Type Value1 = static_cast<Type>(ValuesSubset[i]); |
203 for (size_t j = 0; j < NumValuesSubset; ++j) { | 193 for (size_t j = 0; j < NumValuesSubset; ++j) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 Failures); | 267 Failures); |
278 testAtomicRMWThreads<uint8_t>(&AtomicLocs.l8, TotalTests, Passes, Failures); | 268 testAtomicRMWThreads<uint8_t>(&AtomicLocs.l8, TotalTests, Passes, Failures); |
279 testAtomicRMWThreads<uint16_t>(&AtomicLocs.l16, TotalTests, Passes, Failures); | 269 testAtomicRMWThreads<uint16_t>(&AtomicLocs.l16, TotalTests, Passes, Failures); |
280 testAtomicRMWThreads<uint32_t>(&AtomicLocs.l32, TotalTests, Passes, Failures); | 270 testAtomicRMWThreads<uint32_t>(&AtomicLocs.l32, TotalTests, Passes, Failures); |
281 testAtomicRMWThreads<uint64_t>(&AtomicLocs.l64, TotalTests, Passes, Failures); | 271 testAtomicRMWThreads<uint64_t>(&AtomicLocs.l64, TotalTests, Passes, Failures); |
282 | 272 |
283 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 273 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
284 << " Failures=" << Failures << "\n"; | 274 << " Failures=" << Failures << "\n"; |
285 return Failures; | 275 return Failures; |
286 } | 276 } |
OLD | NEW |