Re: gthread: how many cores do I have?

> I'd my program (a threaded image processing system based on gthread)
> to be able to find out how many cores the host machine has.

First a terminological nit: Don't confuse "cores" with "processors".
There were machines with a high degree of symmetrical multiprocessing
(i.e. lots of processors) a *long* time before multi-core chips
appeared on the market.

> int g_thread_get_cores( void );

Well, firstly the function name should use "processors" and not
"cores". But I think that in general such a function would be too
simplistic, and just look at things from the perspective of the
current low end of the market.

Whether it's worth to try to design a suitable GLib abstraction for
such things, I don't know. In serious parallelism,  you need more
advanced API anyway, you need to consider things like NUMA, asymmetric
multiprocessing etc. (Note, I am certainly not an expert here.) You
will almost certainly need some platform-dependent code, surely? Or
use other libraries that already do it for you?


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