q3map2 doesn't seem to detect correct number of CPUs


(WolfWings) #1

I have a dual-processor Athlon-MP machine, running Linux 2.6.x under a Gentoo distribution.

q3map2 always claims it’s running 4 threads, so apparently the ‘auto thread setting’ code seems to be slightly off on Linux.


(nUllSkillZ) #2

As far as I know the No. of threads and the No. of processors have nothing to do with each other.
You compare apples and pears.


(Q.) #3

My Red Flag Linux, only one proccessor equipped, has the same problem. :frowning:


(MadJack) #4

@ nullskillz, If q3map2 is working Ok with: 2 CPUs = 4 thread, I would expect 2 threads on single CPU yet I get only 1 thread… Maybe I’m getting it the wrong way?


(obsidian) #5

threads != processors

I have a single P4 3.0 GHz HT CPU that runs as threads 2.
If your processor were the engine of a car, the threads would be like the number of cylinders in your engine.


(MadJack) #6

So are you saying that if the CPU is not HT or the AMD equivalent it’ll only run at 1 thread?

So what is dictating how many threads will run (except forcing threads on the command line, if that would work) ?


(WolfWings) #7

NullSkillz: You’re wrong. Threads run on logical processors. Specifically, only one thread can run on any one logical processor at a time, and a seperate thread has to handle switching between other threads, etc.

HyperThreading-equipped Pentium processors have two logical processors per one physical processor, ergo why I’m speaking of logical processors in this case.

But for optimum efficiency and speed, you should have the same number of threads as logical processors. Ergo, in my case (2xAthlon-MP 1600) 2 threads. That q3map2 seems to want to run 4 threads all the time is puzzling me, and seems like incorrect behaviour.


(ydnar) #8

There is no automatic CPU detection on Linux. You must use the -threads N arg to set threads explicitly.


(randomlag) #9

nUllSkillZ is right. The number of threads and the number of processors are 2 different things.

One processor can run any number of threads.

A program is always at least 1 thread or task (in terms of logical units that do “work”).

A coder can add code in his program to start more than 1 thread that runs asynchronously with the main thread and all other threads.

For example, in my code I can start these threads: read keyboard input, another that reads a serial port, another that looks for mouse input, another one for IP stuff. These all run simultaneously in the sense that logically there are all active at the same time.

On a single cpu, only 1 thread runs at a time (or 1 program at a time, even if you have multiple ones running). Task dispatching switches between the different threads (or programs) and it appears to a user as if they are all running at the same time.

On a 2 cpu processor, it can run 2 threads at the same time (similarly you can run 2 programs at the same time) “same time” is not exactly true since any shared resources (kb, vid, etc) are always serialized.

On a 4 cpu it’s 4 and so on.

However, any one program can have any number of threads, regardless of the number of cpus - IOW it has nothing to do with logical or physical processors. The idea is that if you have multiple cpus and the OS is coded to take advantage, then it will run threads in different cpus, thus you get faster results.

Hyperthreading is not really the same as 2 actual processors. It’s just a teeny tiny bit faster. Sometimes even slower :slight_smile:

Don’t know if that’s real clear since this is a coder thingy :slight_smile:


(Q.) #10

I did 2 experiments on my secondary PC(0.4GHz Celeron Processor 128 MByte of SDRAM).
Windows2000 and Red Flag Linux are installed on it.
Maybe there is no unnecessary active process on both of them.
q3map2.exe(threads 1) and q3map2.x86(threads 4) compiled museum and q3dm1sample at each.
Elapsed time was almost the same.
So I don’t care anymore. :banana:


(ydnar) #11

Using -threads on a single-CPU machine will only have a negative effect on compile performance, if at all.