ildyria / Arimaa

3 stars 1 forks source link

std::atomic<bool> vs std::atomic_flag vs #pragma omp atomic #8

Closed ildyria closed 9 years ago

ildyria commented 9 years ago

Just discovered the existence of std::atomic (C++11). This has specializations such as : std::atomic _std::atomicflag the sizeof of theses 2 is the same as bool, meaning no changes in term of space optimizations.

This raise some interesting improvements at some points of the code compared to #pragma omp critical and will requires comparisons to #pragma omp atomic

Some lectures on it (from the cppCon) https://www.youtube.com/watch?v=c1gO9aB9nbs https://www.youtube.com/watch?v=CmxkPChOcvw

Not a priority, but maybe a hint for improvements.

ildyria commented 9 years ago

std::atomic (C++11) can't be used : there is no copy constructor. atomic (const atomic&) = delete; atomic_flag( const atomic_flag& ) = delete; And unfortunately we need them to the pruning of the trees.

source : http://en.cppreference.com/w/cpp/atomic/atomic/atomic http://en.cppreference.com/w/cpp/atomic/atomic_flag/atomic_flag