comp.lang.ada
 help / color / mirror / Atom feed
From: Brad Moore <brad.moore@shaw.ca>
Subject: Re: Maximum Number Of Tasks?
Date: Thu, 05 Dec 2013 20:26:50 -0700
Date: 2013-12-05T20:26:50-07:00	[thread overview]
Message-ID: <Gtbou.409818$jg4.204285@fx05.iad> (raw)
In-Reply-To: <52822462$0$6549$9b4e6d93@newsspool4.arcor-online.net>

On 12/11/2013 5:52 AM, Georg Bauhaus wrote:
> On 12.11.13 10:53, FritzVonBraun wrote:
>> I was wondering about the maximum number of tasks in Ada but I couldnt find
>> any info. The question is, is a task in Ada technically similar to a thread in
>> Windows under the hood? Threads are restricted by the stack size that each
>> thread has reserved, so in practice the maximum number of threads is about 2000.
>>
>> The reason I'm asking is that I wonder if Ada provides a more comfortable
>> solution to the thread pool problem. In C++ for example I create a number of
>> threads roughly equal to the number of processor cores and then have a number
>> of Jobs that are distributed over the threads and which implement a time
>> sharing system by returning control to the thread which then assigns time to
>> another Job.
>
> If you have jobs that do not require intermittent communication among
> them, then in particular, I'd be sure to have a look at the Paraffin
> library. http://paraffin.sourceforge.net/
>

Paraffin has had several flavours of task pools implemented for some 
time now. You can do as you suggest and have a task pool that has the 
same number of tasks as there are cores in your system, and distribute 
work across these tasks.

There are three main "flavours" of task pool.

1) No pool at all, just allocate workers on the fly and distribute work 
across the set of workers
2) A task pool that can be dynamically (or statically) created that 
contains a bounded (or unbounded) number of workers that can be applied 
to any number of parallelism opportunities. These task pools allow a 
worker to migrate to cores, if the OS supports migration (eg. Windows 
and Linux)
3) A Ravenscar compliant task pool that is more suitable for real time, 
where the workers must be statically allocated to cores, and cannot migrate.

To see a demo of these task pools, you could try running the
test_parallel_loops or test_parallel_recursion executables that are 
included with the source for Paraffin.

To see the Ravenscar version of these task pools, you would need to
execute the test_ravenscar_parallel_loops and 
test_ravenscar_parallel_recursion examples.

Rather surprisingly, there is not a significant difference between these 
three task pool models. In general using a task pool will give
a slight edge in performance over creating workers on the fly, but the 
difference is barely noticeable in these examples.

Also, intermittent communication between the workers is OK, as long as
the communication has the necessary safeguards.

For instance you could have several workers performing some lengthy 
calculation, that briefly writes some value to an IO port. If the
IO port was wrapped in a protected object, it may make sense to allow
the multiple workers to access this protected object to perform I/O.

Brad.


  reply	other threads:[~2013-12-06  3:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12  9:53 Maximum Number Of Tasks? FritzVonBraun
2013-11-12 10:59 ` Jacob Sparre Andersen
2013-11-12 12:52 ` Georg Bauhaus
2013-12-06  3:26   ` Brad Moore [this message]
2013-11-12 13:21 ` mockturtle
2013-11-12 20:02   ` Ludovic Brenta
2013-11-12 20:04     ` Ludovic Brenta
2013-11-12 15:54 ` Jeffrey Carter
2013-11-12 16:17   ` Dmitry A. Kazakov
2013-11-14 13:00 ` Marius Amado-Alves
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox