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

Use minipal_getcpufeatures to detect for AVX #113032

Merged
merged 4 commits into from
Mar 4, 2025

Conversation

cshung
Copy link
Member

@cshung cshung commented Mar 1, 2025

This should fix #112897

@cshung cshung self-assigned this Mar 1, 2025
@Copilot Copilot bot review requested due to automatic review settings March 1, 2025 17:45

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

@cshung cshung force-pushed the public/fix-avx-detection branch from 5a71048 to e7edd2e Compare March 1, 2025 19:59
@am11
Copy link
Member

am11 commented Mar 1, 2025

It could be OS-agnostic cshung/runtime@public/fix-avx-detection...am11:runtime:public/fix-avx-detection.

@mrsharm
Copy link
Member

mrsharm commented Mar 4, 2025

Testing

Successfully tested.

Modified code for testing:

SupportedISA DetermineSupportedISA()
{
    int cpuFeatures = minipal_getcpufeatures();
    if ((cpuFeatures & XArchIntrinsicConstants_Avx2) != 0)
    {
        printf( "Has AVX2 \n");
        if ((cpuFeatures & XArchIntrinsicConstants_Avx512) != 0)
        {
            printf( "Has AVX-512 \n");
            return (SupportedISA)((int)SupportedISA::AVX2 | (int)SupportedISA::AVX512F);
        }
        else
            return SupportedISA::AVX2;
    }
    else
    {
        printf( "Doesn't have AVX2 \n");
        return SupportedISA::None;
    }
}

Testing on a Machine with AVX-2 but not AVX-512.

Processor: AMD EPYC 7763 64-Core Processor

Windows

 .\corerun.exe .\GCPerfSim.dll -- -tc 16 -tagb 5 -tlgb 2 -lohpi 0 -sohsi 50 -ramb 20 -rlmb 2 -sohpi 0
Has AVX2

Linux

./corerun GCPerfSim.dll -- -tc 16 -tagb 5 -tlgb
2 -lohpi 0 -sohsi 50 -ramb 20 -rlmb 2 -sohpi 0
Has AVX2

Testing on a Machine with AVX-512

Windows

./corerun ,exe GCPerfSim.dll --  -tc 16 -tagb 5 -tlgb 2 -l
ohpi 0 -sohsi 50 -ramb 20 -rlmb 2 -sohpi 0
Has AVX2
Has AVX-512

Linux

.\corerun .\GCPerfSim.dll --  -tc 16 -tagb 5 -tlgb 2 -lohpi 0 -sohsi 50 -ramb 20 -rlmb 2 -sohpi 0
Has AVX2
Has AVX-512

Testing on a Machine with AVX* disabled

bcdedit /set xsavedisable 1 to disable AVX*.

Windows

corerun.exe GCPerfSim.dll --  -tc 16 -tagb 5 -tlgb 2 -lohpi 0 -sohsi 50 -ramb 20 -rlmb 2 -sohpi 0 
Doesn't have AVX2

Linux

./corerun GCPerfSim.dll --  -tc 16 -tagb 5 -tlgb 2 -lohpi 0 -sohsi 50 -ramb 20 -rlmb 2 -sohpi 0
Doesn't have AVX2

Copy link
Member

@mrsharm mrsharm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Tested extensively.

@cshung cshung merged commit 6d344b3 into dotnet:main Mar 4, 2025
94 checks passed
@cshung cshung deleted the public/fix-avx-detection branch March 4, 2025 02:20
@EgorBo
Copy link
Member

EgorBo commented Mar 5, 2025

Should it be backported?

@mangod9
Copy link
Member

mangod9 commented Mar 5, 2025

yeah trying to validate the fix, and determine priority since it doesnt seem to be failing broadly across all hardware as far as we can tell, so guessing its not certain CPU skus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Signal SIGILL (Illegal instruction) code ILL_ILLOPN (Illegal operand) after migrate to .net9
5 participants