Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: a260847020eec7827b5aef453e42d9b8606ecae6
  • Loading branch information
levlam committed Jul 4, 2020
1 parent c865f6a commit 93ab72b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions tdutils/td/utils/AtomicRead.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <atomic>
#include <cstring>
#include <memory>
#include <type_traits>

namespace td {
Expand Down
15 changes: 9 additions & 6 deletions tdutils/test/StealingQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
//
#include "td/utils/AtomicRead.h"
#include "td/utils/benchmark.h"
#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/MpmcQueue.h"
#include "td/utils/port/thread.h"
#include "td/utils/Random.h"
#include "td/utils/StealingQueue.h"
#include "td/utils/tests.h"

Expand Down Expand Up @@ -84,7 +87,7 @@ TEST(AtomicRead, simple2) {
auto x = value.lock();
x->value = round;
auto str = to_str(round);
memcpy(x->str, str.c_str(), str.size() + 1);
std::memcpy(x->str, str.c_str(), str.size() + 1);
} else {
Value x;
value.read(x);
Expand All @@ -101,8 +104,8 @@ TEST(AtomicRead, simple2) {
}

TEST(StealingQueue, simple) {
td::uint64 sum;
std::atomic<td::uint64> got_sum;
td::uint64 sum = 0;
std::atomic<td::uint64> got_sum{0};

td::Stage run;
td::Stage check;
Expand All @@ -126,9 +129,9 @@ TEST(StealingQueue, simple) {
for (td::uint64 round = 1; round < 10000; round++) {
if (id == 0) {
sum = 0;
int n = rnd() % 5;
int n = static_cast<int>(rnd() % 5);
for (int j = 0; j < n; j++) {
int x = rand() % XN;
int x = static_cast<int>(rnd() % XN);
sum += x_sum[x];
gq.push(x, id);
}
Expand All @@ -144,7 +147,7 @@ TEST(StealingQueue, simple) {
if (gq.try_pop(res, id)) {
return res;
}
if (lq[id].steal(res, lq[rand() % threads_n])) {
if (lq[id].steal(res, lq[static_cast<size_t>(rnd()) % threads_n])) {
//LOG(ERROR) << "STEAL";
return res;
}
Expand Down

0 comments on commit 93ab72b

Please sign in to comment.