|
Boost : |
Subject: [boost] [atomic] Major rewrite landed in develop
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-05-14 14:03:01
Hi,
I've merged a major rewrite of Boost.Atomic into develop. The changes are
quite massive to describe in a few words, but the most significant ones are:
- The interface of atomic<> template and atomic_flag are now completely
decoupled from the atomic operations implementation (the backends). It is now
more consistent across all platforms and not duplicated everywhere.
- atomic_flag and fences are now available through separate headers
atomic_flag.hpp and fences.hpp. These headers are still included by atomic.hpp
for backward compatibility.
- The definition of configuration macros BOOST_ATOMIC_XXX_LOCK_FREE is now
available through a separate header capabilities.hpp. Users are able to
include it and test these macros before including the rest of Boost.Atomic.
Most macros are now defined more correctly based on the sizes of the types
(i.e. BOOST_ATOMIC_LONG_LOCK_FREE now actually depends on the size of long
and is equivalent to BOOST_ATOMIC_INT32_LOCK_FREE or
BOOST_ATOMIC_INT64_LOCK_FREE).
- Added support for 128-bit atomic ops with MSVC. The support is always
enabled for x86_64. There are some ancient AMD chips that don't support
cmpxchg16b, users can define BOOST_ATOMIC_NO_CMPXCHG16B if they want to target
those.
- Added support for BOOST_ATOMIC_FLAG_INIT, although it is optional and
atomic_flag is still zero initialized by default. I did not find a way to
implement it and keep compatibility with C++03.
- Improved ARM backend with gcc (tested for compilation). Now it supports 64-
bit atomics. All operations are written in ll/sc manner instead of a CAS loop.
- Added a separate ARM backend for MSVC (tested for compilation). Some support
for ARM was added to develop earlier but the new implementation is better
optimized (it uses appropriate intinsics wrt memory ordering).
- Added support for 64-bit atomic ops for SPARCv9 with gcc (completely
untested).
- Added support for DEC Alpha backend with gcc (completely untested). It is
based on the dead and incomplete code that was present in Boost.Atomic before.
- Removed support for IA64 on Windows. Not sure if it is needed, but it can be
added relatively easily.
There are many more changes. Lots of code duplication removed, bugs with
arithmetic overflow fixed and things I don't remember.
This new version is the foundation for further improvements that are needed
for Boost.Sync. In particular, I plan to add new operations (btr/bts, inplace
logical operations) and maybe free atomic functions.
You can see in the above list that much of the code is not properly tested,
and I have little-to-none experience with some of the platforms. To my
knowledge, there are no non-x86 regular testers. Therefore I'd appreciate if
people reviewed and tried the code. Please, report any feedback, good or bad.
Thank you.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk