Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: So many good ones!

Author: Dann Corbit

Date: 11:31:37 12/13/05

Go up one level in this thread


On December 13, 2005 at 14:02:29, Dann Corbit wrote:

>On December 13, 2005 at 10:05:18, Tord Romstad wrote:
>
>>On December 12, 2005 at 20:36:33, Dann Corbit wrote:
>>
>>>I predict he will have a very hard time writing a SMP version because of all the
>>>global variables.
>>
>>I really don't understand why people think this is such a big problem.
>>Rewriting
>>the whole program isn't a very difficult or time-consuming task (it's just a bit
>>boring).  It's not at all like starting all over.  You can keep most of the old
>>algorithms and data structures, and also copy big chunks of the code.
>>
>>I think doing a complete rewrite from time to time is a good thing to do anyway.
>>It helps you to correct old, unfortunate design decisions, and give you a good
>>opportunity to try new techniques.  It is also a great way to find obscure old
>>bugs.
>
>I have done several conversions of large systems from single theading to SMP
>(not chess programs, but I guess it is quite similar).
>
>The answer is not just to critical section things because it becomes a huge
>bottleneck (you will get approximately single CPU speed).  Sometimes, you will
>have to rethink the fundamental algorithms themselves.
>
>Debugging SMP programs can be particularly onerous.  (The main product we sell
>where I work is a SMP system).
>
>You could do a wobbly port to SMP and get something with a rough speedup of 1.2
>or so with very little work.  But to do it right is a major task, I think.
>
>I think GCP's approach was very intelligent.  While spawning processes is more
>expensive than spawning threads, it is much easier to have independent programs
>that use shared memory for important shared objects like the hash table.
>
>The clever thing about that approach is that you can still have statics and
>globals in your program and it does not matter as long as they are not in shared
>memory.  This simplifies greatly the effort of gating access to shared
>resources.
>
>I guess that you cannot do an SMP port faster than the way that GCP did it.
>
>However, if you want to go to "the next level" by using threads which are a less
>expensive resource than a process, there is a lot more work to do.

The other smart way to do it is the way that Daniel Shawul did it.

Scorpio is a small program (like -- for instance -- Glaurung).  While a program
is very small, it is not nearly so difficult to do a port to SMP.  I don't know
how many hours it took him to put SMP into Scorpio, but I expect it was not too
many.  The most remarkable thing is that he did not have a multiple CPU machine
to do the port.  (I would not have even attempted it under that circumstance)

Fruit is much larger than Scorpio or Glaurung (about twice as large).  For a
really large program (say, 500K or more of source code) I would probably do a
complete rewrite rather than to try to repair it, unless it was built from the
start with the idea of someday going to SMP.  You can do a big program, of
course, but it's going to take a long time.

The same things that make a program easy to port to SMP are actually good
programming ideas anyway (as few globals and statics as possible -- those few
really necessary globals as static const whenever possible, etc.)  ALso,
organizing the data in structs or classes according to need is helpful.

I guess that Thinker will not be hard to port to SMP because it is very small.
Also, from what small bits of code that I have seen, the author is also a very
good programmer.



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.