forked from boostorg/unordered
Merge branch 'feature/cfoa' of https://github.com/boostorg/unordered into feature/cfoa
This commit is contained in:
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@ -54,6 +54,9 @@ jobs:
|
||||
- { name: Collect coverage, coverage: yes,
|
||||
compiler: gcc-8, cxxstd: '03,11', os: ubuntu-20.04, install: 'g++-8-multilib', address-model: '32,64', ccache_key: "cov" }
|
||||
|
||||
- { name: "cfoa tsan (gcc)", cxxstd: '11,14,17,20,2b', os: ubuntu-22.04, compiler: gcc-12,
|
||||
targets: 'libs/unordered/test//cfoa_tests', thread-sanitize: yes }
|
||||
|
||||
# Linux, clang, libc++
|
||||
- { compiler: clang-7, cxxstd: '03,11,14,17', os: ubuntu-20.04, stdlib: libc++, install: 'clang-7 libc++-7-dev libc++abi-7-dev' }
|
||||
- { compiler: clang-10, cxxstd: '03,11,14,17,20', os: ubuntu-20.04, stdlib: libc++, install: 'clang-10 libc++-10-dev libc++abi-10-dev' }
|
||||
@ -65,12 +68,16 @@ jobs:
|
||||
compiler: clang-12, cxxstd: '17,20,2b', os: ubuntu-20.04, stdlib: libc++, install: 'clang-12 libc++-12-dev libc++abi-12-dev', ccache_key: "san2" }
|
||||
- { compiler: clang-13, cxxstd: '03,11,14,17,20,2b', os: ubuntu-22.04, stdlib: libc++, install: 'clang-13 libc++-13-dev libc++abi-13-dev' }
|
||||
- { compiler: clang-14, cxxstd: '03,11,14,17,20,2b', os: ubuntu-22.04, stdlib: libc++, install: 'clang-14 libc++-14-dev libc++abi-14-dev' }
|
||||
|
||||
# not using libc++ because of https://github.com/llvm/llvm-project/issues/52771
|
||||
- { name: "clang-14 w/ sanitizers (03,11,14)", sanitize: yes,
|
||||
compiler: clang-14, cxxstd: '03,11,14', os: ubuntu-22.04, ccache_key: "san1" }
|
||||
- { name: "clang-14 w/ sanitizers (17,20,2b)", sanitize: yes,
|
||||
compiler: clang-14, cxxstd: '17,20,2b', os: ubuntu-22.04, ccache_key: "san2" }
|
||||
|
||||
- { name: "cfoa tsan (clang)", cxxstd: '11,14,17,20,2b', os: ubuntu-22.04, compiler: clang-14,
|
||||
targets: 'libs/unordered/test//cfoa_tests', thread-sanitize: yes }
|
||||
|
||||
# OSX, clang
|
||||
- { compiler: clang, cxxstd: '03,11,14,17,2a', os: macos-11, }
|
||||
- { compiler: clang, cxxstd: '03,11,14,17,2a', os: macos-12, sanitize: yes }
|
||||
@ -184,6 +191,8 @@ jobs:
|
||||
B2_COMPILER: ${{matrix.compiler}}
|
||||
B2_CXXSTD: ${{matrix.cxxstd}}
|
||||
B2_SANITIZE: ${{matrix.sanitize}}
|
||||
B2_TSAN: ${{matrix.thread-sanitize}}
|
||||
B2_TARGETS: ${{matrix.targets}}
|
||||
B2_STDLIB: ${{matrix.stdlib}}
|
||||
# More entries can be added in the same way, see the B2_ARGS assignment in ci/enforce.sh for the possible keys.
|
||||
# B2_DEFINES: ${{matrix.defines}}
|
||||
|
@ -126,7 +126,7 @@ namespace boost {
|
||||
///
|
||||
|
||||
bool insert(value_type const& obj) { return table_.insert(obj); }
|
||||
bool insert(value_type&& obj) { return table_.insert(obj); }
|
||||
bool insert(value_type&& obj) { return table_.insert(std::move(obj)); }
|
||||
|
||||
bool insert(init_type const& obj) { return table_.insert(obj); }
|
||||
bool insert(init_type&& obj) { return table_.insert(std::move(obj)); }
|
||||
@ -143,6 +143,10 @@ namespace boost {
|
||||
{
|
||||
return table_.visit_all(std::move(f));
|
||||
}
|
||||
|
||||
/// Hash Policy
|
||||
///
|
||||
void rehash(size_type n) { table_.rehash(n); }
|
||||
};
|
||||
} // namespace unordered
|
||||
} // namespace boost
|
||||
|
@ -164,3 +164,5 @@ rule build_cfoa ( name )
|
||||
}
|
||||
|
||||
build_cfoa insert_tests ;
|
||||
|
||||
alias cfoa_tests : cfoa_insert_tests ;
|
||||
|
@ -188,37 +188,22 @@ namespace {
|
||||
{
|
||||
template <class T, class X> void operator()(std::vector<T>& values, X& x)
|
||||
{
|
||||
std::mutex m;
|
||||
std::vector<std::thread> threads;
|
||||
std::condition_variable cv;
|
||||
|
||||
auto ready = false;
|
||||
|
||||
auto subslices = split(values, num_threads);
|
||||
|
||||
BOOST_ASSERT(subslices.size() == num_threads);
|
||||
|
||||
for (std::size_t i = 0; i < num_threads; ++i) {
|
||||
threads.emplace_back([&x, &m, &ready, &subslices, &cv, i] {
|
||||
std::unique_lock<std::mutex> lk(m);
|
||||
cv.wait(lk, [&] { return ready; });
|
||||
lk.unlock();
|
||||
threads.emplace_back([&x, &subslices, i] {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
auto s = subslices[i];
|
||||
|
||||
for (auto const& r : s) {
|
||||
bool b = x.insert(r);
|
||||
(void)b;
|
||||
{
|
||||
auto s = subslices[i];
|
||||
for (auto const& r : s) {
|
||||
bool b = x.insert(r);
|
||||
(void)b;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(m);
|
||||
ready = true;
|
||||
}
|
||||
cv.notify_all();
|
||||
|
||||
for (auto& t : threads) {
|
||||
t.join();
|
||||
}
|
||||
@ -229,9 +214,32 @@ namespace {
|
||||
{
|
||||
template <class T, class X> void operator()(std::vector<T>& values, X& x)
|
||||
{
|
||||
for (auto& r : values) {
|
||||
bool b = x.insert(std::move(r));
|
||||
(void)b;
|
||||
BOOST_TEST_EQ(raii::copy_constructor, 0);
|
||||
|
||||
std::vector<std::thread> threads;
|
||||
auto subslices = split(values, num_threads);
|
||||
|
||||
for (std::size_t i = 0; i < num_threads; ++i) {
|
||||
threads.emplace_back([&x, &subslices, i] {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
{
|
||||
auto s = subslices[i];
|
||||
for (auto& r : s) {
|
||||
bool b = x.insert(std::move(r));
|
||||
(void)b;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
for (auto& t : threads) {
|
||||
t.join();
|
||||
}
|
||||
|
||||
if (std::is_same<T, typename X::value_type>::value) {
|
||||
BOOST_TEST_EQ(raii::copy_constructor, x.size());
|
||||
} else {
|
||||
BOOST_TEST_EQ(raii::copy_constructor, 0);
|
||||
}
|
||||
}
|
||||
} rvalue_inserter;
|
||||
@ -240,14 +248,29 @@ namespace {
|
||||
{
|
||||
template <class T, class X> void operator()(std::vector<T>& values, X& x)
|
||||
{
|
||||
x.insert(values.begin(), values.end());
|
||||
std::vector<std::thread> threads;
|
||||
auto subslices = split(values, num_threads);
|
||||
|
||||
for (std::size_t i = 0; i < num_threads; ++i) {
|
||||
threads.emplace_back([&x, &subslices, i] {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
{
|
||||
auto s = subslices[i];
|
||||
x.insert(s.begin(), s.end());
|
||||
}
|
||||
});
|
||||
}
|
||||
for (auto& t : threads) {
|
||||
t.join();
|
||||
}
|
||||
}
|
||||
} iterator_range_inserter;
|
||||
|
||||
template <class X, class G, class F>
|
||||
void insert(X*, G gen, F inserter, test::random_generator rg)
|
||||
{
|
||||
auto values = make_random_values(1024 * 1024, [&] { return gen(rg); });
|
||||
auto values = make_random_values(1024 * 16, [&] { return gen(rg); });
|
||||
BOOST_TEST_GT(values.size(), 0u);
|
||||
|
||||
auto reference_map =
|
||||
@ -264,7 +287,10 @@ namespace {
|
||||
|
||||
using value_type = typename X::value_type;
|
||||
BOOST_TEST_EQ(x.size(), x.visit_all([&](value_type const& kv) {
|
||||
BOOST_TEST(reference_map.contains(kv.first));
|
||||
if (BOOST_TEST(reference_map.contains(kv.first)) &&
|
||||
rg == test::sequential) {
|
||||
BOOST_TEST_EQ(kv.second, reference_map[kv.first]);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@ -286,15 +312,15 @@ namespace {
|
||||
} // namespace
|
||||
|
||||
using test::default_generator;
|
||||
using test::generate_collisions;
|
||||
using test::limited_range;
|
||||
using test::sequential;
|
||||
|
||||
// clang-format off
|
||||
UNORDERED_TEST(
|
||||
insert, ((map))
|
||||
((value_type_generator)(init_type_generator))
|
||||
((lvalue_inserter)(rvalue_inserter)(iterator_range_inserter))
|
||||
((default_generator)(limited_range)))
|
||||
((default_generator)(sequential)(limited_range)))
|
||||
// clang-format on
|
||||
|
||||
RUN_TESTS()
|
||||
|
Reference in New Issue
Block a user