Arimaa Forum (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi)
Arimaa >> Bot Development >> threads and related stufff
(Message started by: doublep on Dec 6th, 2005, 4:53pm)

Title: threads and related stufff
Post by doublep on Dec 6th, 2005, 4:53pm
According to Jdb, the machine the bots sit on probably has two CPUs.  Doesn't really look so, since unthreaded Aami-ra seems to consume 100% CPU, but I got interested in making in threaded anyway...

So here are many small questions I got in process:

  • Is it really multi-CPU and will the Computer Championship be held on multi-CPU machines?
  • Are bots allowed to use all the CPUs?
  • Does anyone know why libgthread won't compile statically (lots of `undefined reference to ...' errors)? (It compiles normally just fine.)
  • Is it possible to install libgthread on gold.arimaa.com instead? (It is a very common library, there is certainly a package for whatever distro is used on that box.)

A little more generally: are there currently bots that are able to utilise multiple CPUs? I threaded Aami-ra in two evenings, though I'm not sure all errors are terminated. My machine has only one CPU, so I cannot stress the implementation seriously, though even with one CPU and two threads I managed to find many problems :).

Title: Re: threads and related stufff
Post by jdb on Dec 6th, 2005, 6:25pm
This is a quote from an email omar sent me:


Quote:
Yes, you can use both CPU's. Im not sure how you do
that from the program though. I think that linux
uses the CPUs to run multiple independent processes.
So even if your program does not try to use both
CPUs it will still benifit since it will be swapped
out less because other processes can be run on the
second CPU.

Title: Re: threads and related stufff
Post by doublep on Dec 7th, 2005, 5:01am
As far as I know, threads and processes are both created with a call to fork() at the lowest level. So I think Linux can dispatch either two threads of one  process or two different processes on two CPUs.

I don't have any ways to check right now, though, since I cannot run threaded Aami-ra on gold.arimaa.com due to a missing library... (That's assuming gold.arimaa.com has two CPUs in the first place.)

Title: Re: threads and related stufff
Post by 99of9 on Dec 7th, 2005, 5:10am
I think it does have 2 processors.  When I run gnobby the load only goes up to 0.50.  Top still reads 100%, but that's because it's using 100% of one processor.

Title: Re: threads and related stufff
Post by doublep on Dec 7th, 2005, 3:02pm

on 12/06/05 at 16:53:29, doublep wrote:
Is it possible to install libgthread on gold.arimaa.com instead? (It is a very common library, there is certainly a package for whatever distro is used on that box.)


Ah, I've just looked closer and libgthread is installed there. Just not the development parts. Will check if it works with a home-compiled bot once the current game against GnoBot finishes.

Title: Re: threads and related stufff
Post by doublep on Dec 9th, 2005, 4:22pm
OK, now it finally runs faster than before when using two CPUs. I'm still disappointed, since the speedup is merely about 5%, I sort of hoped for more... Anyway, the bot is now configured to run in two threads and use 256 MB of memory for the cache.

In case anyone wonders: gold.arimaa.com is indeed a two-CPU machine as can be seen in the file `/proc/cpuinfo'.



Arimaa Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.