comp.lang.ada
 help / color / mirror / Atom feed
* Ada Tagged Type-Operation assign?
@ 2009-05-15 13:57 patrick.gunia
  2009-05-15 14:30 ` Ludovic Brenta
  0 siblings, 1 reply; 7+ messages in thread
From: patrick.gunia @ 2009-05-15 13:57 UTC (permalink / raw)


Hi all,

I got a question concerning Ada-Tagged-Type implementation. I´m
currently comparing two versions of a program written in Ada, one uses
tagged types, the other one doesn´t. I use VTune to evaluate the
runtime-performance of both versions and found that the call graph
display of vtunes shows one function in the tagged-type version which
gets called massively whereas there aren´t any calls to these
functions in my "non-tagged-type-version". This operation isn´t
declared by me, thus it has to be provided by the system. The
operation is named "assign". The funny thing about this is, that this
operations gets only called for tagged types which aren´t inherited,
all my other tagged types which are organized in class hierarchies don
´t show this behaviour. It might be important that these types are
aubclasses from Ada.Finalization.Controlled, maybe that´s a reason why
I don´t find the "assign"-operation.
So, now here are my questions:
Is the operation "assign" automatically provided for tagged types?
If so, is there any possibility to control this method or do I have to
accept it?

The reason for my second question simply is the fact, that the self
time of the function is not relevant (0,00ms), though when it gets
called 3 billion times, it starts to be a relevant factor for
performance differences...

Thanks for your help,
Patrick



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ada Tagged Type-Operation assign?
  2009-05-15 13:57 Ada Tagged Type-Operation assign? patrick.gunia
@ 2009-05-15 14:30 ` Ludovic Brenta
  2009-05-15 14:53   ` patrick.gunia
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Brenta @ 2009-05-15 14:30 UTC (permalink / raw)


Patrick Gunia wrote on comp.lang.ada:
> I got a question concerning Ada-Tagged-Type implementation. I´m
> currently comparing two versions of a program written in Ada, one uses
> tagged types, the other one doesn´t. I use VTune to evaluate the
> runtime-performance of both versions and found that the call graph
> display of vtunes shows one function in the tagged-type version which
> gets called massively whereas there aren´t any calls to these
> functions in my "non-tagged-type-version". This operation isn´t
> declared by me, thus it has to be provided by the system. The
> operation is named "assign". The funny thing about this is, that this
> operations gets only called for tagged types which aren´t inherited,
> all my other tagged types which are organized in class hierarchies don
> ´t show this behaviour. It might be important that these types are
> aubclasses from Ada.Finalization.Controlled, maybe that´s a reason why
> I don´t find the "assign"-operation.
> So, now here are my questions:
> Is the operation "assign" automatically provided for tagged types?
> If so, is there any possibility to control this method or do I have to
> accept it?
>
> The reason for my second question simply is the fact, that the self
> time of the function is not relevant (0,00ms), though when it gets
> called 3 billion times, it starts to be a relevant factor for
> performance differences...

I could imagine that the compiler-generated assign procedure
implements the run-time checks for assignment. These run-time checks
presumably exist only when the source or the target of the assignment
is of a class-wide type. Is that the case?

For controlled types, there should be calls to Adjust and Finalize in
addition to (not instead of) assign, so my reasoning may be off-mark.
It would help if you could produce a short example.

--
Ludovic Brenta.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ada Tagged Type-Operation assign?
  2009-05-15 14:30 ` Ludovic Brenta
@ 2009-05-15 14:53   ` patrick.gunia
  2009-05-15 18:16     ` Robert A Duff
  0 siblings, 1 reply; 7+ messages in thread
From: patrick.gunia @ 2009-05-15 14:53 UTC (permalink / raw)



> I could imagine that the compiler-generated assign procedure
> implements the run-time checks for assignment. These run-time checks
> presumably exist only when the source or the target of the assignment
> is of a class-wide type. Is that the case?

No, neither source nor target are class-wide types.

> For controlled types, there should be calls to Adjust and Finalize in
> addition to (not instead of) assign, so my reasoning may be off-mark.
> It would help if you could produce a short example.

What´s irritating me is the fact, that all my controlled types which
are of course also tagged-types, don´t call this operation. Regarding
an example I have the problem, that I don´t really know, where the
operation is called, because VTune only tells me, that there is a big
number of calls to this function, but it can´t tell me, where these
calls take place. Of course I assume that the operation gets called,
when I assign values to instances of my tagged-types, but I don´t
think, that it would help, to show an example for such an assignment.
Or am I getting your question for an example wrong?



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ada Tagged Type-Operation assign?
  2009-05-15 14:53   ` patrick.gunia
@ 2009-05-15 18:16     ` Robert A Duff
  2009-05-16 13:32       ` patrick.gunia
  0 siblings, 1 reply; 7+ messages in thread
From: Robert A Duff @ 2009-05-15 18:16 UTC (permalink / raw)


"patrick.gunia@googlemail.com" <patrick.gunia@googlemail.com> writes:

> What�s irritating me is the fact, that all my controlled types which
> are of course also tagged-types, don�t call this operation. Regarding
> an example I have the problem, that I don�t really know, where the
> operation is called, because VTune only tells me, that there is a big
> number of calls to this function, but it can�t tell me, where these
> calls take place. Of course I assume that the operation gets called,
> when I assign values to instances of my tagged-types, but I don�t
> think, that it would help, to show an example for such an assignment.
> Or am I getting your question for an example wrong?

Assignment is quite expensive for controlled types (or types containing
controlled types, etc).  Try out to the -gnatD and/or -gnatG switches
to see what's going on under the covers.

Assignment of tagged types is not particularly expensive, if not
controlled.

- Bob



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ada Tagged Type-Operation assign?
  2009-05-15 18:16     ` Robert A Duff
@ 2009-05-16 13:32       ` patrick.gunia
  2009-05-16 16:35         ` patrick.gunia
  2009-05-16 16:37         ` patrick.gunia
  0 siblings, 2 replies; 7+ messages in thread
From: patrick.gunia @ 2009-05-16 13:32 UTC (permalink / raw)


> Assignment is quite expensive for controlled types (or types containing
> controlled types, etc).  Try out to the -gnatD and/or -gnatG switches
> to see what's going on under the covers.

This is, what I also expected, because of calling Adjust, Finalize and
Initialize on instances of these types. VTune tells me the number of
times these methods are called for my controlled types, this is
acceptable, simply because of the fact, that it´s a behaviour I
expectext. Though I still don´t have a clue why this "assign"
operation gets called. I´ve been searching quite a long time to get a
hint, but still haven´t been successfull. I´ll try using the compiler
switches, currently I´ve changed the two tagged types where I found
this method to "normal" private types to see, wether it´s got
something to do with the treatment of tagged types. As soon as I can
tell any results, I´ll post them. If this fails, I´ll go for -gnatG
and -gnatD.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ada Tagged Type-Operation assign?
  2009-05-16 13:32       ` patrick.gunia
@ 2009-05-16 16:35         ` patrick.gunia
  2009-05-16 16:37         ` patrick.gunia
  1 sibling, 0 replies; 7+ messages in thread
From: patrick.gunia @ 2009-05-16 16:35 UTC (permalink / raw)


So now here´s my results after performing another test run using
VTune. Without declaring the two types as tagged-types, the operation
"assign" isn´t listed any more in my VTune-results, and thus doesn´t
get called and probably ain´t created any more. This yields to an
performance-increase of ca. 10% for the overall performance of my
application. This is quite nice, though I don´t get, why this happens.
Does anyone have an explanation for this?



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ada Tagged Type-Operation assign?
  2009-05-16 13:32       ` patrick.gunia
  2009-05-16 16:35         ` patrick.gunia
@ 2009-05-16 16:37         ` patrick.gunia
  1 sibling, 0 replies; 7+ messages in thread
From: patrick.gunia @ 2009-05-16 16:37 UTC (permalink / raw)


As it might depend on my compiler switches, here´s the switches I use
(using gcc).
-g -gnato -fstack-check -gnatf (for Compiler)
-g -gstabs -Wl,-pie -pie (for Linker => the last options are required
by VTune as it needs relocation data for call graph analysis.)



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-05-16 16:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-15 13:57 Ada Tagged Type-Operation assign? patrick.gunia
2009-05-15 14:30 ` Ludovic Brenta
2009-05-15 14:53   ` patrick.gunia
2009-05-15 18:16     ` Robert A Duff
2009-05-16 13:32       ` patrick.gunia
2009-05-16 16:35         ` patrick.gunia
2009-05-16 16:37         ` patrick.gunia

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