TBB atomic support for float/doubles

TBB atomic support for float/doubles

According to the documnetation, TBB atomic is supported for integer/enum types/pointer types.
I took at the test driver test_atomic.cpp and one of the test cases calls the function called
TestAtomicFloat. Does this imply that fetch_and_store, etc. will work correctly for
floats/doubles?

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Yes, the documentation is just not up to date. Be careful when evaluating success for CAS (+0 and -0 are different for CAS but not for the equality operator, so using just the equality operator to compare the comparand with the return value instead of excluding -0 or using memcmp at least for the dubious cases you might erroneously evaluate a failed invocation as successful).

This is mentioned in tbb40_20120408oss/include/tbb/atomic.h: "Works for any type T that has the same size as an integral type, has a trivial constructor/destructor,
and can be copied/compared by memcpy/memcmp."

(2012-05-21) Elaborated.

Leave a Comment

Please sign in to add a comment. Not a member? Join today