Seva Alekseyev Seva Alekseyev - 1 year ago 121
C++ Question

Float array to double array and back, quickly

I need to convert large arrays of

in memory to arrays of
and back. Are there any SSE compiler intrinsics in Visual C++ 15 update 3 that would help?

EDIT: it's a conversion between two wire formats, so #define won't help. A data structure is stored as floats, but a third party processing library expects an array of double.

Answer Source

You can use SSE for this:

float -> double: _mm_cvtps_pd

double -> float: _mm_cvtpd_ps

Try a simple scalar loop first though as (a) the compiler may vectorize for you anyway and (b) you may well be memory-bound, so SIMD optimisation may not help much.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download