Subject: Re: Modified Proposal for Context Sensitive Function Calls
From: Joao.Geada@synopsys.com
Date: Wed Nov 20 2002 - 11:59:50 PST
Kevin.Cameron@nsc.com said:
> The converse mechanism could be used to link module (class) specific
> routines to module instances, i.e. if a module declares an XF (rather
> than in $root) it would be bound to a C/C++ function pointer at
> elaboration by calling a user-supplied (PLI) routine e.g.:
Kevin,
You are assuming that "context" always means "virtual function". I am
not sure that there is such a strong (ie unbreakable) coupling. It seems just
as likely that all I'd want to store in the context is some "per instance" data
and have the same one function manipulate this data: ie the context selects
the data to work on and not what function does the work.
I personally think this is and also more generic, since if you have
context data you can clearly implement context specific functions (as per John's
proposal), but if all you have is context specific functions, implementing the
simpler cases can become cumbersome.
Kevin.Cameron@nsc.com said:
> The approaches are not mutually exclusive, it's mostly a tradeoff
> between ease-of-use and (post elaboration) execution speed.
As to the optimization issue: the entire difference between the approaches
appears to be:
a) if context is required, it has to be explicitly requested with John's
proposal. (1 function call per invocation)
b) dereferencing the context to get a function pointer
Whether it happens internally or externally, this still must occur, so
this is the same in both cases.
Note that in neither case am I accounting for the one off setup costs.
So, yes, John's proposal may be *slightly* more expensive. However, John's
proposal needs no new APIs, is simple to explain and is generally applicable
to a wide domain of uses. My personal approach is to avoid premature optimizations
(ie follow Amdahl's Law :-)) if "genericity" or simplicity would be sacrificed.
Given free choice I'd defer choosing what to optimize until I could see what
really mattered, and that is clearly going to be dependent on the real world
usage of these interfaces.
BTW: I just saw more traffic on the server on this subject. I will hold further
comments until I see your more detailed proposal.
Joao
==============================================================================
Joao Geada, PhD Principal Engineer Verif Tech Group
Synopsys, Inc TEL: (508) 263-8083
154 Crane Meadow Road, Suite 300, FAX: (508) 263-8069
Marlboro, MA 01752, USA
==============================================================================
This archive was generated by hypermail 2b28 : Wed Nov 20 2002 - 12:00:40 PST