Skip to content

Commit b338820

Browse files
committed
Remove logging, & -> *
1 parent 41843bb commit b338820

13 files changed

+185
-484
lines changed

SingleSource/UnitTests/Atomic/CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
# These tests output numerical values to improve debuggability.
2-
# Setting FP_TOLERANCE causes the test checker to use fpcmp to compare
3-
# test and expected output.
4-
# Because the nonatomic output may vary wildly even in a passing run,
5-
# we set FP_TOLERANCE high so the test will never fail due to
6-
# differing numerical results.
7-
# The tests each have their own correctness checking and will fail
8-
# properly if something is actually wrong.
9-
set(FP_TOLERANCE 1000000)
10-
111
# Link the Clang built libatomic.
122
execute_process(COMMAND ${CMAKE_C_COMPILER} --print-file-name=libclang_rt.atomic.so
133
OUTPUT_VARIABLE _path_to_libatomic

SingleSource/UnitTests/Atomic/big_test.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
//
4343
//===----------------------------------------------------------------------===//
4444

45-
#include <cstdio>
4645
#include <iostream>
4746
#include <thread>
4847
#include <vector>
@@ -56,7 +55,7 @@ struct big_t {
5655

5756
// The big struct cmpxchg test is identical to the numeric cmpxchg test, except
5857
// each element of the underlying array is incremented.
59-
void looper_big_cmpxchg(big_t *abig, big_t &bbig, int success_model,
58+
void looper_big_cmpxchg(big_t *abig, big_t *bbig, int success_model,
6059
int fail_model) {
6160
for (int n = 0; n < kIterations; ++n) {
6261
big_t desired, expected = {};
@@ -67,7 +66,7 @@ void looper_big_cmpxchg(big_t *abig, big_t &bbig, int success_model,
6766
} while (!__atomic_compare_exchange(abig, &expected, &desired, true,
6867
success_model, fail_model));
6968
for (int k = 0; k < kBigSize; ++k)
70-
bbig.v[k]++;
69+
bbig->v[k]++;
7170
}
7271
}
7372

@@ -76,23 +75,13 @@ void test_big_cmpxchg() {
7675

7776
for (int success_model : atomic_compare_exchange_models) {
7877
for (int fail_model : atomic_compare_exchange_models) {
79-
big_t abig = {};
80-
big_t bbig = {};
78+
big_t abig = {}, bbig = {};
8179
for (int n = 0; n < kThreads; ++n)
82-
pool.emplace_back(looper_big_cmpxchg, &abig, std::ref(bbig),
80+
pool.emplace_back(looper_big_cmpxchg, &abig, &bbig,
8381
success_model, fail_model);
8482
for (int n = 0; n < kThreads; ++n)
8583
pool[n].join();
8684
pool.clear();
87-
std::cout << "CMPXCHG: ";
88-
std::cout << "atomic: ";
89-
for (int n = 0; n < kBigSize; ++n)
90-
std::cout << abig.v[n] << " ";
91-
std::cout << "\n ";
92-
std::cout << "nonatomic: ";
93-
for (int n = 0; n < kBigSize; ++n)
94-
std::cout << bbig.v[n] << " ";
95-
std::cout << "\n";
9685
for (int n = 0; n < kBigSize; ++n)
9786
if (lt(abig.v[n], bbig.v[n]) || abig.v[n] != kExpected)
9887
fail();
@@ -101,14 +90,14 @@ void test_big_cmpxchg() {
10190
}
10291

10392
void test_big() {
104-
printf("Testing big\n");
93+
std::cout << "Testing big\n";
10594
test_big_cmpxchg();
10695
}
10796

10897
int main() {
109-
printf("%d threads; %d iterations each; total of %d\n", kThreads, kIterations,
110-
kExpected);
111-
98+
std::cout << kThreads << " threads; "
99+
<< kIterations << " iterations each; total of "
100+
<< kExpected << "\n";
112101
test_big();
113-
printf("PASSED\n");
102+
std::cout << "PASSED\n";
114103
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
10 threads; 1000000 iterations each; total of 10000000
22
Testing big
3-
CMPXCHG: atomic: 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000
4-
nonatomic: 9970397 9970397 9970397 9970397 9972269 9972269 9972269 9972269 9941180 9941180
53
PASSED
64
exit 0

SingleSource/UnitTests/Atomic/float_test.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
#include <sys/stat.h>
4646

47-
#include <cstdio>
47+
#include <iostream>
4848
#include <thread>
4949
#include <vector>
5050

@@ -59,22 +59,17 @@ void test_float_scalar_xchg() {
5959
std::vector<std::thread> pool;
6060

6161
for (int model : atomic_exchange_models) {
62-
T afloat = 0;
63-
T ffloat = 0;
62+
T afloat = 0, ffloat = 0;
6463
for (int n = 0; n < kThreads; ++n)
6564
pool.emplace_back(looper_numeric_xchg_atomic<T>, &afloat, model);
6665
for (int n = 0; n < kThreads; ++n)
6766
pool[n].join();
6867
pool.clear();
6968
for (int n = 0; n < kThreads; ++n)
70-
pool.emplace_back(looper_numeric_xchg_nonatomic<T>, std::ref(ffloat),
71-
model);
69+
pool.emplace_back(looper_numeric_xchg_nonatomic<T>, &ffloat, model);
7270
for (int n = 0; n < kThreads; ++n)
7371
pool[n].join();
7472
pool.clear();
75-
std::cout << "SCALAR (FETCH ADD): "
76-
<< "atomic: " << afloat << " "
77-
<< "nonatomic: " << ffloat << "\n";
7873
if (lt(afloat, ffloat) || afloat < expected * (1 - kEpsilon) ||
7974
afloat > expected * (1 + kEpsilon))
8075
fail();
@@ -90,17 +85,13 @@ void test_float_scalar_cmpxchg() {
9085

9186
for (int success_model : atomic_compare_exchange_models) {
9287
for (int fail_model : atomic_compare_exchange_models) {
93-
T afloat = 0;
94-
T ffloat = 0;
88+
T afloat = 0, ffloat = 0;
9589
for (int n = 0; n < kThreads; ++n)
96-
pool.emplace_back(looper_numeric_cmpxchg<T>, &afloat, std::ref(ffloat),
90+
pool.emplace_back(looper_numeric_cmpxchg<T>, &afloat, &ffloat,
9791
success_model, fail_model);
9892
for (int n = 0; n < kThreads; ++n)
9993
pool[n].join();
10094
pool.clear();
101-
std::cout << "SCALAR (FETCH ADD): "
102-
<< "atomic: " << afloat << " "
103-
<< "nonatomic: " << ffloat << "\n";
10495
if (lt(afloat, ffloat) || afloat < expected * (1 - kEpsilon) ||
10596
afloat > expected * (1 + kEpsilon))
10697
fail();
@@ -109,19 +100,19 @@ void test_float_scalar_cmpxchg() {
109100
}
110101

111102
void test_floating_point() {
112-
printf("Testing float\n");
103+
std::cout << "Testing float\n";
113104
test_float_scalar_xchg<float>();
114105
test_float_scalar_cmpxchg<float>();
115106

116-
printf("Testing double\n");
107+
std::cout << "Testing double\n";
117108
test_float_scalar_xchg<double>();
118109
test_float_scalar_cmpxchg<double>();
119110
}
120111

121112
int main() {
122-
printf("%d threads; %d iterations each; total of %d\n", kThreads, kIterations,
123-
kExpected);
124-
113+
std::cout << kThreads << " threads; "
114+
<< kIterations << " iterations each; total of "
115+
<< kExpected << "\n";
125116
test_floating_point();
126-
printf("PASSED\n");
117+
std::cout << "PASSED\n";
127118
}
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
10 threads; 1000000 iterations each; total of 10000000
22
Testing float
3-
SCALAR (FETCH ADD): atomic: 6.50116e+08 nonatomic: 6.6e+07
4-
SCALAR (FETCH ADD): atomic: 6.41017e+08 nonatomic: 5.8511e+08
53
Testing double
6-
SCALAR (FETCH ADD): atomic: 2.84596e+18 nonatomic: 2.84596e+17
7-
SCALAR (FETCH ADD): atomic: 2.84596e+18 nonatomic: 2.5513e+18
84
PASSED
95
exit 0

0 commit comments

Comments
 (0)