Search found 2332 matches

by Michael Sherwin
Mon Apr 13, 2020 4:42 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Compiler Optimization Question
Replies: 27
Views: 2030

Re: Compiler Optimization Question

And yet another question. Since I'm using simple arrays instead instead of an array of structures the move stack is: frsq[t][10000] tosq[t][10000] trgt[t][10000] type[t][10000] scor[t][10000] And this is done: if (score != -INFINITY && (score > alpha || depth > 0)) { frsq[t][eye] = fs; // had to us...
by Michael Sherwin
Mon Apr 13, 2020 4:20 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Compiler Optimization Question
Replies: 27
Views: 2030

Re: Compiler Optimization Question

And yet another question. Since I'm using simple arrays instead instead of an array of structures the move stack is: frsq[t][10000] tosq[t][10000] trgt[t][10000] type[t][10000] scor[t][10000] And this is done: if (score != -INFINITY && (score > alpha || depth > 0)) { frsq[t][eye] = fs; // had to use...
by Michael Sherwin
Mon Apr 13, 2020 4:03 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Compiler Optimization Question
Replies: 27
Views: 2030

Re: Compiler Optimization Question

A really large function has many local variables and accesses many global variables. Will modern compilers be able to optimize register usage effectively or is it better to break up the large function into a few subfunctions with fewer variables so the compiler can better optimize register usage? R...
by Michael Sherwin
Mon Apr 13, 2020 3:12 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Compiler Optimization Question
Replies: 27
Views: 2030

Re: Compiler Optimization Question

Here's the simple answer from a compiler guy. Small functions are just fine. If they SHOULD be inlined, the compiler will do it during the compilation process. If it won't help, it won't. Not inlining can improve cache efficiency if the function is executed infrequently. Better to have the natural ...
by Michael Sherwin
Mon Apr 13, 2020 1:43 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Compiler Optimization Question
Replies: 27
Views: 2030

Re: Compiler Optimization Question

Here is the function I'm concerned about. It is almost complete, just have to add the castling code. It generates all moves one at a time and calls Qsearch(). Only legal moves are stored in the move list. The variable "t" is the thread index and it uses arrays rather than a structure. void GenAllMov...
by Michael Sherwin
Mon Apr 13, 2020 1:38 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Compiler Optimization Question
Replies: 27
Views: 2030

Re: Compiler Optimization Question

regardless of any optimising issues, its just good practice to brake things into small, easy readable/debug functions. One function = one job. if it spans more than a screen, break it up into small logical parts. they are easier to prove correct and then your mind can abstract them away. And maybe ...
by Michael Sherwin
Mon Apr 13, 2020 1:28 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Compiler Optimization Question
Replies: 27
Views: 2030

Re: Compiler Optimization Question

Thanks guys. I found this online. WRITE CLEAR, SIMPLE CODE Some of the very things that make code clear and readable to humans also make it clear and readable to compilers. Complicated expressions are harder to optimize and can cause the compiler to "fallback" to a less intense mode of optimization....
by Michael Sherwin
Mon Apr 13, 2020 1:09 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Compiler Optimization Question
Replies: 27
Views: 2030

Re: Compiler Optimization Question

I would not worry about trying to out-think the compiler. Modern compilers can even eliminate tail recursion. The first rule of optimization is "Don't do it." The second rule, for experts only, is "Don't do it yet." Of course it is kind of a gag, but the point is never to waste time optimizing unti...
by Michael Sherwin
Sun Apr 12, 2020 11:11 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Compiler Optimization Question
Replies: 27
Views: 2030

Compiler Optimization Question

A really large function has many local variables and accesses many global variables. Will modern compilers be able to optimize register usage effectively or is it better to break up the large function into a few subfunctions with fewer variables so the compiler can better optimize register usage?
by Michael Sherwin
Sun Apr 12, 2020 9:27 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: A Neat Trick
Replies: 13
Views: 1209

Re: A Neat Trick

@hgm, Benchmarks of shift instructions comparing Intel vs AMD reveals that even ten year old AMD chips run circles around even the latest Intel chips. So my question about your solution is wouldn't it be better to use a shift instruction rather than a multiply. sq = ts ^ ((u64)(epbitboard == one<<ts...