[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: computer-go: Sharing Go modules




It's true that modern compiles can usually avoid the multiply. For example if
you are iterating over a row in a loop, the compiler will only multiply once,
to get an index, then just add to the index as the loop advances. But it won't
avoid all of the multiplies.

When I use one dimensional arrays, I never multiply in the go code. The only multiply
is in the GUI, when the user selects a point. All parameters and references inside
the go engine use a point index rather than an (x,y) pair.

David

At 10:47 PM 5/16/2001 -0700, you wrote:
A one dimensional array doesn't avoid the multiply. You are doing the
multiply yourself to convert x,y to index. I think modern day optimized
compiler is more efficient than calculating the address yourself.

Man Lung Li

> -----Original Message-----
> From: David Fotland [mailto:fotland@xxxxxxxxxxxxxxxxx]
> Sent: Wednesday, May 16, 2001 7:20 PM
> To: computer-go@xxxxxxxxxxxxxxxxx
> Subject: RE: computer-go: Sharing Go modules
>
>
> At 03:37 PM 5/16/2001 -0700, you wrote:
> >Could you explain why a 2D array can cause a performance problem?
>
>
> Take a look at the assembler output with a debugger.  To get
> the memory address for a 2d 19x19 array, there is a multiply
> by 19.  A one dimensional array avoids the multiply.  If the
> computer has index addressing mode, a single instruction can
> get the array value.
>
> David
>
>
> >Thanks.
> >
> >-- Mousheng Xu
> >
> >-----Original Message-----
> >From: Anders Kierulf [mailto:anders@xxxxxxxxxxxxxxxxx]
> >Sent: Wednesday, May 16, 2001 8:33 AM
> >To: computer-go@xxxxxxxxxxxxxxxxx
> >Subject: RE: computer-go: Sharing Go modules
> >
> >
> > > The coordinate coding method that I use is X,Y converts
> to X+Y*20.
> > > The arrays are all 421 long where all te points at 0,Y and X,0
> > > contain special values to make it easy to detect the edge of the
> > > board. This is a
> >convenient
> > > coding since it's still fairly easy to see which coordinates they
> >represent
> > > (for example: 63 is 3,3 and 356 is 16,17). However I do
> realise that
> > > every Go programmmer has their own idea of how this
> should be done
> > > and that there's little chance that I can convince
> everyone in the
> > > world to use
> >this
> > > scheme (that would be nice though <grin>) instead of
> using separate
> > > X and
> >Y
> > > coordinates.
> >
> >This is a good scheme. It's the same scheme SmartGo uses, so
> at least
> >two Go programs have independently reached exactly the same
> solution.
> >Please go ahead and convince the rest of the world. :-)
> >
> >Anders Kierulf
> >www.smartgo.com
> >
> >
> >The information contained in this email is intended for the personal
> >and confidential use of the addressee only. It may also be
> privileged
> >information. If you are not the intended recipient then you
> are hereby
> >notified that you have received this document in error and that any
> >review, distribution or copying of this document is strictly
> >prohibited. If you have received  this communication in
> error, please
> >notify Celltech Group immediately on:
> >
> >+44 (0)1753 534655, or email 'is@xxxxxxxxxxxxxxxxx'
> >
> >Celltech Group plc
> >216 Bath Road, Slough, SL1 4EN, Berkshire, UK
> >
> >Registered Office as above. Registered in England No. 2159282
>
> David Fotland
>
>
David Fotland