unefficient parts of glaurung
Posted: 29 Aug 2006, 10:02
I wonder how much speed improvement it is possible to get by improving speed of glaurung without doing big changes in the structure and only with making the code simpler.
I believe that there are unefficient parts in that program.
I give only one example and there are more unefficient parts that I do not mention in this post.
The pos structure include both the side to move and the side of the opponent to move(side and xside)
It seems to me waste of time to update xside in lines like
pos->side ^= 1; pos->xside ^= 1;
I find that pos->xside is not used often in glaurung
for example I find the following string 8 times in glaurung
side = pos->side, xside = side^1;
It means that glaurung even does not use pos->xside
I am not sure if it is better to have seperate variable for xside but
it is possible to say that without it the code may be bigger even if it is faster but in case of pos->xside if I do not miss something deleting it and replacing every pos->xside in the few cases that it needed by pos->side^1 is going to do glaurung both simpler and faster.
I have not a good compiler and I do not plan to compile glaurung to check it but it may be interesting to know how much speed improvement people can get from this simple changes
in the code:
1)replacing pos->xside by pos->side^1 in the following lines:
eval.cpp(362): e_result += PSQ(KingOfColour(pos->xside), xksq);
eval.cpp(845): int c = PieceOfColourAndType(pos->xside, CAPTURE(m));
extend.cpp(12): if(PIECE(m)==PAWN && PawnRank[pos->xside][TO(m)] == RANK_7)
search.cpp(110): if(PIECE(m) == PAWN && pawn_is_passed(pos, TO(m), pos->xside)) return false;
search.cpp(141): !global_see(pos, pos->xside, ss[ply].eval - beta - margin))
2)deleting xside from the pos field
3)deleting pos->xside in the other cases that it is used when glaurung change sides.
Uri
I believe that there are unefficient parts in that program.
I give only one example and there are more unefficient parts that I do not mention in this post.
The pos structure include both the side to move and the side of the opponent to move(side and xside)
It seems to me waste of time to update xside in lines like
pos->side ^= 1; pos->xside ^= 1;
I find that pos->xside is not used often in glaurung
for example I find the following string 8 times in glaurung
side = pos->side, xside = side^1;
It means that glaurung even does not use pos->xside
I am not sure if it is better to have seperate variable for xside but
it is possible to say that without it the code may be bigger even if it is faster but in case of pos->xside if I do not miss something deleting it and replacing every pos->xside in the few cases that it needed by pos->side^1 is going to do glaurung both simpler and faster.
I have not a good compiler and I do not plan to compile glaurung to check it but it may be interesting to know how much speed improvement people can get from this simple changes
in the code:
1)replacing pos->xside by pos->side^1 in the following lines:
eval.cpp(362): e_result += PSQ(KingOfColour(pos->xside), xksq);
eval.cpp(845): int c = PieceOfColourAndType(pos->xside, CAPTURE(m));
extend.cpp(12): if(PIECE(m)==PAWN && PawnRank[pos->xside][TO(m)] == RANK_7)
search.cpp(110): if(PIECE(m) == PAWN && pawn_is_passed(pos, TO(m), pos->xside)) return false;
search.cpp(141): !global_see(pos, pos->xside, ss[ply].eval - beta - margin))
2)deleting xside from the pos field
3)deleting pos->xside in the other cases that it is used when glaurung change sides.
Uri