Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose IsSupported properties on the vector types #69036

Closed
tannergooding opened this issue May 8, 2022 · 3 comments · Fixed by #71240
Closed

Expose IsSupported properties on the vector types #69036

tannergooding opened this issue May 8, 2022 · 3 comments · Fixed by #71240
Labels
api-approved API was approved in API review, it can be implemented area-System.Runtime.Intrinsics
Milestone

Comments

@tannergooding
Copy link
Member

Summary

There are currently several scenarios where we may be dealing with a generic type and want to vectorize it if vectorization support exists. However, those checks are currently sometimes hard to do, may not cover future changes to what T is supported, and may not be constant folded by the JIT.

One such example of this is in #68183 where we currently have to limit the vectorization paths after checking for specific cases of T.

Users would be expected to check both Vector128<T>.IsSupported && Vector128.IsHardwareAccelerated to determine if the usage of T is expected to be performant.

API Proposal

namespace System.Numerics
{
    public partial struct Vector<T>
    {
        public static bool IsSupported { get; }
    }
}

namespace System.Runtime.Intrinsics
{
    public partial struct Vector64<T>
    {
        public static bool IsSupported { get; }
    }

    public partial struct Vector128<T>
    {
        public static bool IsSupported { get; }
    }

    public partial struct Vector256<T>
    {
        public static bool IsSupported { get; }
    }
}
@tannergooding tannergooding added area-System.Runtime.Intrinsics api-ready-for-review API is ready for review, it is NOT ready for implementation labels May 8, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label May 8, 2022
@ghost
Copy link

ghost commented May 8, 2022

Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics
See info in area-owners.md if you want to be subscribed.

Issue Details

Summary

There are currently several scenarios where we may be dealing with a generic type and want to vectorize it if vectorization support exists. However, those checks are currently sometimes hard to do, may not cover future changes to what T is supported, and may not be constant folded by the JIT.

One such example of this is in #68183 where we currently have to limit the vectorization paths after checking for specific cases of T.

Users would be expected to check both Vector128<T>.IsSupported && Vector128.IsHardwareAccelerated to determine if the usage of T is expected to be performant.

API Proposal

namespace System.Numerics
{
    public partial struct Vector<T>
    {
        public static bool IsSupported { get; }
    }
}

namespace System.Runtime.Intrinsics
{
    public partial struct Vector64<T>
    {
        public static bool IsSupported { get; }
    }

    public partial struct Vector128<T>
    {
        public static bool IsSupported { get; }
    }

    public partial struct Vector256<T>
    {
        public static bool IsSupported { get; }
    }
}
Author: tannergooding
Assignees: -
Labels:

area-System.Runtime.Intrinsics, api-ready-for-review

Milestone: -

@tannergooding
Copy link
Member Author

CC. @stephentoub

@tannergooding tannergooding removed the untriaged New issue has not been triaged by the area owner label May 8, 2022
@tannergooding tannergooding added this to the 7.0.0 milestone Jun 23, 2022
@terrajobst
Copy link
Member

terrajobst commented Jun 23, 2022

Video

  • Looks good as proposed
namespace System.Numerics;

public partial struct Vector<T>
{
    public static bool IsSupported { get; }
}
namespace System.Runtime.Intrinsics;

public partial struct Vector64<T>
{
    public static bool IsSupported { get; }
}

public partial struct Vector128<T>
{
    public static bool IsSupported { get; }
}

public partial struct Vector256<T>
{
    public static bool IsSupported { get; }
}

@terrajobst terrajobst added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Jun 23, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jun 24, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 5, 2022
@dotnet dotnet locked as resolved and limited conversation to collaborators Aug 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Runtime.Intrinsics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants