OpenMP for chess programming
Moderators: hgm, Rebel, chrisw
-
- Posts: 396
- Joined: Sat May 05, 2012 2:48 pm
- Full name: Oliver Roese
OpenMP for chess programming
I have a simple question: Would you consider to use OpenMP for chess programming? If i look a certain chess programs, this would be possible. Can you back up your opinion with facts? Thanks in advance.
-
- Posts: 12541
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: OpenMP for chess programming
It's been tried (C engine with various options, then Java):
https://github.com/hennimohammed/parallel_chess_engine
https://github.com/sennosays/DeepBlueOpenMP
https://github.com/hennimohammed/parallel_chess_engine
https://github.com/sennosays/DeepBlueOpenMP
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
- Posts: 4185
- Joined: Tue Mar 14, 2006 11:34 am
- Location: Ethiopia
Re: OpenMP for chess programming
OpenMP has task based parallelism since 4.0 i think, so why not. It is easier if you use easy algorithms such asBeyondCritics wrote: ↑Fri Jun 28, 2019 1:12 am I have a simple question: Would you consider to use OpenMP for chess programming? If i look a certain chess programs, this would be possible. Can you back up your opinion with facts? Thanks in advance.
MCTS, LazySMP, ABDADA etc but should be possible with YBW too. All you need from the library is to be able
to fork threads and provide some primitive synchronizations.
Sample code from my MCTS chess and Hex engine that uses OpenMP on the CPU and CUDA on the GPU.
Code: Select all
//
// locks
//
#ifdef GPU
# define LOCK int
# define l_create(x) ((x) = 0)
# define l_trylock(x) (atomicExch(&(x),1))
# define l_lock(x) while(l_trylock(x) != 0);
# define l_unlock(x) (atomicExch(&(x),0))
# define l_add(x,v) (atomicAdd(&x,v))
# define l_sub(x,v) (atomicSub(&x,v))
#else
# define LOCK omp_lock_t
# define l_create(x) omp_init_lock(&x)
# define l_trylock(x) omp_test_lock(&x)
# define l_lock(x) omp_set_lock(&x)
# define l_unlock(x) omp_unset_lock(&x)
template <class T>
inline void l_add(T x,T v) {
#pragma omp atomic
x+=v;
}
template <class T>
inline void l_sub(T x,T v) {
#pragma omp atomic
x-=v;
}
#endif