Re: gthread: how many cores do I have?



On 15 March 2010 17:46, Martin Nordholts <enselic gmail com> wrote:
> On 03/15/2010 12:14 PM, jcupitt gmail com wrote:
>> 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. This would
>> let me make my threadpools default to a sensible size.
>
> That would maybe work OK if only one program ran at a time, but I don't
> think that is a fair assumption. If I were to attack this problem I would
> look into porting Apple's libdispatch to Linux and go on from there. In
> short, the libdispatch framework is an OS level mechanism that takes care of
> distributing cores across programs.

Yes, libdispatch is a nice mechanism. If anyone's not come across it,
it provides dynamically resizeable threadpools with a central manager
which adjusts pools globally to keep the system from bogging down (and
a few other bells and whistles, or that's my understanding anyway).

But it seems to me that we have a more immediate need: gthread has a
threadpools, but no way to pick a reasonable size for a pool.

I guess existing cross-platform applications and libraries which use
threadpools must all have some duplicated code to pick a default pool
size*. If we centralise this, we could perhaps add some standard
mechanisms, like a --g-threadpool-size=N argument, or a
G_THREADPOOL_SIZE environment variable.

John

* though I'm too lazy to look


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