Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: what is the meaning of RESTRICT in crafty?

Author: Anthony Cozzie

Date: 11:51:38 12/17/03

Go up one level in this thread


On December 17, 2003 at 14:40:22, Uri Blass wrote:

>On December 17, 2003 at 14:25:02, Anthony Cozzie wrote:
>
>>On December 17, 2003 at 14:22:22, Uri Blass wrote:
>>
>>>I find that a lot of functions in Craftyget as a parameter TREE* RESTRICT
>>>
>>>What is the meaning of the RESTRICT word?
>>>
>>>I looked for that word in Crafty and except cases when Crafty get that parameter
>>>in functions
>>>I could only find in chess.h the following lines that I also do not understand.
>>>
>>>#if defined (_MSC_VER) && (_MSC_VER >= 1300) && (!defined(_M_IX86) || (_MSC_VER
>>>>= 1400))
>>>#  define RESTRICT __restrict
>>>#else
>>>#  define RESTRICT
>>>#endif
>>>
>>>
>>>Uri
>>
>>restrict means an unaliased pointer. e.g.
>>
>>void vectoradd(double *a, double *b, double *c, int len)
>>{
>>  for(int i = 0; i < len; i++)
>>    c[i] = b[i] + a[i];
>>}
>>
>>the compiler doesn't know that a != b != c unless you use __restrict or specify
>>it as a command line option.
>>
>>anthony
>
>what is exactly the advantage of using Restrict?
>Does it cause Crafty to be slightly faster or does it prevent errors of
>overwriting(in your example changing a[i] when you change c[i] because the
>compiler may believe that a=c inspite of the fact that you used different
>varaibles)?
>
>I see that crafty use a lot of pointers without restrict(for example
>HashProbe is using int * beta and int * threat)
>
>Why does it use Restrict only for the big struct of TREE.
>
>Uri

suppose we make a slight change:

void vectoradd(double *a, double *b, double *c, int len)
{
  for(int i = 0; i < len; i++)
    c[i+1] = b[i] + a[i];
}

now the compiler cannot unroll the loop unless it knows that there is no
aliasing.

anthony



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.