Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the performance of the "address of" operator &?

I have to pass a lot of pointers in my code in the midst of a big loop, (so I have lots of expressions like foo(&x, &y, ...)). I was wondering whether I should store the pointers as separate variables (i.e. cache) for performance (at the cost of introducing more variables and clutter in my code)?

(Doing lots of matrix mult. and the CUBLAS library insists on pointers...)

like image 894
mchen Avatar asked Dec 04 '22 11:12

mchen


1 Answers

No -- the address-of operator is about as inexpensive/fast as anything you can hope for. It's possible to overload it, and such an overload could be slower, but overloading it at all is fairly unusual.

like image 167
Jerry Coffin Avatar answered Dec 07 '22 00:12

Jerry Coffin