Skip to content

API Proposal: Ceil, Floor for Vector<T> #20509

@mjmckp

Description

@mjmckp

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<float> Floor(Vector<float> value);
        public static Vector<double> Floor(Vector<double> value);
        public static Vector<float> Ceiling(Vector<float> value);
        public static Vector<double> Ceiling(Vector<double> value);
    }
}

which map directly to the following AVX intrinsics:

_mm256_floor_ps
_mm256_floor_pd
_mm256_ceil_ps
_mm256_ceil_pd

respectively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedAPI was approved in API review, it can be implementedarea-System.Numericshelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions