Commit c2d90c70 authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

Use uint32_t rather than uint

Summary: Because Windows doesn't have `uint` as it's non-standard.

Reviewed By: djwatson

Differential Revision: D7821774

fbshipit-source-id: 4f7ff4468fc56052e28995f386e194fe70c6c513
parent 71fe1d6a
......@@ -390,7 +390,7 @@ void printResultComparison(
* common for benchmarks that need a "problem size" in addition to
* "number of iterations". Consider:
*
* void pushBack(uint n, size_t initialSize) {
* void pushBack(uint32_t n, size_t initialSize) {
* vector<int> v;
* BENCHMARK_SUSPEND {
* v.resize(initialSize);
......@@ -426,7 +426,7 @@ void printResultComparison(
*
* For example:
*
* void addValue(uint n, int64_t bucketSize, int64_t min, int64_t max) {
* void addValue(uint32_t n, int64_t bucketSize, int64_t min, int64_t max) {
* Histogram<int64_t> hist(bucketSize, min, max);
* int64_t num = min;
* FOR_EACH_RANGE (i, 0, n) {
......
......@@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/concurrency/ConcurrentHashMap.h>
#include <atomic>
#include <memory>
#include <thread>
#include <folly/concurrency/ConcurrentHashMap.h>
#include <folly/hash/Hash.h>
#include <folly/portability/GTest.h>
#include <folly/test/DeterministicSchedule.h>
......@@ -323,15 +325,15 @@ TEST(ConcurrentHashMap, UpdateStressTest) {
Mutex>
m(2);
for (uint i = 0; i < size; i++) {
for (uint32_t i = 0; i < size; i++) {
m.insert(i, i);
}
std::vector<std::thread> threads;
unsigned int num_threads = 32;
for (uint t = 0; t < num_threads; t++) {
for (uint32_t t = 0; t < num_threads; t++) {
threads.push_back(lib::thread([&, t]() {
int offset = (iters * t / num_threads);
for (uint i = 0; i < iters / num_threads; i++) {
for (uint32_t i = 0; i < iters / num_threads; i++) {
unsigned long k = folly::hash::jenkins_rev_mix32((i + offset));
k = k % (iters / num_threads) + offset;
unsigned long val = 3;
......@@ -370,16 +372,16 @@ TEST(ConcurrentHashMap, EraseStressTest) {
Mutex>
m(2);
for (uint i = 0; i < size; i++) {
for (uint32_t i = 0; i < size; i++) {
unsigned long k = folly::hash::jenkins_rev_mix32(i);
m.insert(k, k);
}
std::vector<std::thread> threads;
unsigned int num_threads = 32;
for (uint t = 0; t < num_threads; t++) {
for (uint32_t t = 0; t < num_threads; t++) {
threads.push_back(lib::thread([&, t]() {
int offset = (iters * t / num_threads);
for (uint i = 0; i < iters / num_threads; i++) {
for (uint32_t i = 0; i < iters / num_threads; i++) {
unsigned long k = folly::hash::jenkins_rev_mix32((i + offset));
auto res = m.insert(k, k).second;
if (res) {
......@@ -429,19 +431,19 @@ TEST(ConcurrentHashMap, IterateStressTest) {
Mutex>
m(2);
for (uint i = 0; i < size; i++) {
for (uint32_t i = 0; i < size; i++) {
unsigned long k = folly::hash::jenkins_rev_mix32(i);
m.insert(k, k);
}
for (uint i = 0; i < 10; i++) {
for (uint32_t i = 0; i < 10; i++) {
m.insert(i, i);
}
std::vector<std::thread> threads;
unsigned int num_threads = 32;
for (uint t = 0; t < num_threads; t++) {
for (uint32_t t = 0; t < num_threads; t++) {
threads.push_back(lib::thread([&, t]() {
int offset = (iters * t / num_threads);
for (uint i = 0; i < iters / num_threads; i++) {
for (uint32_t i = 0; i < iters / num_threads; i++) {
unsigned long k = folly::hash::jenkins_rev_mix32((i + offset));
auto res = m.insert(k, k).second;
if (res) {
......@@ -488,10 +490,10 @@ TEST(ConcurrentHashMap, insertStressTest) {
EXPECT_FALSE(m.insert(0, 0).second);
std::vector<std::thread> threads;
unsigned int num_threads = 32;
for (uint t = 0; t < num_threads; t++) {
for (uint32_t t = 0; t < num_threads; t++) {
threads.push_back(lib::thread([&, t]() {
int offset = (iters * t / num_threads);
for (uint i = 0; i < iters / num_threads; i++) {
for (uint32_t i = 0; i < iters / num_threads; i++) {
auto var = offset + i + 1;
EXPECT_TRUE(m.insert(var, var).second);
EXPECT_FALSE(m.insert(0, 0).second);
......@@ -542,7 +544,7 @@ TEST(ConcurrentHashMap, assignStressTest) {
Mutex>
m(2);
for (uint i = 0; i < iters; i++) {
for (uint32_t i = 0; i < iters; i++) {
big_value a;
a.set(i);
m.insert(i, a);
......@@ -550,9 +552,9 @@ TEST(ConcurrentHashMap, assignStressTest) {
std::vector<std::thread> threads;
unsigned int num_threads = 32;
for (uint t = 0; t < num_threads; t++) {
for (uint32_t t = 0; t < num_threads; t++) {
threads.push_back(lib::thread([&]() {
for (uint i = 0; i < iters; i++) {
for (uint32_t i = 0; i < iters; i++) {
auto res = m.find(i);
EXPECT_NE(res, m.cend());
res->second.check();
......
......@@ -112,7 +112,7 @@ TEST(RcuTest, Stress) {
std::vector<std::thread> threads;
constexpr uint32_t sz = 1000;
std::atomic<int*> ints[sz];
for (uint i = 0; i < sz; i++) {
for (uint32_t i = 0; i < sz; i++) {
ints[i].store(new int(0));
}
for (unsigned th = 0; th < FLAGS_threads; th++) {
......@@ -121,10 +121,10 @@ TEST(RcuTest, Stress) {
rcu_reader g;
int sum = 0;
int* ptrs[sz];
for (uint j = 0; j < sz; j++) {
for (uint32_t j = 0; j < sz; j++) {
ptrs[j] = ints[j].load(std::memory_order_acquire);
}
for (uint j = 0; j < sz; j++) {
for (uint32_t j = 0; j < sz; j++) {
sum += *ptrs[j];
}
EXPECT_EQ(sum, 0);
......@@ -149,7 +149,7 @@ TEST(RcuTest, Stress) {
updater.join();
// Cleanup for asan
synchronize_rcu();
for (uint i = 0; i < sz; i++) {
for (uint32_t i = 0; i < sz; i++) {
delete ints[i].exchange(nullptr);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment