Search code examples
c++cavxfloor

How to implement floor(double) in AVX?


The C and C++ function double floor(double arg) (defined in cmath and math.h) returns the largest integer value not greater than arg. What is the most efficient way to vectorise this using AVX instructions?

Essentially, what I want is

__m256d floor(__m256d arg);

Is it necessary to convert to integer and back?


Solution

  • That intrinsic exists as _mm256_floor_pd