GeezerVison is showing github.com — API Proposal: Ceil, Floor for Vector<T> · Issue #20509 · dotnet/runtime
API Proposal: Ceil, Floor for Vector<T> #20509DescriptionThis 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. Reacted by Haytham ElFadeel, itsamelambda and Joannes Vermorel Activitychanged the title [-]API Proposal: Ceil, Floor, and Add for Vector<T>[/-] [+]API Proposal: Ceil, Floor for Vector<T>[/+] on Mar 7, 2017mellinoe commented on Mar 8, 2017 These seem really straightforward to me, and are a common operation in many algorithms. Any concerns about the feasibility in the JIT, or in other non-AVX architectures? @sivarv sivarv commented on Mar 8, 2017 CC @russellhadley
As per Intel manual, these C++ intrinsics are wrappers over roundps/roundpd instructions with rounding mode specified using an immediate byte. roundps/pd is supported on SSE4_1 and above. Given RyuJIT also supports SSE3_4 mode, which is more common than SSE2 alone, we should consider implementing these intrinsics. mellinoe commented on Mar 8, 2017 This one seems so straightforward that I'm just going to mark it as api-ready-for-review. Reacted by mjmckp, Jack Mott and itsamelambda terrajobst commented on Mar 14, 2017 Looks good, but we'd suggest changing x to value and Ceil to Ceiling, to be consistent with Math:
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);
}
}Reacted by Jack Mott and itsamelambda Gnbrkm41 commented on Oct 14, 2019 I would like to take a look at this. tannergooding commented on Oct 14, 2019 I talked with @Gnbrkm41 about this briefly in the C# Discord and what would be the process for getting this done 😄 danmoseley commented on Jan 29, 2020 Gnbrkm41 commented on Jan 30, 2020 Been wondering if the intrinsics part could be implemented in C# (#956) since there's a few conversion methods introduced to convert between Vector and HWIntrinsics vector types not so long ago, then apparently I've forgotten about it 😅 Thanks for the ping. I can give it a try still but feel free to unassign if this is a problem. Gnbrkm41 commented on Feb 2, 2020 Should this throw for any non-floating point types, like int/short/etc? it really doesn't make to ceil/floor those data types because they are integral types. tannergooding commented on Mar 2, 2020
Should this throw for any non-floating point types, like int/short/etc? it really doesn't make to ceil/floor those data types because they are integral types.
@Gnbrkm41, The proposed and approved API surface is only for float/double, so we shouldn't need to consider the integral types. tannergooding commented on Mar 16, 2020 ghost locked as resolved and limited conversation to collaborators on Dec 25, 2020
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|