Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Semantics o...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 15 of 15 Topic 5622 of 5827
Post > Topic >>

Re: Semantics of statement reordering relevant to Ada.Real_Time

by Robert A Duff <bobduff@[EMAIL PROTECTED] > Mar 30, 2008 at 05:28 PM

Eric Hughes <eric.eh9@[EMAIL PROTECTED]
> writes:

> On Mar 30, 12:59 pm, Robert A Duff <bobd...@[EMAIL PROTECTED]
>
> wrote:
>> The only thing that's guaranteed is I/O behavior, so you have to do
some
>> I/O.
>
> Only?  You can also count on task termination, no?

Insofar as it affects I/O, yes.  And I suppose you can count on
termination of the program as a whole (that is, if all tasks
terminate, then so should the program).

>...Example code
> below.
>
> Eric
>
>
> with Ada.Real_Time ;
> with Ada.Text_IO ;
> procedure Foo
> is
>    Val : Natural := 0 ;

Better make that modular, or this conversion gets confused by the
overflow issue.  Oh, never mind, I see you reduced the counts,
and (if I can do that in my head correctly) it won't overflow. ;-)

>    Start_T, End_T : Ada.Real_Time.Time ;
>    use Ada.Real_Time ;
> begin
>    declare
>       task Start_Timer ;
>       task body Start_Timer is begin
>          Start_T := Ada.Real_Time.Clock ;
>       end ;
>    begin
>       null ;
>    end ;
>
>    declare
>       task Compute ;
>       task body Compute is begin
>          for K in 1 .. 10 loop
>             for I in 1 .. 10_000 loop
>                Val := Val + I * I ;
>             end loop;
>          end loop;
>       end ;
>    begin
>       null ;
>    end ;
>
>    declare
>       task End_Timer ;
>       task body End_Timer is begin
>          End_T := Ada.Real_Time.Clock ;
>       end ;
>    begin
>       null ;
>    end ;
>
>    Ada.Text_IO.Put_Line( Natural'Image( Val ) ) ;
>    Ada.Text_IO.Put_Line( Duration'Image( To_Duration( End_T -
> Start_T ) ) ) ;
>
> end Foo ;

I don't see any language rule that would prevent moving the calculation
of Val before or after the Start_Timer or End_Timer tasks, since they
don't use that value.  Or in parallel with them.  Or at compile time.

I'm not claiming that real compilers do these transformations
in practise, nor implying that they "should".

I suppose you could reasonably argue that the Clock in Start_Timer must
happen before the one in End_Timer (since a calculation based on those
values is printed out).  So I guess it would be wrong to print
a negative time span.

Meaningful benchmarking is hard!  ;-)

- Bob
 




 15 Posts in Topic:
Ada.Real_Time behavior with GNAT
kongra <kongra@[EMAIL   2008-03-29 06:51:58 
Re: Ada.Real_Time behavior with GNAT
george.priv@[EMAIL PROTEC  2008-03-29 09:50:56 
Re: Ada.Real_Time behavior with GNAT
Georg Bauhaus <rm.tsoh  2008-03-29 18:29:48 
Re: Ada.Real_Time behavior with GNAT
Simon Wright <simon.j.  2008-03-29 18:11:29 
Re: Ada.Real_Time behavior with GNAT
"Dmitry A. Kazakov&q  2008-03-29 19:25:05 
Re: Ada.Real_Time behavior with GNAT
george.priv@[EMAIL PROTEC  2008-03-29 12:06:38 
Re: Ada.Real_Time behavior with GNAT
Konrad Grzanek <kongra  2008-03-29 12:15:41 
Re: Ada.Real_Time behavior with GNAT
Konrad Grzanek <kongra  2008-03-29 12:46:16 
Re: Ada.Real_Time behavior with GNAT
Georg Bauhaus <rm.tsoh  2008-03-30 01:14:29 
Re: Ada.Real_Time behavior with GNAT
george.priv@[EMAIL PROTEC  2008-03-29 14:21:45 
Re: Ada.Real_Time behavior with GNAT
Konrad Grzanek <kongra  2008-03-29 14:49:16 
Semantics of statement reordering relevant to Ada.Real_Time
Eric Hughes <eric.eh9@  2008-03-30 10:12:25 
Re: Semantics of statement reordering relevant to Ada.Real_Time
Robert A Duff <bobduff  2008-03-30 14:59:21 
Re: Semantics of statement reordering relevant to Ada.Real_Time
Eric Hughes <eric.eh9@  2008-03-30 14:12:20 
Re: Semantics of statement reordering relevant to Ada.Real_Time
Robert A Duff <bobduff  2008-03-30 17:28:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 0:07:32 CDT 2008.