TBB atomic support for float/doubles

TBB atomic support for float/doubles

imagem de drselee

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
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de Raf Schietekat

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.

Faça login para deixar um comentário.