Discussion:
[Gmat-developers] GMAT Function Design Issues
Steven Hughes
2007-10-25 14:10:51 UTC
Permalink
Darrel, ( I think we should start using SourceForge lists for this
discussion so that's why you're receiving this through SF)

We've talked about using pass-by-value (PBV) vs. pass-by-ref (PBR) in
functions calls. PBV requires making a copy of the object which is a
performance hit. PBR is faster, but will result in changes to the
inputs even if that is not what the user wants. How about a middle
ground, if an object is contained in both the input arg list, and the
output arg list, it uses PBR, and if it does not appear in the output
list it uses PBV? Do you think this would add a lot of complexity to
the design? It could allow a significant performance improvement in
some cases.

Steve

Here's the syntax we're assuming for GMAT function calls (Identical to
MATLAB's syntax).

[Out1, Out2, Out3, ...., OutN] = FuncName(In1, In2, In3, ....., InM)
Wendy Shoan
2007-10-25 14:18:26 UTC
Permalink
Is that how MATLAB does it? (I think Linda said something about that
at the meeting the other day).

So, then, the function would have to keep track of which things were
in the output and input lists, and check for something being in both
before it decides whether to copy a thing or not. Is that what you
are saying? Of course, it would know that on creation, so maybe that
wouldn't be such a big deal. But Darrel would know that better, of
course.

Wendy
Post by Steven Hughes
Darrel, ( I think we should start using SourceForge lists for this
discussion so that's why you're receiving this through SF)
We've talked about using pass-by-value (PBV) vs. pass-by-ref (PBR) in
functions calls. PBV requires making a copy of the object which is a
performance hit. PBR is faster, but will result in changes to the
inputs even if that is not what the user wants. How about a middle
ground, if an object is contained in both the input arg list, and the
output arg list, it uses PBR, and if it does not appear in the output
list it uses PBV? Do you think this would add a lot of complexity to
the design? It could allow a significant performance improvement in
some cases.
Steve
Here's the syntax we're assuming for GMAT function calls (Identical to
MATLAB's syntax).
[Out1, Out2, Out3, ...., OutN] = FuncName(In1, In2, In3, ....., InM)
----------------------------------------------------------------------
---
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a
browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Gmat-developers mailing list
https://lists.sourceforge.net/lists/listinfo/gmat-developers
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Until he extends his circle of compassion to
all living things, man himself will not find
peace. - Albert Schweitzer
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Views expressed are my own and
do not necessarily reflect those
of my employer, or anyone else.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Wendy C. Shoan
NASA/GSFC/MAB/583
Greenbelt MD 20771
301.286.6263
***@nasa.gov
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Darrel J. Conway
2007-10-25 16:14:07 UTC
Permalink
Post by Wendy Shoan
Is that how MATLAB does it? (I think Linda said something about that
at the meeting the other day).
So, then, the function would have to keep track of which things were
in the output and input lists, and check for something being in both
before it decides whether to copy a thing or not. Is that what you
are saying? Of course, it would know that on creation, so maybe that
wouldn't be such a big deal.
Actually, the Function doesn't necessarily know this on creation, since
functions can be called from multiple places in the script. It can know
this if we use multiple instances of the function (one per CallFunction
command), but I wasn't thinking we'd do it that way, since that would
mean cloning the Functions from the Function resource. In other words,
Edwin might make a test script something like this:

Create GmatFunction myFunc;
...
sat1 = myFunc(sat1);
sat2 = myFunc(sat1);

In the first case, we can read and write to the input object, but not in
the second case.

Darrel J. Conway
2007-10-25 16:07:13 UTC
Permalink
Post by Steven Hughes
Darrel, ( I think we should start using SourceForge lists for this
discussion so that's why you're receiving this through SF)
We probably should post the requirements there as well, then, so folks
know what we are talking about.
Post by Steven Hughes
We've talked about using pass-by-value (PBV) vs. pass-by-ref (PBR) in
functions calls. PBV requires making a copy of the object which is a
performance hit. PBR is faster, but will result in changes to the
inputs even if that is not what the user wants.
Actually (guess I'm being picky today), we are using pass by reference
in all of the cases we discussed, since the copy is made inside of the
function, not prior to the call. But that part is still subject to the
current design work (see below).
Post by Steven Hughes
How about a middle
ground, if an object is contained in both the input arg list, and the
output arg list, it uses PBR, and if it does not appear in the output
list it uses PBV? Do you think this would add a lot of complexity to
the design?
Yes. I'd prefer to wait and see if there is a performance hit before
adding this layer of complexity. I suspect (it's not designed yet, so
it is just a suspicion) that since (1) the CallFunction command knows
ahead of time what parameters are used and (2) it already will need some
logic to manage the function call, we may be able to add some buffering
there that makes the clones at initialization and just calls the
assignment operator at execution. Then we can pass the object that can
be changed into the function directly (by reference), and move the logic
for setting the copies correctly to the calling Command, rather than in
the function.

Initially we could always pass in copies, and add this type of logical
construct on the second pass through the design and implementation if we
need it.
Post by Steven Hughes
It could allow a significant performance improvement in
some cases.
Maybe. Let's see if it's an issue before adding the complexity.
Post by Steven Hughes
Steve
Here's the syntax we're assuming for GMAT function calls (Identical to
MATLAB's syntax).
[Out1, Out2, Out3, ...., OutN] = FuncName(In1, In2, In3, ....., InM)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Gmat-developers mailing list
https://lists.sourceforge.net/lists/listinfo/gmat-developers
Loading...