proxygen
|
#include <folly/synchronization/Hazptr.h>
#include <folly/synchronization/example/HazptrLockFreeLIFO.h>
#include <folly/synchronization/example/HazptrSWMRSet.h>
#include <folly/synchronization/example/HazptrWideCAS.h>
#include <folly/synchronization/test/Barrier.h>
#include <folly/portability/GFlags.h>
#include <folly/portability/GTest.h>
#include <folly/test/DeterministicSchedule.h>
#include <atomic>
#include <thread>
Go to the source code of this file.
Classes | |
class | Count |
class | Node< Atom > |
class | NodeRC< Mutable, Atom > |
struct | List< T, Atom > |
class | NodeAuto< Atom > |
class | HazptrPreInitTest |
Typedefs | |
using | DSched = folly::test::DeterministicSchedule |
Functions | |
DEFINE_bool (bench, false,"run benchmark") | |
DEFINE_int64 (num_reps, 10,"Number of test reps") | |
DEFINE_int32 (num_threads, 6,"Number of threads") | |
DEFINE_int64 (num_ops, 1003,"Number of ops or pairs of ops per rep") | |
template<template< typename > class Atom = std::atomic> | |
void | basic_objects_test () |
template<template< typename > class Atom = std::atomic> | |
void | copy_and_move_test () |
template<template< typename > class Atom = std::atomic> | |
void | basic_holders_test () |
template<template< typename > class Atom = std::atomic> | |
void | basic_protection_test () |
template<template< typename > class Atom = std::atomic> | |
void | virtual_test () |
template<template< typename > class Atom = std::atomic> | |
void | destruction_test (hazptr_domain< Atom > &domain) |
template<template< typename > class Atom = std::atomic> | |
void | move_test () |
template<template< typename > class Atom = std::atomic> | |
void | array_test () |
template<template< typename > class Atom = std::atomic> | |
void | array_dtor_full_tc_test () |
template<template< typename > class Atom = std::atomic> | |
void | local_test () |
template<bool Mutable, template< typename > class Atom = std::atomic> | |
void | linked_test () |
template<bool Mutable, template< typename > class Atom = std::atomic> | |
void | mt_linked_test () |
template<template< typename > class Atom = std::atomic> | |
void | auto_retire_test () |
template<template< typename > class Atom = std::atomic> | |
void | free_function_retire_test () |
template<template< typename > class Atom = std::atomic> | |
void | cleanup_test () |
template<template< typename > class Atom = std::atomic> | |
void | priv_dtor_test () |
template<template< typename > class Atom = std::atomic> | |
void | lifo_test () |
template<template< typename > class Atom = std::atomic> | |
void | swmr_test () |
template<template< typename > class Atom = std::atomic> | |
void | wide_cas_test () |
TEST (HazptrTest, basic_objects) | |
TEST_F (HazptrPreInitTest, dsched_basic_objects) | |
TEST (HazptrTest, copy_and_move) | |
TEST_F (HazptrPreInitTest, dsched_copy_and_move) | |
TEST (HazptrTest, basic_holders) | |
TEST_F (HazptrPreInitTest, dsched_basic_holders) | |
TEST (HazptrTest, basic_protection) | |
TEST_F (HazptrPreInitTest, dsched_basic_protection) | |
TEST (HazptrTest, virtual) | |
TEST_F (HazptrPreInitTest, dsched_virtual) | |
TEST (HazptrTest, destruction) | |
TEST_F (HazptrPreInitTest, dsched_destruction) | |
TEST (HazptrTest, move) | |
TEST_F (HazptrPreInitTest, dsched_move) | |
TEST (HazptrTest, array) | |
TEST_F (HazptrPreInitTest, dsched_array) | |
TEST (HazptrTest, array_dtor_full_tc) | |
TEST_F (HazptrPreInitTest, dsched_array_dtor_full_tc) | |
TEST (HazptrTest, local) | |
TEST_F (HazptrPreInitTest, dsched_local) | |
TEST (HazptrTest, linked_mutable) | |
TEST_F (HazptrPreInitTest, dsched_linked_mutable) | |
TEST (HazptrTest, linked_immutable) | |
TEST_F (HazptrPreInitTest, dsched_linked_immutable) | |
TEST (HazptrTest, mt_linked_mutable) | |
TEST_F (HazptrPreInitTest, dsched_mt_linked_mutable) | |
TEST (HazptrTest, mt_linked_immutable) | |
TEST_F (HazptrPreInitTest, dsched_mt_linked_immutable) | |
TEST (HazptrTest, auto_retire) | |
TEST_F (HazptrPreInitTest, dsched_auto_retire) | |
TEST (HazptrTest, free_function_retire) | |
TEST_F (HazptrPreInitTest, dsched_free_function_retire) | |
TEST (HazptrTest, cleanup) | |
TEST_F (HazptrPreInitTest, dsched_cleanup) | |
TEST (HazptrTest, priv_dtor) | |
TEST_F (HazptrPreInitTest, dsched_priv_dtor) | |
TEST (HazptrTest, lifo) | |
TEST_F (HazptrPreInitTest, dsched_lifo) | |
TEST (HazptrTest, swmr) | |
TEST_F (HazptrPreInitTest, dsched_swmr) | |
TEST (HazptrTest, wide_cas) | |
TEST_F (HazptrPreInitTest, dsched_wide_cas) | |
TEST (HazptrTest, reclamation_without_calling_cleanup) | |
template<typename InitFunc , typename Func , typename EndFunc > | |
uint64_t | run_once (int nthreads, const InitFunc &init, const Func &fn, const EndFunc &endFn) |
template<typename RepFunc > | |
uint64_t | bench (std::string name, int ops, const RepFunc &repFn) |
uint64_t | holder_bench (std::string name, int nthreads) |
template<size_t M> | |
uint64_t | array_bench (std::string name, int nthreads) |
template<size_t M> | |
uint64_t | local_bench (std::string name, int nthreads) |
uint64_t | obj_bench (std::string name, int nthreads) |
uint64_t | list_hoh_bench (std::string name, int nthreads, int size, bool provided=false) |
uint64_t | list_protect_all_bench (std::string name, int nthreads, int size, bool provided=false) |
uint64_t | cleanup_bench (std::string name, int nthreads) |
void | benches () |
TEST (HazptrTest, bench) | |
Variables | |
static Count | c_ |
const int | ops = 1000000 |
const int | nthr [] = {1, 10} |
const int | sizes [] = {10, 20} |
Definition at line 52 of file HazptrTest.cpp.
|
inline |
Definition at line 1193 of file HazptrTest.cpp.
References a, bench(), bm::init(), nthreads, ops, and run_once().
void array_dtor_full_tc_test | ( | ) |
Definition at line 456 of file HazptrTest.cpp.
References Atom, M, folly::gen::move, uint8_t, and x.
Referenced by TEST().
void array_test | ( | ) |
Definition at line 436 of file HazptrTest.cpp.
References ASSERT_EQ, Atom, h, i, and folly::gen::move.
Referenced by TEST().
void auto_retire_test | ( | ) |
Definition at line 607 of file HazptrTest.cpp.
References a, folly::hazptr_obj_linked< Atom >::acquire_link_safe(), ASSERT_EQ, Atom, b, c, Count::clear(), Count::ctors(), Count::dtors(), and h.
Referenced by TEST().
void basic_holders_test | ( | ) |
Definition at line 347 of file HazptrTest.cpp.
Referenced by TEST().
void basic_objects_test | ( | ) |
Definition at line 280 of file HazptrTest.cpp.
References folly::hazptr_obj_linked< Atom >::acquire_link_safe(), ASSERT_EQ, Atom, Count::clear(), Count::ctors(), Count::dtors(), folly::hazptr_obj_base< T, Atom, D >::retire(), and folly::hazptr_obj_base_linked< T, Atom, D >::retire().
Referenced by TEST().
void basic_protection_test | ( | ) |
Definition at line 354 of file HazptrTest.cpp.
References ASSERT_EQ, Atom, Count::clear(), Count::ctors(), Count::dtors(), h, and folly::hazptr_holder< Atom >::reset().
Referenced by TEST().
uint64_t bench | ( | std::string | name, |
int | ops, | ||
const RepFunc & | repFn | ||
) |
Definition at line 1147 of file HazptrTest.cpp.
References max, min, name, string, sum(), uint64_t, and folly::unit.
Referenced by array_bench(), cleanup_bench(), holder_bench(), list_hoh_bench(), list_protect_all_bench(), local_bench(), and obj_bench().
void benches | ( | ) |
Definition at line 1308 of file HazptrTest.cpp.
References cleanup_bench(), holder_bench(), i, list_hoh_bench(), list_protect_all_bench(), nthr, obj_bench(), and sizes.
Referenced by TEST().
uint64_t cleanup_bench | ( | std::string | name, |
int | nthreads | ||
) |
Definition at line 1290 of file HazptrTest.cpp.
References bench(), folly::hazptr_cleanup(), i, bm::init(), ops, and run_once().
Referenced by benches().
void cleanup_test | ( | ) |
Definition at line 720 of file HazptrTest.cpp.
References ASSERT_EQ, Atom, Count::clear(), Count::ctors(), Count::dtors(), h, i, folly::test::DeterministicSchedule::join(), folly::hazptr_obj_base< T, Atom, D >::retire(), folly::pushmi::detail::t, folly::test::DeterministicSchedule::thread(), and threads.
Referenced by TEST().
void copy_and_move_test | ( | ) |
Definition at line 317 of file HazptrTest.cpp.
References a, Atom, and folly::gen::move.
Referenced by TEST().
DEFINE_int32 | ( | num_threads | , |
6 | , | ||
"Number of threads" | |||
) |
DEFINE_int64 | ( | num_reps | , |
10 | , | ||
"Number of test reps" | |||
) |
void destruction_test | ( | hazptr_domain< Atom > & | domain | ) |
Definition at line 387 of file HazptrTest.cpp.
References Atom, i, cpp.ast::next(), and val.
Referenced by TEST().
void free_function_retire_test | ( | ) |
Definition at line 697 of file HazptrTest.cpp.
References ASSERT_TRUE, Atom, testing::gmock_matchers_test::foo, foo2(), and folly::hazptr_domain< Atom >::retire().
Referenced by TEST().
|
inline |
Definition at line 1178 of file HazptrTest.cpp.
References bench(), h, bm::init(), nthreads, ops, and run_once().
Referenced by benches().
void lifo_test | ( | ) |
Definition at line 813 of file HazptrTest.cpp.
References ASSERT_EQ, ASSERT_TRUE, Atom, i, folly::test::DeterministicSchedule::join(), folly::fibers::local(), folly::HazptrLockFreeLIFO< T, Atom >::pop(), folly::HazptrLockFreeLIFO< T, Atom >::push(), s, sum(), folly::pushmi::detail::t, folly::test::DeterministicSchedule::thread(), threads, and v.
Referenced by TEST().
void linked_test | ( | ) |
Definition at line 500 of file HazptrTest.cpp.
References ASSERT_EQ, ASSERT_GT, Atom, Count::clear(), Count::ctors(), Count::dtors(), i, folly::gen::Mutable, NodeRC< Mutable, Atom >::next(), folly::hazptr_obj_base_linked< NodeRC< Mutable, Atom >, Atom >::retire(), and v.
uint64_t list_hoh_bench | ( | std::string | name, |
int | nthreads, | ||
int | size, | ||
bool | provided = false |
||
) |
Definition at line 1238 of file HazptrTest.cpp.
References bench(), List< T, Atom >::hand_over_hand(), bm::init(), nthreads, ops, and run_once().
Referenced by benches().
uint64_t list_protect_all_bench | ( | std::string | name, |
int | nthreads, | ||
int | size, | ||
bool | provided = false |
||
) |
Definition at line 1264 of file HazptrTest.cpp.
References bench(), bm::init(), nthreads, ops, List< T, Atom >::protect_all(), and run_once().
Referenced by benches().
|
inline |
Definition at line 1208 of file HazptrTest.cpp.
References a, bench(), bm::init(), nthreads, ops, and run_once().
void local_test | ( | ) |
Definition at line 485 of file HazptrTest.cpp.
Referenced by TEST().
void move_test | ( | ) |
Definition at line 409 of file HazptrTest.cpp.
References ASSERT_EQ, Atom, i, folly::gen::move, and folly::hazptr_holder< Atom >::reset().
Referenced by TEST().
void mt_linked_test | ( | ) |
Definition at line 540 of file HazptrTest.cpp.
References ASSERT_EQ, ASSERT_GT, Atom, Count::clear(), Count::ctors(), Count::dtors(), folly::hazptr_holder< Atom >::get_protected(), i, folly::test::DeterministicSchedule::join(), folly::gen::Mutable, NodeRC< Mutable, Atom >::next(), nthr, folly::pushmi::detail::t, folly::test::DeterministicSchedule::thread(), folly::hazptr_obj_base_linked< NodeRC< Mutable, Atom >, Atom >::unlink(), and v.
|
inline |
Definition at line 1222 of file HazptrTest.cpp.
References bench(), bm::init(), nthreads, ops, and run_once().
Referenced by benches().
void priv_dtor_test | ( | ) |
Definition at line 790 of file HazptrTest.cpp.
References ASSERT_EQ, Atom, Count::clear(), Count::ctors(), Count::dtors(), folly::test::DeterministicSchedule::join(), and folly::test::DeterministicSchedule::thread().
Referenced by TEST().
uint64_t run_once | ( | int | nthreads, |
const InitFunc & | init, | ||
const Func & | fn, | ||
const EndFunc & | endFn | ||
) |
Definition at line 1116 of file HazptrTest.cpp.
References b, count, folly::hazptr_cleanup(), bm::init(), now(), nthreads, start, folly::pushmi::detail::t, threads, and folly::test::Barrier::wait().
Referenced by array_bench(), cleanup_bench(), holder_bench(), list_hoh_bench(), list_protect_all_bench(), local_bench(), and obj_bench().
void swmr_test | ( | ) |
Definition at line 840 of file HazptrTest.cpp.
References folly::HazptrSWMRSet< T, Atom >::add(), Atom, folly::HazptrSWMRSet< T, Atom >::contains(), i, folly::test::DeterministicSchedule::join(), folly::HazptrSWMRSet< T, Atom >::remove(), s, folly::pushmi::detail::t, T, folly::test::DeterministicSchedule::thread(), threads, and uint64_t.
Referenced by TEST().
TEST | ( | HazptrTest | , |
basic_objects | |||
) |
TEST | ( | HazptrTest | , |
copy_and_move | |||
) |
TEST | ( | HazptrTest | , |
basic_holders | |||
) |
TEST | ( | HazptrTest | , |
basic_protection | |||
) |
TEST | ( | HazptrTest | , |
virtual | |||
) |
Definition at line 932 of file HazptrTest.cpp.
References virtual_test().
TEST | ( | HazptrTest | , |
destruction | |||
) |
Definition at line 941 of file HazptrTest.cpp.
References destruction_test().
TEST | ( | HazptrTest | , |
move | |||
) |
Definition at line 959 of file HazptrTest.cpp.
References move_test().
TEST | ( | HazptrTest | , |
array | |||
) |
Definition at line 968 of file HazptrTest.cpp.
References array_test().
TEST | ( | HazptrTest | , |
array_dtor_full_tc | |||
) |
TEST | ( | HazptrTest | , |
local | |||
) |
Definition at line 986 of file HazptrTest.cpp.
References local_test().
TEST | ( | HazptrTest | , |
linked_mutable | |||
) |
Definition at line 995 of file HazptrTest.cpp.
TEST | ( | HazptrTest | , |
linked_immutable | |||
) |
Definition at line 1004 of file HazptrTest.cpp.
TEST | ( | HazptrTest | , |
mt_linked_mutable | |||
) |
Definition at line 1013 of file HazptrTest.cpp.
TEST | ( | HazptrTest | , |
mt_linked_immutable | |||
) |
Definition at line 1022 of file HazptrTest.cpp.
TEST | ( | HazptrTest | , |
auto_retire | |||
) |
TEST | ( | HazptrTest | , |
free_function_retire | |||
) |
TEST | ( | HazptrTest | , |
cleanup | |||
) |
Definition at line 1049 of file HazptrTest.cpp.
References cleanup_test().
TEST | ( | HazptrTest | , |
priv_dtor | |||
) |
TEST | ( | HazptrTest | , |
lifo | |||
) |
Definition at line 1067 of file HazptrTest.cpp.
References lifo_test().
TEST | ( | HazptrTest | , |
swmr | |||
) |
Definition at line 1076 of file HazptrTest.cpp.
References swmr_test().
TEST | ( | HazptrTest | , |
wide_cas | |||
) |
Definition at line 1085 of file HazptrTest.cpp.
References wide_cas_test().
TEST | ( | HazptrTest | , |
reclamation_without_calling_cleanup | |||
) |
Definition at line 1094 of file HazptrTest.cpp.
References ASSERT_GT, Count::clear(), Count::dtors(), folly::detail::hazptr_domain_rcount_threshold(), i, nthr, folly::hazptr_obj_base< T, Atom, D >::retire(), and folly::pushmi::detail::t.
TEST | ( | HazptrTest | , |
bench | |||
) |
TEST_F | ( | HazptrPreInitTest | , |
dsched_basic_objects | |||
) |
Definition at line 900 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_copy_and_move | |||
) |
Definition at line 909 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_basic_holders | |||
) |
Definition at line 918 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_basic_protection | |||
) |
Definition at line 927 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_virtual | |||
) |
Definition at line 936 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_destruction | |||
) |
Definition at line 949 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_move | |||
) |
Definition at line 963 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_array | |||
) |
Definition at line 972 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_array_dtor_full_tc | |||
) |
Definition at line 981 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_local | |||
) |
Definition at line 990 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_linked_mutable | |||
) |
Definition at line 999 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_linked_immutable | |||
) |
Definition at line 1008 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_mt_linked_mutable | |||
) |
Definition at line 1017 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_mt_linked_immutable | |||
) |
Definition at line 1026 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_auto_retire | |||
) |
Definition at line 1035 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_free_function_retire | |||
) |
Definition at line 1044 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_cleanup | |||
) |
Definition at line 1053 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_priv_dtor | |||
) |
Definition at line 1062 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_lifo | |||
) |
Definition at line 1071 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_swmr | |||
) |
Definition at line 1080 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
TEST_F | ( | HazptrPreInitTest | , |
dsched_wide_cas | |||
) |
Definition at line 1089 of file HazptrTest.cpp.
References folly::test::DeterministicSchedule::uniform().
void virtual_test | ( | ) |
Definition at line 369 of file HazptrTest.cpp.
References a, ASSERT_EQ, Atom, i, and folly::hazptr_holder< Atom >::reset().
Referenced by TEST().
void wide_cas_test | ( | ) |
Definition at line 866 of file HazptrTest.cpp.
References ASSERT_FALSE, ASSERT_TRUE, folly::HazptrWideCAS< T, Atom >::cas(), s, and string.
Referenced by TEST().
|
static |
Definition at line 94 of file HazptrTest.cpp.
Referenced by folly::padded::Adaptor< IntNodeVec >::allocate_back(), folly::padded::Adaptor< IntNodeVec >::back(), folly::padded::Adaptor< IntNodeVec >::begin(), folly::padded::Adaptor< IntNodeVec >::capacity(), folly::padded::Adaptor< IntNodeVec >::cbegin(), folly::padded::Adaptor< IntNodeVec >::cend(), folly::padded::Adaptor< IntNodeVec >::clear(), folly::padded::Adaptor< IntNodeVec >::empty(), folly::padded::Adaptor< IntNodeVec >::end(), folly::padded::Adaptor< IntNodeVec >::front(), folly::padded::Adaptor< IntNodeVec >::max_size(), folly::padded::Adaptor< IntNodeVec >::move(), folly::padded::Adaptor< IntNodeVec >::operator=(), folly::padded::Adaptor< IntNodeVec >::operator[](), folly::padded::Adaptor< IntNodeVec >::padToFullNode(), folly::padded::Adaptor< IntNodeVec >::peek(), folly::padded::Adaptor< IntNodeVec >::pop_back(), folly::padded::Adaptor< IntNodeVec >::reserve(), folly::padded::Adaptor< IntNodeVec >::size(), folly::padded::Adaptor< IntNodeVec >::swap(), and testing::gmock_matchers_test::Unprintable::Unprintable().
const int nthr[] = {1, 10} |
Definition at line 1305 of file HazptrTest.cpp.
Referenced by benches(), mt_linked_test(), and TEST().
const int ops = 1000000 |
Definition at line 1176 of file HazptrTest.cpp.
Referenced by array_bench(), bench(), cleanup_bench(), concurrentOps(), concurrentSizeTest(), enq_deq_test(), folly::test::fc_test(), holder_bench(), list_hoh_bench(), list_protect_all_bench(), local_bench(), multiPusherPopper(), obj_bench(), producer_consumer_test(), run_once(), folly::test::run_test(), test(), TEST(), test_scan(), and throughtput_test().
const int sizes[] = {10, 20} |
Definition at line 1306 of file HazptrTest.cpp.
Referenced by benches(), folly::getHugePageSizes(), folly::test::TEST(), TEST(), and testSimple().