[sac-user] Need more help on pass by reference

Daniel Rolls daniel.rolls.27 at googlemail.com
Sun Aug 22 13:22:20 CEST 2010


The array being returned (Z) should only appear one once in the SaC  
function signature as a return type. I.e

external double[.] /* Z */ add( double[.] X, double[.] Y);

Then in SaC you can call the function C = A + B by
C = add(A,B)

You can also write A = add(A,B) and A = add(A,A) but be aware that the  
returned A's are new variables and do not denote that memory used for  
the original A will be reused. Sac2c will work that out for you.

I hope that clarifies things a bit,

On 22 Aug 2010, at 04:35, Salem Reyen wrote:

> I have a C function which adds two double precision vectors, ie,
> add(double* X, double *Y, double* Z) where vectors X and Y are
> the input vectors and Z is the output vector.  In SaC, I declare
> A, B, C to be double precision vectors.
> Based on Bodo's example, I can declare
> external double[.] add(double[.] X, double[.] Y, double[.] Z);
> #pragma linksign[3,1,2,3]
> And then I can call the function add for C = A + B by
> C = add(A, B, C);
> Now my question is how can SaC compiler handle the cases such as
> A = A + B and A = A + A?
> Salem
> _______________________________________________
> sac-user mailing list
> sac-user at sac-home.org
> http://lists.sac-home.org/mailman/listinfo.cgi/sac-user

More information about the sac-user mailing list