Seva Alekseyev Seva Alekseyev - 22 days ago 6
C++ Question

Float array to double array and back, quickly

I need to convert large arrays of

float
in memory to arrays of
double
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

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.