29 using namespace folly;
40 using Node = detail::LifoSemRawNode<DeterministicAtomic>;
41 Node::Pool& pool_{Node::pool()};
56 const int opsPerThread = 10000;
58 std::atomic<int> blocks(0);
60 for (
auto& thr : threads) {
61 thr = std::thread([&] {
63 for (
int i = 0;
i < opsPerThread; ++
i) {
77 for (
auto& thr : threads) {
81 LOG(
INFO) << opsPerThread *
sizeof(
threads) /
sizeof(threads[0])
82 <<
" post/wait pairs, " << blocks <<
" blocked";
88 const int iters = 100;
90 for (
int pass = 0; pass < 10; ++pass) {
95 for (
int i = 0;
i < iters; ++
i) {
103 for (
int i = 0;
i < iters; ++
i) {
117 const int iters = 100;
119 for (
int pass = 0; pass < 10; ++pass) {
123 for (
int i = 0;
i < iters; ++
i) {
128 for (
int i = 0;
i < iters; ++
i) {
143 const int iters = 100;
144 const int numThreads = 2;
145 const int width = 10;
147 for (
int pass = 0; pass < 10; ++pass) {
150 std::vector<std::thread>
threads;
151 while (threads.size() < numThreads) {
153 for (
int i = 0;
i < iters; ++
i) {
155 for (
int w = 0; w < width; ++w) {
161 for (
auto& thr : threads) {
172 const int iters = 1000;
174 for (
int pass = 0; pass < 10; ++pass) {
178 for (
int i = 0;
i < iters; ++
i) {
182 for (
int i = 0;
i < iters; ++
i) {
201 for (
int pass = 0; pass < 10; ++pass) {
203 std::vector<std::thread>
threads;
204 while (threads.size() < 20) {
216 for (
auto& thr : threads) {
235 const int NPOSTS = 1000;
237 auto producer = [&] {
238 for (
int i = 0;
i < NPOSTS; ++
i) {
246 auto consumer = [&] {
249 stop = consumer_stop.
load();
261 consumer_stop.
store(
true);
273 for (
int pass = 0; pass < 10; ++pass) {
275 std::vector<std::thread>
threads;
276 while (threads.size() < 20) {
278 for (
int i = 0;
i < 10;
i++) {
290 std::vector<std::thread> threads2;
291 while (threads2.size() < 20) {
293 for (
int i = 0;
i < 10;
i++) {
302 for (
auto& thr : threads) {
305 for (
auto& thr : threads2) {
316 auto thr = std::thread([&] {
317 for (
size_t i = 0;
i < iters; ++
i) {
322 for (
size_t i = 0;
i < iters; ++
i) {
331 auto thr = std::thread([&] {
332 for (
size_t i = 0;
i < iters; ++
i) {
336 for (
size_t i = 0;
i < iters; ++
i) {
344 for (
size_t n = 0; n < iters; ++n) {
352 for (
size_t n = 0; n < iters; ++n) {
360 for (
size_t n = 0; n < iters; ++n) {
370 for (
size_t n = 0; n < iters; ++n) {
379 for (
size_t n = 0; n < iters; ++n) {
389 for (
size_t n = 0; n < iters; ++n) {
398 std::vector<std::thread>
threads;
399 std::atomic<bool> go(
false);
402 for (
int t = 0;
t < waiters; ++
t) {
403 threads.emplace_back([=, &sem] {
409 for (
int t = 0;
t < posters; ++
t) {
410 threads.emplace_back([=, &sem, &go] {
422 for (
auto& thr : threads) {
467 gflags::ParseCommandLineFlags(&argc, &
argv,
true);
#define EXPECT_THROW(statement, expected_exception)
#define ASSERT_EQ(val1, val2)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
#define LIFOSEM_DECLARE_POOL(Atom, capacity)
#define EXPECT_EQ(val1, val2)
LifoSemImpl< DeterministicAtomic > DLifoSem
#define BENCHMARK_SUSPEND
bool post()
Silently saturates if value is already 2^32-1.
T load(std::memory_order mo=std::memory_order_seq_cst) const noexcept
static std::thread thread(Func &&func, Args &&...args)
—— Concurrent Priority Queue Implementation ——
int main(int argc, char **argv)
std::vector< std::thread::id > threads
static std::function< size_t(size_t)> uniform(uint64_t seed)
uint32_t valueGuess() const
#define BENCHMARK_NAMED_PARAM(name, param_name,...)
bool tryWait()
Returns true iff value was decremented.
bool isShutdown() const
Returns true iff shutdown() has been called.
static std::function< size_t(size_t)> uniformSubset(uint64_t seed, size_t n=2, size_t m=64)
TEST(ProgramOptionsTest, Errors)
#define EXPECT_TRUE(condition)
void store(T v, std::memory_order mo=std::memory_order_seq_cst) noexcept
BENCHMARK(fbFollyGlobalBenchmarkBaseline)
bool runBenchmarksOnFlag()
bool try_wait_for(const std::chrono::duration< Rep, Period > &timeout)
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
The exception thrown when wait()ing on an isShutdown() LifoSem.
static void contendedUse(uint32_t n, int posters, int waiters)
#define EXPECT_FALSE(condition)
static void join(std::thread &child)
TEST_F(FileUtilTest, read)
uint32_t randomNumberSeed()
DeterministicSchedule DSched
void asm_volatile_memory()
#define EXPECT_GT(val1, val2)