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

Unified Diff: crosstest/test_sync_atomic_main.cpp

Issue 877003003: Subzero: Use a "known" version of clang-format. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add a clang-format blacklist. Fix formatting "errors". Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crosstest/test_sync_atomic.cpp ('k') | runtime/szrt.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crosstest/test_sync_atomic_main.cpp
diff --git a/crosstest/test_sync_atomic_main.cpp b/crosstest/test_sync_atomic_main.cpp
index 6a00f31c6724fba494e1ea1ffdcfe3d2ddc0024a..c9bf5792850d9934a57bf846e9ec1010c9f5601c 100644
--- a/crosstest/test_sync_atomic_main.cpp
+++ b/crosstest/test_sync_atomic_main.cpp
@@ -33,27 +33,27 @@ namespace Subzero_ {
}
volatile uint64_t Values[] = {
- 0, 1, 0x7e,
- 0x7f, 0x80, 0x81,
- 0xfe, 0xff, 0x7ffe,
- 0x7fff, 0x8000, 0x8001,
- 0xfffe, 0xffff,
- 0x007fffff /*Max subnormal + */,
- 0x00800000 /*Min+ */, 0x7f7fffff /*Max+ */,
- 0x7f800000 /*+Inf*/, 0xff800000 /*-Inf*/,
- 0x7fa00000 /*SNaN*/, 0x7fc00000 /*QNaN*/,
- 0x7ffffffe, 0x7fffffff, 0x80000000,
- 0x80000001, 0xfffffffe, 0xffffffff,
- 0x100000000ll, 0x100000001ll,
- 0x000fffffffffffffll /*Max subnormal + */,
- 0x0010000000000000ll /*Min+ */,
- 0x7fefffffffffffffll /*Max+ */,
- 0x7ff0000000000000ll /*+Inf*/,
- 0xfff0000000000000ll /*-Inf*/,
- 0x7ff0000000000001ll /*SNaN*/,
- 0x7ff8000000000000ll /*QNaN*/,
- 0x7ffffffffffffffell, 0x7fffffffffffffffll, 0x8000000000000000ll,
- 0x8000000000000001ll, 0xfffffffffffffffell, 0xffffffffffffffffll };
+ 0, 1,
+ 0x7e, 0x7f,
+ 0x80, 0x81,
+ 0xfe, 0xff,
+ 0x7ffe, 0x7fff,
+ 0x8000, 0x8001,
+ 0xfffe, 0xffff,
+ 0x007fffff /*Max subnormal + */, 0x00800000 /*Min+ */,
+ 0x7f7fffff /*Max+ */, 0x7f800000 /*+Inf*/,
+ 0xff800000 /*-Inf*/, 0x7fa00000 /*SNaN*/,
+ 0x7fc00000 /*QNaN*/, 0x7ffffffe,
+ 0x7fffffff, 0x80000000,
+ 0x80000001, 0xfffffffe,
+ 0xffffffff, 0x100000000ll,
+ 0x100000001ll, 0x000fffffffffffffll /*Max subnormal + */,
+ 0x0010000000000000ll /*Min+ */, 0x7fefffffffffffffll /*Max+ */,
+ 0x7ff0000000000000ll /*+Inf*/, 0xfff0000000000000ll /*-Inf*/,
+ 0x7ff0000000000001ll /*SNaN*/, 0x7ff8000000000000ll /*QNaN*/,
+ 0x7ffffffffffffffell, 0x7fffffffffffffffll,
+ 0x8000000000000000ll, 0x8000000000000001ll,
+ 0xfffffffffffffffell, 0xffffffffffffffffll};
const static size_t NumValues = sizeof(Values) / sizeof(*Values);
@@ -65,27 +65,21 @@ struct {
} AtomicLocs;
template <typename Type>
-void testAtomicRMW(volatile Type *AtomicLoc,
- size_t &TotalTests, size_t &Passes, size_t &Failures) {
- typedef Type (*FuncType)(bool, volatile Type*, Type);
+void testAtomicRMW(volatile Type *AtomicLoc, size_t &TotalTests, size_t &Passes,
+ size_t &Failures) {
+ typedef Type (*FuncType)(bool, volatile Type *, Type);
static struct {
const char *Name;
FuncType FuncLlc;
FuncType FuncSz;
} Funcs[] = {
-#define X(inst) \
- { \
- STR(inst), test_##inst, Subzero_::test_##inst \
- }, \
- { \
- STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst \
- }, \
- { \
- STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst \
- },
- RMWOP_TABLE
+#define X(inst) \
+ { STR(inst), test_##inst, Subzero_::test_##inst } \
+ , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \
+ {STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst},
+ RMWOP_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -97,26 +91,22 @@ void testAtomicRMW(volatile Type *AtomicLoc,
bool fetch_first = k;
++TotalTests;
*AtomicLoc = Value1;
- Type ResultSz1 = Funcs[f].FuncSz(
- fetch_first, AtomicLoc, Value2);
+ Type ResultSz1 = Funcs[f].FuncSz(fetch_first, AtomicLoc, Value2);
Type ResultSz2 = *AtomicLoc;
*AtomicLoc = Value1;
- Type ResultLlc1 = Funcs[f].FuncLlc(
- fetch_first, AtomicLoc, Value2);
+ Type ResultLlc1 = Funcs[f].FuncLlc(fetch_first, AtomicLoc, Value2);
Type ResultLlc2 = *AtomicLoc;
if (ResultSz1 == ResultLlc1 && ResultSz2 == ResultLlc2) {
++Passes;
} else {
++Failures;
- std::cout << "test_" << Funcs[f].Name
- << (CHAR_BIT * sizeof(Type)) << "("
- << static_cast<uint64_t>(Value1) << ", "
+ std::cout << "test_" << Funcs[f].Name << (CHAR_BIT * sizeof(Type))
+ << "(" << static_cast<uint64_t>(Value1) << ", "
<< static_cast<uint64_t>(Value2)
<< "): sz1=" << static_cast<uint64_t>(ResultSz1)
<< " llc1=" << static_cast<uint64_t>(ResultLlc1)
<< " sz2=" << static_cast<uint64_t>(ResultSz2)
- << " llc2=" << static_cast<uint64_t>(ResultLlc2)
- << "\n";
+ << " llc2=" << static_cast<uint64_t>(ResultLlc2) << "\n";
}
}
}
@@ -170,18 +160,16 @@ void testValCompareAndSwap(volatile Type *AtomicLoc, size_t &TotalTests,
}
}
-template <typename Type>
-struct ThreadData {
- Type (*FuncPtr)(bool, volatile Type*, Type);
+template <typename Type> struct ThreadData {
+ Type (*FuncPtr)(bool, volatile Type *, Type);
bool Fetch;
volatile Type *Ptr;
Type Adjustment;
};
-template <typename Type>
-void *threadWrapper(void *Data) {
+template <typename Type> void *threadWrapper(void *Data) {
const size_t NumReps = 8000;
- ThreadData<Type> *TData = reinterpret_cast<ThreadData<Type>*>(Data);
+ ThreadData<Type> *TData = reinterpret_cast<ThreadData<Type> *>(Data);
for (size_t i = 0; i < NumReps; ++i) {
(void)TData->FuncPtr(TData->Fetch, TData->Ptr, TData->Adjustment);
}
@@ -191,26 +179,22 @@ void *threadWrapper(void *Data) {
template <typename Type>
void testAtomicRMWThreads(volatile Type *AtomicLoc, size_t &TotalTests,
size_t &Passes, size_t &Failures) {
- typedef Type (*FuncType)(bool, volatile Type*, Type);
+ typedef Type (*FuncType)(bool, volatile Type *, Type);
static struct {
const char *Name;
FuncType FuncLlc;
FuncType FuncSz;
} Funcs[] = {
-#define X(inst) \
- { \
- STR(inst), test_##inst, Subzero_::test_##inst \
- }, \
- { \
- STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst \
- },
- RMWOP_TABLE
+#define X(inst) \
+ { STR(inst), test_##inst, Subzero_::test_##inst } \
+ , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst},
+ RMWOP_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
// Just test a few values, otherwise it takes a *really* long time.
- volatile uint64_t ValuesSubset[] = { 1, 0x7e, 0x000fffffffffffffffll };
+ volatile uint64_t ValuesSubset[] = {1, 0x7e, 0x000fffffffffffffffll};
const size_t NumValuesSubset = sizeof(ValuesSubset) / sizeof(*ValuesSubset);
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -219,10 +203,10 @@ void testAtomicRMWThreads(volatile Type *AtomicLoc, size_t &TotalTests,
for (size_t j = 0; j < NumValuesSubset; ++j) {
Type Value2 = static_cast<Type>(ValuesSubset[j]);
bool fetch_first = true;
- ThreadData<Type> TDataSz = {
- Funcs[f].FuncSz, fetch_first, AtomicLoc, Value2 };
- ThreadData<Type> TDataLlc = {
- Funcs[f].FuncLlc, fetch_first, AtomicLoc, Value2 };
+ ThreadData<Type> TDataSz = {Funcs[f].FuncSz, fetch_first, AtomicLoc,
+ Value2};
+ ThreadData<Type> TDataLlc = {Funcs[f].FuncLlc, fetch_first, AtomicLoc,
+ Value2};
++TotalTests;
const size_t NumThreads = 4;
pthread_t t[NumThreads];
@@ -243,8 +227,8 @@ void testAtomicRMWThreads(volatile Type *AtomicLoc, size_t &TotalTests,
for (size_t m = 0; m < NumThreads; ++m) {
if (pthread_create(&t[m], NULL, &threadWrapper<Type>,
m % 2 == 0
- ? reinterpret_cast<void *>(&TDataLlc)
- : reinterpret_cast<void *>(&TDataSz)) != 0) {
+ ? reinterpret_cast<void *>(&TDataLlc)
+ : reinterpret_cast<void *>(&TDataSz)) != 0) {
++Failures;
std::cout << "pthread_create failed w/ " << strerror(errno) << "\n";
abort();
@@ -268,8 +252,7 @@ void testAtomicRMWThreads(volatile Type *AtomicLoc, size_t &TotalTests,
<< static_cast<uint64_t>(Value1) << ", "
<< static_cast<uint64_t>(Value2)
<< "): llc=" << static_cast<uint64_t>(ResultLlc)
- << " mixed=" << static_cast<uint64_t>(ResultMixed)
- << "\n";
+ << " mixed=" << static_cast<uint64_t>(ResultMixed) << "\n";
}
}
}
@@ -285,22 +268,17 @@ int main(int argc, char **argv) {
testAtomicRMW<uint16_t>(&AtomicLocs.l16, TotalTests, Passes, Failures);
testAtomicRMW<uint32_t>(&AtomicLocs.l32, TotalTests, Passes, Failures);
testAtomicRMW<uint64_t>(&AtomicLocs.l64, TotalTests, Passes, Failures);
- testValCompareAndSwap<uint8_t>(
- &AtomicLocs.l8, TotalTests, Passes, Failures);
- testValCompareAndSwap<uint16_t>(
- &AtomicLocs.l16, TotalTests, Passes, Failures);
- testValCompareAndSwap<uint32_t>(
- &AtomicLocs.l32, TotalTests, Passes, Failures);
- testValCompareAndSwap<uint64_t>(
- &AtomicLocs.l64, TotalTests, Passes, Failures);
- testAtomicRMWThreads<uint8_t>(
- &AtomicLocs.l8, TotalTests, Passes, Failures);
- testAtomicRMWThreads<uint16_t>(
- &AtomicLocs.l16, TotalTests, Passes, Failures);
- testAtomicRMWThreads<uint32_t>(
- &AtomicLocs.l32, TotalTests, Passes, Failures);
- testAtomicRMWThreads<uint64_t>(
- &AtomicLocs.l64, TotalTests, Passes, Failures);
+ testValCompareAndSwap<uint8_t>(&AtomicLocs.l8, TotalTests, Passes, Failures);
+ testValCompareAndSwap<uint16_t>(&AtomicLocs.l16, TotalTests, Passes,
+ Failures);
+ testValCompareAndSwap<uint32_t>(&AtomicLocs.l32, TotalTests, Passes,
+ Failures);
+ testValCompareAndSwap<uint64_t>(&AtomicLocs.l64, TotalTests, Passes,
+ Failures);
+ testAtomicRMWThreads<uint8_t>(&AtomicLocs.l8, TotalTests, Passes, Failures);
+ testAtomicRMWThreads<uint16_t>(&AtomicLocs.l16, TotalTests, Passes, Failures);
+ testAtomicRMWThreads<uint32_t>(&AtomicLocs.l32, TotalTests, Passes, Failures);
+ testAtomicRMWThreads<uint64_t>(&AtomicLocs.l64, TotalTests, Passes, Failures);
std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
<< " Failures=" << Failures << "\n";
« no previous file with comments | « crosstest/test_sync_atomic.cpp ('k') | runtime/szrt.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698