Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unordered and ordered containers ranges for empty containers #673

Closed
wants to merge 19 commits into from

Conversation

kboyarinov
Copy link
Contributor

Description

Fix for empty ordered and unordered containers range_type and const_range_type

Fixes #641

  • - git commit message contains appropriate signed-off-by string (see CONTRIBUTING.md for details)

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add respective label(s) to PR if you have permissions

  • bug fix - change which fixes an issue
  • new feature - change which adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and for some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

List users with @ to send notifications

Other information

REQUIRE_MESSAGE(r.begin() == r.end(), "Incorrect iterators on empty range");
REQUIRE_MESSAGE(r.begin() == cont.begin(), "Incorrect iterators on empty range");

Range r2(r, tbb::split{});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not stated if split ctor can be used for non-divisible range; however, the spec says about is_divisible: "True if the range can be partitioned into two subranges.". I.e. range cannot be partitioned if false. Does it mean that we cannot use splitting ctor to partition the empty range?

@anton-potapov
Copy link
Contributor

@kboyarinov please fix the test failures

isaevil and others added 18 commits December 27, 2021 15:33
* Fixed incorrect definitions of assignment operators in associative containers.

This fixes incorrect return types of assignment operators imported from
base classes. Other than copy and move assignment operators, which are
generated by the compiler even if imported with a using-declaration,
the imported operators will be returning a reference to the base class
instead of the derived class.

Fixes #372.

Signed-off-by: Andrey Semashev <[email protected]>
Signed-off-by: Ilya Isaev <[email protected]>
…memory. (#671)

This uses the standard allocator for allocating and freeing memory with
higher alignment requirements instead of the hand-rolled implementation.

Signed-off-by: Andrey Semashev <[email protected]>
* Add raii to aggregator to prevent stuck

Signed-off-by: Mishin, Ilya <[email protected]>

* Add test

Signed-off-by: Mishin, Ilya <[email protected]>

* Reuse tbb raii guard

Signed-off-by: Mishin, Ilya <[email protected]>

* Add header

Signed-off-by: Mishin, Ilya <[email protected]>

* execute_and_wait lightweight task

Signed-off-by: Mishin, Ilya <[email protected]>

* remove unused headers

Signed-off-by: Mishin, Ilya <[email protected]>

* remove space

Signed-off-by: Mishin, Ilya <[email protected]>

* remove std::function

Signed-off-by: Mishin, Ilya <[email protected]>

* noexcept lightweight body

Signed-off-by: Mishin, Ilya <[email protected]>

* fix cmake

Signed-off-by: Mishin, Ilya <[email protected]>

* fix space

Signed-off-by: Mishin, Ilya <[email protected]>

* gcc error

Signed-off-by: Mishin, Ilya <[email protected]>

* declval gateway_type

Signed-off-by: Mishin, Ilya <[email protected]>

* new tests

Signed-off-by: Mishin, Ilya <[email protected]>

* template tests

Signed-off-by: Mishin, Ilya <[email protected]>

* macro TBB_USE_EXCEPTIONS

Signed-off-by: Mishin, Ilya <[email protected]>

* Apply suggestions from code review

Co-authored-by: Aleksei Fedotov <[email protected]>

Co-authored-by: Aleksei Fedotov <[email protected]>
* Deallocate object with based on actual type

Signed-off-by: Serov, Vladimir <[email protected]>
* Fix limiter_node decrementer

Signed-off-by: Mishin, Ilya <[email protected]>

* Fix align

Signed-off-by: Mishin, Ilya <[email protected]>

* add new variable for check unused decrements

Signed-off-by: Mishin, Ilya <[email protected]>

* remove iostream

Signed-off-by: Mishin, Ilya <[email protected]>

* remove unnesessary cast

Signed-off-by: Mishin, Ilya <[email protected]>

* align whitespaces

Signed-off-by: Mishin, Ilya <[email protected]>

* Fix whitespace alignment

Signed-off-by: Serov, Vladimir <[email protected]>

* Revert workaround for GCC

Signed-off-by: Serov, Vladimir <[email protected]>

Co-authored-by: Serov, Vladimir <[email protected]>
Exclude non-glibc linux systems along with android
Fixes
src/tbb/dynamic_link.cpp:417:29: error: use
 of undeclared identifier 'RTLD_DEEPBIND'                                                                                    |             flags = flags | RTLD_DEEPBIND;
|                             ^

Signed-off-by: Khem Raj <[email protected]>
* Update README.md

Signed-off-by: Alexandra Epanchinzeva [email protected]

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md
Moving task_group_exptensions out of the preview

- moved all but :
  - is_inside_task
  - scheduller bypass

- replaced exceptions with asserts for undefined behavior
 - made some flags in the tests non-atomic for TSAN to raise a flag if
implementation is incorrect

Signed-off-by: Anton Potapov <[email protected]>
Co-authored-by: Ilya Isaev <[email protected]>
Co-authored-by: Alex <[email protected]>
* Added optimized x86 atomic_fence for gcc-compatible compilers.

On x86 (32 and 64-bit) any lock-prefixed instruction provides sequential
consistency guarantees for atomic operations and is more efficient than
mfence.

We are choosing a "lock not" on a dummy byte on the stack for the following
reasons:

 - The "not" instruction does not affect flags or clobber any registers.
   The memory operand is presumably accessible through esp/rsp.
 - The dummy byte variable is at the top of the stack, which is likely
   hot in cache.
 - The dummy variable does not alias any other data on the stack, which
   means the "lock not" instruction won't introduce any false data
   dependencies with prior or following instructions.

In order to avoid various sanitizers and valgrind complaining, we have to
initialize the dummy variable to zero prior to the operation.

Additionally, for memory orders weaker than seq_cst there is no need for
any special instructions, and we only need a compiler fence. For the relaxed
memory order we don't need even that.

This optimization is only enabled for gcc up to version 11. In gcc 11 the
compiler implements a similar optimization for std::atomic_thread_fence.
Compilers compatible with gcc (namely, clang up to 13 and icc up to 2021.3.0,
inclusively) identify themselves as gcc < 11 and also benefit from this
optimization, as they otherwise generate mfence for
std::atomic_thread_fence(std::memory_order_seq_cst).

Signed-off-by: Andrey Semashev <[email protected]>

* Removed explicit mfence in atomic_fence on Windows.

The necessary instructions according to the memory order argument
should already be generated by std::atomic_thread_fence.

Signed-off-by: Andrey Semashev <[email protected]>

* Removed memory order argument from atomic_fence.

The code uses memory_order_seq_cst in all call sites of atomic_fence,
so remove the argument and simplifiy the implementation a bit. Also, renamed
the function to make the memory order it implements apparent.

Signed-off-by: Andrey Semashev <[email protected]>
Class template inheritance doesn't work well with function-local types
Move class definition to global scope

Signed-off-by: Serov, Vladimir <[email protected]>
Signed-off-by: Vladislav Shchapov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

empty ranges for concurrent_map and concurrent_unordered_map cause crash / assert