atomic<float> only support fetch_and_store but not support fetch_and_add?

atomic only support fetch_and_store but not support fetch_and_add?

The following piece of code runs well:

atomic a;
a = 0.1;
cout< a.fetch_and_store(0.2);
cout<
The following piece does not compile(error: struct tbb::atomic has no member named fetch_and_add):
atomic a;
a = 0.1;
cout< a.fetch_and_store(0.2);
cout< a.fetch_and_add(0.3);
cout<

Anyone know whether current tbb support float/double for fetch_and_add or not?

Thanks!

2 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de Raf Schietekat

That would be nice and orthogonal, but neither TBB nor C++11 provide arithmetic operations for floating-point types, so they require you to cobble those together yourself (note that with TBB you'll have to be extra careful when evaluating the result of compare_and_swap, as plus zero and minus zero are different bit patterns but compare as equal for the equality operator).

Connectez-vous pour laisser un commentaire.