comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Does Ada tasking profit from multi-core cpus?
Date: Tue, 6 Mar 2007 09:44:14 +0100
Date: 2007-03-06T09:44:14+01:00	[thread overview]
Message-ID: <uzi0vxrkly8j.ayer9t8wf46c$.dlg@40tude.net> (raw)
In-Reply-To: yfydnaboycG2YHHYnZ2dnUVZ_tadnZ2d@comcast.com

On Mon, 05 Mar 2007 23:33:31 -0600, tmoran@acm.org wrote:

>> 1. Whether protected object's functions are indeed executed concurrently
>> when come from the tasks running on different cores?
> 
>    A quick test with a single protected object containing a single,
> long-duration, function appears to have just one call of the function
> active at a time, even if the function is called from two different tasks.
> 
>   global_flag : integer := 0;
> 
>   protected body pt is
>     function f(id : integer) return natural is
>       change_count : natural := 0;
>     begin
>       global_flag := id;
>       for i in 1 .. 10_000_000 loop
>         if global_flag /= id then
>           change_count := change_count;
>           global_flag := id;
>         end if;
>       end loop;
>       return change_count;
>     end f;
>   end pt;
> 
> One task calls pt.f(id=>1) and the other calls pt.f(id=>2).  They both get
> a result of zero back from their function call.  This was with Gnat 3.15p
> Windows 2000 on a dual core Pentium.  If I change it from a single
> protected object to two instances of a protected type, then the function
> calls are overlapped and return non-zero results.

Not very promising, sigh. Probably GNAT uses a critical section for all
protected actions, so the result.

>> 3. Can a task switch cores? If yes, what is the overhead of switching?

>   By "switch cores" do you mean that the particular hardware stack
> pointers swap which stack they are pointing to?  I think this is an OS
> question

That depends on the mapping of Ada's schedulable units to the OS ones. But
it is Ada question too. Because the processor affinity of a task is not
specified, the scheduler should be able to switch it from processor to
processor to achieve an optimal performance. Otherwise multi-core would
make no sense for Ada. AFAIK, Windows indeed switches thread's processors,
so GNAT 3.15p should follow it as well (provided, tasks are mapped on
threads and no thread affinity mask is set). Interesting would be to know
the penalty of such switching.

> and, for Windows, I don't know how one asks "which core am
> I currently running on" - or indeed if that questions makes any sense.

I suppose it should be NtGetCurrentProcessorNumber under Windows.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2007-03-06  8:44 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-29 11:57 Does Ada tasking profit from multi-core cpus? Gerd
2007-01-29 12:04 ` Georg Bauhaus
2007-01-30 13:55   ` Gerd
2007-02-09 10:18     ` karl
2007-02-09 11:03       ` Stefan Lucks
2007-02-09 11:35         ` Ludovic Brenta
2007-03-04 17:54 `   jpluto
2007-03-05 10:08   ` Ludovic Brenta
2007-03-05 13:12     ` Dmitry A. Kazakov
2007-03-06  5:33       ` tmoran
2007-03-06  8:44         ` Dmitry A. Kazakov [this message]
2007-03-07  7:52           ` tmoran
2007-03-07  9:31           ` tmoran
2007-03-06  9:40         ` Colin Paul Gloster
2007-03-06 12:47           ` Jeffrey Creem
2007-03-06 14:44           ` Georg Bauhaus
2007-03-06 16:53         ` Dr. Adrian Wrigley
2007-03-06 18:58           ` tmoran
2007-03-07 10:11             ` Colin Paul Gloster
2007-03-07 18:47               ` tmoran
2007-03-06 18:51         ` Jeffrey R. Carter
2007-03-16 14:29           ` Arguments for single-mutex-exclusion on protected types (Was: Does Ada tasking profit from multi-core cpus?) Jacob Sparre Andersen
2007-03-17  5:26             ` Jeffrey R. Carter
2007-03-17 17:22               ` Robert A Duff
2007-03-17 17:52                 ` Jeffrey R. Carter
2007-03-17 23:06                 ` Randy Brukardt
2007-03-18 17:57                   ` Robert A Duff
2007-03-19 21:49                     ` Randy Brukardt
2007-03-20  0:55                       ` Jeffrey R. Carter
2007-03-20  1:36                         ` Randy Brukardt
2007-03-20 16:32                           ` Jeffrey R. Carter
2007-03-20 17:51                             ` Randy Brukardt
2007-03-21  0:10                               ` Jeffrey R. Carter
2007-03-26 23:38                               ` Robert A Duff
2007-03-26 23:24                           ` Robert A Duff
2007-03-17 10:25             ` Dmitry A. Kazakov
2007-03-18 17:15               ` Arguments for single-mutex-exclusion on protected types Jacob Sparre Andersen
2007-03-18 18:50                 ` Dmitry A. Kazakov
2007-03-20 12:38                 ` Florian Weimer
2007-03-07  3:58       ` Does Ada tasking profit from multi-core cpus? Steve
2007-03-07  8:39         ` Dmitry A. Kazakov
2007-03-08  5:21           ` Randy Brukardt
2007-03-08 10:15             ` Dmitry A. Kazakov
2007-03-08 21:18               ` accuracy (was: Does Ada tasking profit from multi-core cpus?) Björn Persson
2007-03-09  8:33                 ` accuracy Dmitry A. Kazakov
2007-03-10  1:39                   ` accuracy Randy Brukardt
2007-03-10  9:11                     ` accuracy Dmitry A. Kazakov
2007-03-11  3:03                       ` accuracy Randy Brukardt
2007-03-11  5:21                         ` accuracy tmoran
2007-03-11  8:52                         ` accuracy Dmitry A. Kazakov
2007-03-11 13:57                           ` accuracy Pascal Obry
2007-03-11 14:16                             ` accuracy Dmitry A. Kazakov
2007-03-11 14:37                               ` accuracy Pascal Obry
2007-03-11 15:50                                 ` accuracy Dmitry A. Kazakov
2007-03-11 17:38                                   ` accuracy Pascal Obry
2007-03-11 18:48                                     ` accuracy Dmitry A. Kazakov
2007-03-12 20:20                           ` accuracy Randy Brukardt
2007-03-13  9:33                             ` accuracy Dmitry A. Kazakov
2007-03-10 14:53                     ` accuracy Stephen Leake
2007-03-10 18:36                       ` accuracy Cesar Rabak
2007-03-05 18:46   ` Does Ada tasking profit from multi-core cpus? Jeffrey R. Carter
replies disabled

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