speed and passing data

N

N Yiannakoulias

Hi all,

Is there a performance issue when passing data types of different sizes to
a function? For example, if a double precision variable is bigger than a
single precision variable, is it faster at run time to pass the single
precision variable? Let's say the function does the exact same thing in
both cases (say, returns an integer). Is this a compiler-specific issue,
or is there a rule of thumb applicable to C?

N

--
 
B

Ben Pfaff

N Yiannakoulias said:
Is there a performance issue when passing data types of different sizes to
a function? For example, if a double precision variable is bigger than a
single precision variable, is it faster at run time to pass the single
precision variable? Let's say the function does the exact same thing in
both cases (say, returns an integer). Is this a compiler-specific issue,
or is there a rule of thumb applicable to C?

The answer is going to depend on the compiler and the
architecture and everything else. For instance, on x86
floating-point values are sometimes passed in the CPU's
floating-point registers; in that case, it shouldn't matter
whether they are float or double or long double.

The only way you can find out for sure is to measure actual
performance on the system of interest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top