Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about changing my data structure

Author: Uri Blass

Date: 14:03:07 07/17/03

Go up one level in this thread


On July 17, 2003 at 16:42:01, Gerd Isenberg wrote:

>>>
>>>You have the old int array with swapped indicies [8][64] now.
>>
>>Yes
>>
>>>You need a second one with some conditional stuff.
>>
>>I think that the there may be a misunderstanding about the conditional stuff.
>>I am not sure about what I need and I will describe what I have.
>>
>>I have now the old int array with swapped indices A[i][j]
>>and I have also 8 different arrays Ai[j] that are in different place in the
>>memory.
>>
>>I use both arrays.
>>
>>Every time that I use A[i][j] I have A[i][j]=Ai[j] but
>>there are cases when I use Ai[j] when Ai[j]!=A[i][j] because I do not care to
>>update A[i][j]
>>
>>A[i][j] was planned to give information only when some condition about square i
>>exists so it is used only in these cases.
>>
>>Ai[j] is planned to give information also when the condition about square i does
>>not hold and in these cases I may have Ai[j]!=A[i][j]
>>
>>I tried to tell the compiler that Ai[j] and A[i][j] mean the same thing by
>>definition and for some reason the result is that the code is slower.
>>
>>I  tried it by replacing
>>int A0[64];
>>int A1[64];
>>...
>>int A7[64];
>>
>>by
>>int *const A0=A[0]
>>int *const A1=A[1]
>>...
>>int *const A7=A[7]
>>
>>Of course I have significant names instead of A A0,...A7
>>
>>Unfortunately I found that the result is slower by almost 5%.
>
>
>I see, so your intention is that A1..A7 are only constant alias names for
>A[0]...A[7]. An additional reference costs some time. To address of A[0] is
>known during compile time - shorter and faster code. The access via A0 is only
>resolvable at runtime - more code and an additional memory access:
>
>i = A[0][j];
>
>mov eax, [_A + 4*ebx] ; j in ebx
>
>but
>
>i = A0[j]; // is may be something like this
>mov esi, [_A0] ; get the pointer of _A in esi
>mov eax, [esi + 4*ebx]
>
>and that's only for readability?
>What about MACROS?
>
>#define A0 A[0]
>
>and maybe later
>#undef A0
>or even in other context
>#define A0 A[1]
>
>Regards,
>Gerd

Thanks

I understand now that i=A0[j] is faster than i=A[0][j](I got the impression that
it should be the same speed based on previous post)

I do not understand exactly what you suggest.

In most cases I already use A0[j] or A3[j] and the only cases when I do not do
it is when I want to use A[i][j] and i is not a constant number and in these
cases I use the old array.

What do you suggest to do in that case?

I can do switch about i but I do not like that solution.
I also do not see how #define A0 A[1] can help me in these cases.

Uri



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.