API Proposal: Ceil, Floor for Vector · Issue #20509 · dotnet/runtime (original) (raw)

This is a proposal of the ideas discussed in issue #20147.

There are a few SIMD operations on System.Numerics.Vector<T> missing that are required to implement vectorized versions of log, exp, sin, and cos.

There is a C implementation of these methods using AVX intrinsics here, which I have translated into a C# implemention using Vector<T> here. In the implementation, I have added fake versions of the missing intrinsics.

@mellinoe suggested creating two separate issues for the missing methods (the other issue is dotnet/corefx#16835), so the purpose of this issue is to propose the addition of the following methods:

[Updated proposal with comments below]

namespace System.Numerics { public static class Vector { public static Vector Floor(Vector value); public static Vector Floor(Vector value); public static Vector Ceiling(Vector value); public static Vector Ceiling(Vector value); } }

which map directly to the following AVX intrinsics:

_mm256_floor_ps
_mm256_floor_pd
_mm256_ceil_ps
_mm256_ceil_pd

respectively.