Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: crosstest/test_sync_atomic_main.cpp

Issue 413903002: Subzero: Add a peephole to fuse cmpxchg w/ later cmp+branch. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: blank Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crosstest/test_sync_atomic.cpp ('k') | src/IceCfgNode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 } 121 }
122 } 122 }
123 } 123 }
124 } 124 }
125 } 125 }
126 126
127 template <typename Type> 127 template <typename Type>
128 void testValCompareAndSwap(volatile Type *AtomicLoc, size_t &TotalTests, 128 void testValCompareAndSwap(volatile Type *AtomicLoc, size_t &TotalTests,
129 size_t &Passes, size_t &Failures) { 129 size_t &Passes, size_t &Failures) {
130 for (size_t i = 0; i < NumValues; ++i) { 130 typedef Type (*FuncType)(volatile Type *, Type, Type);
131 Type Value1 = static_cast<Type>(Values[i]); 131 static struct {
132 for (size_t j = 0; j < NumValues; ++j) { 132 const char *Name;
133 Type Value2 = static_cast<Type>(Values[j]); 133 FuncType FuncLlc;
134 for (size_t f = 0; f < 2; ++f) { 134 FuncType FuncSz;
135 bool flip = f; 135 } Funcs[] = {{"val_cmp_swap", test_val_cmp_swap, Subzero_::test_val_cmp_swap},
136 ++TotalTests; 136 {"val_cmp_swap_loop", test_val_cmp_swap_loop,
137 *AtomicLoc = Value1; 137 Subzero_::test_val_cmp_swap_loop}};
138 Type ResultSz1 = Subzero_::test_val_cmp_swap( 138 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
139 AtomicLoc, flip ? Value2 : Value1, Value2); 139 for (size_t f = 0; f < NumFuncs; ++f) {
140 Type ResultSz2 = *AtomicLoc; 140 for (size_t i = 0; i < NumValues; ++i) {
141 *AtomicLoc = Value1; 141 Type Value1 = static_cast<Type>(Values[i]);
142 Type ResultLlc1 = test_val_cmp_swap( 142 for (size_t j = 0; j < NumValues; ++j) {
143 AtomicLoc, flip ? Value2 : Value1, Value2); 143 Type Value2 = static_cast<Type>(Values[j]);
144 Type ResultLlc2 = *AtomicLoc; 144 for (size_t f = 0; f < 2; ++f) {
145 if (ResultSz1 == ResultLlc1 && ResultSz2 == ResultLlc2) { 145 bool flip = f;
146 ++Passes; 146 ++TotalTests;
147 } else { 147 *AtomicLoc = Value1;
148 ++Failures; 148 Type ResultSz1 =
149 std::cout << "test_val_cmp_swap" << (CHAR_BIT * sizeof(Type)) << "(" 149 Funcs[f].FuncSz(AtomicLoc, flip ? Value2 : Value1, Value2);
150 << static_cast<uint64_t>(Value1) << ", " 150 Type ResultSz2 = *AtomicLoc;
151 << static_cast<uint64_t>(Value2) 151 *AtomicLoc = Value1;
152 << "): sz1=" << static_cast<uint64_t>(ResultSz1) 152 Type ResultLlc1 =
153 << " llc1=" << static_cast<uint64_t>(ResultLlc1) 153 Funcs[f].FuncLlc(AtomicLoc, flip ? Value2 : Value1, Value2);
154 << " sz2=" << static_cast<uint64_t>(ResultSz2) 154 Type ResultLlc2 = *AtomicLoc;
155 << " llc2=" << static_cast<uint64_t>(ResultLlc2) 155 if (ResultSz1 == ResultLlc1 && ResultSz2 == ResultLlc2) {
156 << "\n"; 156 ++Passes;
157 } else {
158 ++Failures;
159 std::cout << "test_" << Funcs[f].Name << (CHAR_BIT * sizeof(Type))
160 << "(" << static_cast<uint64_t>(Value1) << ", "
161 << static_cast<uint64_t>(Value2)
162 << "): sz1=" << static_cast<uint64_t>(ResultSz1)
163 << " llc1=" << static_cast<uint64_t>(ResultLlc1)
164 << " sz2=" << static_cast<uint64_t>(ResultSz2)
165 << " llc2=" << static_cast<uint64_t>(ResultLlc2) << "\n";
166 }
157 } 167 }
158 } 168 }
159 } 169 }
160 } 170 }
161 } 171 }
162 172
163 template <typename Type> 173 template <typename Type>
164 struct ThreadData { 174 struct ThreadData {
165 Type (*FuncPtr)(bool, volatile Type*, Type); 175 Type (*FuncPtr)(bool, volatile Type*, Type);
166 bool Fetch; 176 bool Fetch;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 &AtomicLocs.l16, TotalTests, Passes, Failures); 299 &AtomicLocs.l16, TotalTests, Passes, Failures);
290 testAtomicRMWThreads<uint32_t>( 300 testAtomicRMWThreads<uint32_t>(
291 &AtomicLocs.l32, TotalTests, Passes, Failures); 301 &AtomicLocs.l32, TotalTests, Passes, Failures);
292 testAtomicRMWThreads<uint64_t>( 302 testAtomicRMWThreads<uint64_t>(
293 &AtomicLocs.l64, TotalTests, Passes, Failures); 303 &AtomicLocs.l64, TotalTests, Passes, Failures);
294 304
295 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 305 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
296 << " Failures=" << Failures << "\n"; 306 << " Failures=" << Failures << "\n";
297 return Failures; 307 return Failures;
298 } 308 }
OLDNEW
« no previous file with comments | « crosstest/test_sync_atomic.cpp ('k') | src/IceCfgNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698