C++11 atomic locks

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Which is better for chess programs?

C++11 atomic locks
3
60%
PThreads mutex locks
2
40%
 
Total votes: 5

ZirconiumX
Posts: 1334
Joined: Sun Jul 17, 2011 11:14 am

C++11 atomic locks

Post by ZirconiumX »

There are several locks used for chess programs, spinlocks, mutexes etc.

So, as I am currently implementing SMP into FruitFly, would it be worth the hassle of converting the Toga mutexes to C++11 atomic locks?

Matthew:out
Some believe in the almighty dollar.

I believe in the almighty printf statement.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: C++11 atomic locks

Post by mcostalba »

ZirconiumX wrote:There are several locks used for chess programs, spinlocks, mutexes etc.

So, as I am currently implementing SMP into FruitFly, would it be worth the hassle of converting the Toga mutexes to C++11 atomic locks?

Matthew:out
Considering that you failed to understand that C++1 atomic library does not cover lock functionality I'd strongly suggest to stay with what you know better (or at least you think to know).
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: C++11 atomic locks

Post by bob »

ZirconiumX wrote:There are several locks used for chess programs, spinlocks, mutexes etc.

So, as I am currently implementing SMP into FruitFly, would it be worth the hassle of converting the Toga mutexes to C++11 atomic locks?

Matthew:out
First question is, what is your goal? Max performance on a dedicated machine? Use nothing but spinlocks. If you are going to compete for CPU resources with other running processes (non-chess processes) then a traditional mutex that spins and then blocks is the way to go... I only care about the former myself, not the latter.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: C++11 atomic locks

Post by Daniel Shawul »

OpenMP locks have an interesting property. They act as spinlocks for a certain time and then as a mutex in which the thread is put to sleep. They will probably act fully as spin locks when it is our turn so no loss there. http://www.thinkingparallel.com/2006/09 ... roduction/
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Camel is a horse designed by a committee

Post by Daniel Shawul »

That was the conclusion of a recent Dr Dobb's article after discussing concurrency in C11. http://drdobbs.com/cpp/232800444?pgno=1