Author |
Topic: threads and related stufff (Read 1402 times) |
|
doublep
Forum Guru
Badger author
Gender:
Posts: 82
|
|
threads and related stufff
« on: Dec 6th, 2005, 4:53pm » |
Quote Modify
|
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 .
|
|
IP Logged |
|
|
|
jdb
Forum Guru
Arimaa player #214
Gender:
Posts: 682
|
|
Re: threads and related stufff
« Reply #1 on: Dec 6th, 2005, 6:25pm » |
Quote Modify
|
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. |
|
|
|
IP Logged |
|
|
|
doublep
Forum Guru
Badger author
Gender:
Posts: 82
|
|
Re: threads and related stufff
« Reply #2 on: Dec 7th, 2005, 5:01am » |
Quote Modify
|
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.)
|
|
IP Logged |
|
|
|
99of9
Forum Guru
Gnobby's creator (player #314)
Gender:
Posts: 1413
|
|
Re: threads and related stufff
« Reply #3 on: Dec 7th, 2005, 5:10am » |
Quote Modify
|
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.
|
|
IP Logged |
|
|
|
doublep
Forum Guru
Badger author
Gender:
Posts: 82
|
|
Re: threads and related stufff
« Reply #4 on: Dec 7th, 2005, 3:02pm » |
Quote Modify
|
on Dec 6th, 2005, 4:53pm, 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.
|
|
IP Logged |
|
|
|
doublep
Forum Guru
Badger author
Gender:
Posts: 82
|
|
Re: threads and related stufff
« Reply #5 on: Dec 9th, 2005, 4:22pm » |
Quote Modify
|
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'.
|
|
IP Logged |
|
|
|
|