Hi All,

Many posemath functions (like pmCartCartDot, for example) pass compound
data types like PmCartesion and PmPose by value. Is there a specific reason
for this design choice?

 It seems like the "right" way is to pass pure inputs by reference using
constant pointers:
Instead of this:

pmCartCartDot(PmCartesian v1, PmCartesian v2, double * dot)

It would look like this with "constant pointer to constant" inputs:

pmCartCartDot(PmCartesian const * const v1, PmCartesian const * const v2,
double * const dot)

This would reduce stack bloat (a pointer vs. a ~24 byte struct) and
eliminate some needless copying. Adding the const specifiers makes the
compiler mark changes to v1 and v2 as errors, so it should be as safe and
robust as passing by value. One downside I can see is that you lose the
ability to use v1 and v2 as "scratch" variables, but I'd argue that you can
always declare such variables in the function when you need them.

Another concern I can think of is thread safety, but:

   - many posemath functions doesn't seem to be explicitly thread-safe
   - posemath functions seem like short utility functions, and shouldn't
   need to be thread-safe (i.e. the calling function should deal with it)

I've tested this change on a few of the posemath functions already without
any issues, but I'd like to know what the community thinks before I start
making major changes.

Thanks!
Rob
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to