mixing DP and SP code possible?

Hi,

I have certain code segments where SP doesn’t suffice so what I’m currently doing is mixing SP and DP code, so i have certain functions in the kernel that look like:

d_someCodeSegment( … ) ;

My question is, what will the compiler do ? Compile everything to run at DP or will it be clever enough to mix 32 bit and 64 bit instructions ? I’m trying to figure out if I will loose a lot of performance with this approach…

Thanks,
c

Hi,

I have certain code segments where SP doesn’t suffice so what I’m currently doing is mixing SP and DP code, so i have certain functions in the kernel that look like:

d_someCodeSegment( … ) ;

My question is, what will the compiler do ? Compile everything to run at DP or will it be clever enough to mix 32 bit and 64 bit instructions ? I’m trying to figure out if I will loose a lot of performance with this approach…

Thanks,
c

It’s not a matter of the compiler being “clever enough”. The compiler must follow the C++ semantics for numerical calculations. If a statement contains only SP values, than all results for that statement are computed in SP. If you have a mix of SP and DP in a single statement, then the type promotion rules apply. See your favorite C++ reference book for a list of these rules.

It’s not a matter of the compiler being “clever enough”. The compiler must follow the C++ semantics for numerical calculations. If a statement contains only SP values, than all results for that statement are computed in SP. If you have a mix of SP and DP in a single statement, then the type promotion rules apply. See your favorite C++ reference book for a list of these rules.

Hello,

This approach might help also because you need less registers for SP.

Hello,

This approach might help also because you need less registers for SP.

In this case I would have an almost complete separation of the SP and DP computations.

SP computational results serve as some of the inputs for the DP computations. The SP values are mixed with DP values and the resultant is type casted to DP. So line by line it would be:

SP - computations
SP - computations
SP - computations

SP_results = …

DP_input = SP_results * other_DP_inputs;
DP - computations
DP - computations
DP - computations

SP_input = DP_output * other_SP_values
SP - computations

If that makes any sense to you :)

Thanks!

In this case I would have an almost complete separation of the SP and DP computations.

SP computational results serve as some of the inputs for the DP computations. The SP values are mixed with DP values and the resultant is type casted to DP. So line by line it would be:

SP - computations
SP - computations
SP - computations

SP_results = …

DP_input = SP_results * other_DP_inputs;
DP - computations
DP - computations
DP - computations

SP_input = DP_output * other_SP_values
SP - computations

If that makes any sense to you :)

Thanks!