Author: Uri Blass
Date: 12:39:26 07/17/03
Go up one level in this thread
On July 17, 2003 at 12:50:32, Gerd Isenberg wrote: >On July 17, 2003 at 07:43:19, Uri Blass wrote: > >>On July 17, 2003 at 06:43:30, Gerd Isenberg wrote: >> >>>On July 17, 2003 at 06:28:44, Uri Blass wrote: >>> >>>>On July 17, 2003 at 06:14:04, Richard Pijl wrote: >>>> >>>>>On July 17, 2003 at 05:58:39, Gerd Isenberg wrote: >>>>> >>>>>>On July 17, 2003 at 05:06:16, Uri Blass wrote: >>>>>> >>>>>>>Note that the name of the arrays that I have is different but I replaced the >>>>>>>names to make it easy to understand the problem. >>>>>>> >>>>>>>I have an array A[64][8] >>>>>>> >>>>>>>I want to replace it by 8 arrays A0[64],A1[64],...A7[64] when A[i][j]=Aj[i] >>>>>> >>>>>>Hi Uri, >>>>>> >>>>>>I would suggest A[8][64] for your purpose. >>>>>> >>>>>>Then you still may index the arrays with A[j][sq] and you get your suggested >>>>>>single 64 element arrays: A0[sq], A1[sq] with A[0][sq], A[1][sq] ... >>>>>> >>>>>>Gerd >>>>> >>>>>Of course! Let the compiler do the optimizing. I guess most compilers will >>>>>recognize this? >>>>>Richard. >>>> >>>>Your suggestion seems to be better. >>>> >>>>The point is that I have significant names instead of A0,A1,.... and I do not >>>>want to lose the significant names. >>>> >>>>I only wrote here A0, A1 to explain the point because otherwise I cannot use a >>>>simple formula based on the name of the array. >>>> >>>>I already finished the replace of the array and I now only need to add your >>>>definitions and save calculations that are done twice for both arrays. >>>> >>>>The arrays practically are not the same but every time that I call A[i][j] it is >>>>the same as Ai[j], so it is a waste of time to calculate A[i][j] >>> >>>Uri, if "i" is a constant, there is no waste of time! >>>A1[j] or A[1][j] produce the same assembler output. >> >>I understand it but this was not the point of this post(I was wrong to think >>that A[0][j] is faster than A0[j] from the computer point of view in the >>original post but not in this post and there were reasons to add the new arrays >>that are not speed). >> >>I will try to explain it more clearly. >> >>At this point I only checked for no bugs after replacing A[64][8] by A[8][64] >> >>Ai[j] is a different array than A[i][j] and has a different place in the memory >>of the computer. >> >>Ai[j] simply gives me more information than A[i][j] so I do not need the old >>A[i][j] >> >>I have >>1)A[i][j]=Ai[j] if condition X happens. >>2)A[i][j] is used only if condition X happens. >>3)A[i][j]<>Ai[j] is possible if X does not happen. >> >>In the past I used only A[i][j] only when X happened >>I decide to build Ai[j] and now I use it also when x does not happen but A[i][j] >>is still used only when X happens. >> >>It means that I can replace A[i][j] by Ai[j] and save time of calculation of >>A[i][j]. >> >>The problem was how to calculate Ai[j] when I have only i and j and i is not a >>constant. >>In the last version I still use simply A[i][j] >>I did not like to use switch and I also do not like to use A[i][j] instead of >>Ai[j] because the names of Ai are significant names(I have 8 names that are >>different english words when using 8 different words in the array A[8][64] is >>not practical). >> >>The solution that Richard prposed seems to be good because I can keep the >>original 8*64 array only in the definitions and use the significant names. >> >>I can also save time relative to the situation today because I do not need to >>calculate the old array. >> >>I did not post the full inforamtion in the original post because I thought that >>the fact that A[i][j] gives more information than Ai[j] is irrelvant because >>there was a different reason of speed to support Ai[j]. >> >>More information may also support speed and not only knowledge but I thought >>that if I give too complex post then I may confuse people. >> >>Uri > >sorry Uri, a bit short in time (on Work) ... >I'm not sure i understand your problems... > >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%. If it is easier for the computer to calculate A3[i] and not things like A[3][i] then it could be a good explanation for it but I understood from your post that it is not the case so I do not know why it is slower. Maybe it is a statistical error of the compiler because I read that dieter also found that by changing something that is not relevant the code can be 5% slower or 5% faster. Maybe the compiler does not like to work on data that is changed often and in the old structure it was easier to use A[i][j] because A[i][j] was not changed often. 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.