Subject: RE: [sv-cc] DPI context - setting/preserving&resetting a scope
From: Warmke, Doug (doug_warmke@mentorg.com)
Date: Mon Mar 17 2003 - 13:38:20 PST
Francoise,
I don't think we should design a complex system for corner cases.
Instead, we should try to create the simplest possible rules and
definitions that will work well in all cases (including corners).
I think we can do that - please follow through my logic below,
and then correct anything you think I may have overlooked.
The rule should be:
- If an exported SV function is called from C, the context should
be well-determined in advance of the call.
If user code does not conform to this rule, then all bets are off.
Hopefully all implementations will detect the situation and give
a good error message.
There are two ways for context to be well determined:
1) A context external function is up the call chain.
This introduces a "default scope". Specifically, the
entry-point ILFC (inter-language function call) is the
only place where the default scope is set.
2) User has explicitly set scope with svSetScope()
This rule, along with the two caveats about when context is
well determined, should be enough to handle all main use cases
and corner cases with good efficiency.
In your specific example, caveat 1) would apply, thus making
it a legal (and non-corner case, from the system's point of view)
calling sequence. If the user wants to do something as complex
as what you suggest, we should put the burden of ensuring correct
scope upon them, not upon our system.
There are other scenarios as well, such as one context external
function calling another context external function, and then
calling an SV function. Without the above rule and caveats,
that would not be very predictable for users either. (And it's
not even the subject of this mail thread, i.e. calling SV from
non-context functions).
Thanks and regards,
Doug
> -----Original Message-----
> From: Francoise Martinolle [mailto:fm@cadence.com]
> Sent: Monday, March 17, 2003 6:13 AM
> To: Joao.Geada@synopsys.com; Warmke, Doug; 'Andrzej
> Litwiniuk'; Stickley, John
> Cc: sv-cc@eda.org
> Subject: RE: [sv-cc] DPI context -
> setting/preserving&resetting a scope
>
>
> I disagree with the fact that non context functions could
> call SV functions. I completely agree with Michael and with
> Andrzej who states that it will
> complicate the
> implementation.
> Getting the context, setting the context and switching
> context will not
> only be complex but will create some performance hit.
>
> If you remember our initial goal for having the "context" qualifier:
> 1. it was to indicate the SV compiler that this external C
> function was
> context
> sensitive and therefore a scope handle needed to be
> constructed and
> passed to that C
> function. This allowed to optimize non context
> functions and to have
> better performance
> for the execution of these.
> 2. The context qualifier indicated that some VPI or PLI
> calls will be
> guaranteed to work
> properly if called inside the context extern C function.
>
> Are we going to allowing a corner case of :
> SV -> context C function -> non context C function -> SV
> to work and break the initial rules just for convenience of a
> corner case ?
>
> I don't think we should do that.
> Moreover, the user who writes the non context C function
> either has to
> assume that it will
> be called from a context function or use the set/get scope
> rules. The first assumption causes his code to be dependent
> on who called that
> function,
> the second assumption using the set/get scope rules is
> against our initial
> requirement
> to have non context function NOT depending on a context.
>
> Francoise
> '
>
>
> Now we are allowing to have extern non context C functions
> called from some
> previous
> context C function to assume that they can have the default
> context and
> event set their
> context.
>
>
> Adding context functions At 06:50 PM 3/14/2003 -0500, Joao
> Geada wrote:
> >As long as the user ensures that there is a valid context prior to
> >making the call, I have no objection.
> >
> >All that the standard says is that only context calls have context
> >automatically
> >initialized to something sensible.
> >
> >Joao
> >=============================================================
> =================
> >Joao Geada, PhD Principal Engineer
> Verif Tech Group
> >Synopsys, Inc
> TEL: (508) 263-8083
> >344 Simarano Drive, Suite 300,
> FAX: (508) 263-8069
> >Marlboro, MA 01752, USA
> >=============================================================
> ==========
> >=======
> >
> >
> >-----Original Message-----
> >From: owner-sv-cc@eda.org [mailto:owner-sv-cc@eda.org]On Behalf Of
> >Warmke, Doug
> >Sent: Friday, March 14, 2003 5:56 PM
> >To: 'Andrzej Litwiniuk'; Stickley, John
> >Cc: sv-cc@eda.org
> >Subject: RE: [sv-cc] DPI context -
> setting/preserving&resetting a scope
> >
> >
> >Andrzej, John,
> >
> >I think it's OK to have the behavior specified by Andrzej
> >for non-context external functions. It's even OK if the user enters
> >their C code by some other means, say a PLI callback. All Andrzej is
> >saying is that you can't count on the default scope being set if you
> >didn't follow the rules.
> >
> >More important to me is that we don't make it illegal to call an SV
> >export function from non-context C code. That would have lots of
> >consequences on users, and no benefits for implementors. (Drat,
> >Andrzej! :) ) Here, John's example of explicitly setting scope and
> >then making the call is reasonable and should be quite useful in
> >practice.
> >
> >Thanks and regards,
> >Doug
> >
> >
> > > -----Original Message-----
> > > From: Andrzej Litwiniuk [mailto:Andrzej.Litwiniuk@synopsys.com]
> > > Sent: Friday, March 14, 2003 2:44 PM
> > > To: Stickley, John
> > > Cc: sv-cc@server.eda.org
> > > Subject: Re: [sv-cc] DPI context - setting/preserving&resetting a
> > > scope
> > >
> > >
> > > > johnS:
> > > > Most likely it will be safer however, if the current
> > > context is set to
> > > > NULL by the infrastructure whenever a non-context function
> > > is called.
> > >
> > > John,
> > >
> > > this is exactly what I want to avoid!
> > > I don't want =any= overhead on simple calls of non-context
> > > functions. The implementation that I had in mind would instrument
> > > only the calls of context functions.
> > >
> > > My take on this is that an overhead is acceptable if it buys you
> > > something important and useful. I don't think that the
> rule "NULL if
> > > called directly from non-context" is worth the price.
> > >
> > > It shouldn't happen that we carelessly and without due diligence
> > > specify a functionality of a function, and then all
> simulators will
> > > have to bear an overhead in order to be compliant with a standard.
> > > I may be wrong whether a specific rule is needed or not, or
> > > whether the price
> > > overweights the benefits, but it's my job to figure out the
> > > consequences from
> > > compiler's perspective. As you see, I'm a little biased :-)
> > >
> > > Regards,
> > > Andrzej
> > >
> > >
>
This archive was generated by hypermail 2b28 : Mon Mar 17 2003 - 13:39:18 PST