Skip to content

Commit 970fee0

Browse files
committed
parallel_test.cpp: attempt to work around windows test failures
1 parent 0d6d957 commit 970fee0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/pbrt/util/parallel_test.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,16 @@ TEST(Parallel, ForEachThread) {
5050
TEST(ThreadLocal, Consistency) {
5151
ThreadLocal<std::thread::id> tids([]() { return std::this_thread::get_id(); });
5252

53-
auto busywork = [](int64_t index) {
53+
std::atomic<int64_t> dummy{0};
54+
auto busywork = [&dummy](int64_t index) {
5455
// Do some busy work to burn some time
55-
Float f = 1.141;
56+
// Use the index to do a varying amount of computation
57+
int64_t result = 0;
5658
for (int i = 0; i <= index; ++i)
5759
for (int j = 0; j <= index; ++j)
58-
f *= std::sqrt(f);
59-
EXPECT_NE(f, 1.141f); // make sure it isn't optimized out
60+
result += i * j;
61+
// Store result in atomic to prevent optimization
62+
dummy.fetch_add(result, std::memory_order_relaxed);
6063
};
6164

6265
ParallelFor(0, 1000, [&](int64_t index) {

0 commit comments

Comments
 (0)