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

Update TargetHasAVXSupport to correctly check for AVX support by accounting for all ISAs and bits necessary #61474

Closed
wants to merge 1 commit into from

Conversation

tannergooding
Copy link
Member

@tannergooding tannergooding commented Nov 11, 2021

This should partiallly resolve #61471

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 11, 2021
@ghost
Copy link

ghost commented Nov 11, 2021

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

This resolves #61471

Author: tannergooding
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@tannergooding
Copy link
Member Author

tannergooding commented Nov 11, 2021

@jkotas, @davidwrighton, this is called from exactly one place in methodtablebuilder.cpp: https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/methodtablebuilder.cpp#L1150-L1151.

  • I think this is "one time" but it would be good if that could be confirmed so we know it doesn't need to be cached.

Some other questions:

  • Do we know of any other places that have an AVX check that isn't going through void EEJitManager::SetCpuInfo()?
    • The bug indicates this failed on a machine with just SSSE3, so my guess is there is another method that needs updating
  • What would the right .NET 6 servicing branch be that this should backport against?

| (1 << 28); // AVX


if (((cpuInfo[CPUID_EDX] & EXPECTED_EDX) == EXPECTED_EDX) && ((cpuInfo[CPUID_ECX] & EXPECTED_ECX) == EXPECTED_ECX))
Copy link
Member

Choose a reason for hiding this comment

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

Instead of duplicating the logic here, would it be better to just call into JIT manager to get the InstructionSet_AVX bit from CPUCompileFlags?

This logic will get even more complex once we fix #60035

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably, yes.

I assumed there was some existing reason for this separation. If there isn't, it's likely more trivial to just reuse what we already have computed (assuming its correctly taking into account things like crossgen flags, etc)

Copy link
Member

@jkotas jkotas Nov 11, 2021

Choose a reason for hiding this comment

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

Actually, we do call into the JIT manager right after calling TargetHasAVXSupport anyway that should take care of everything. I think that the TargetHasAVXSupport is unnecessary and can be just deleted.

It does not explain where the bug may be.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that the TargetHasAVXSupport is unnecessary and can be just deleted.

I think you may be right...

It does not explain where the bug may be.

AFAIK, all of the logic for tracking and checking per-ISA checks (even for crossgen) is supposed to be driven around the information set by void EEJitManager::SetCpuInfo() and so if Avx isn't set there; the comparison of "is the R2R code supported" should fail if the method is annotated as uses Avx.

I'll try and dig in a bit more, but @davidwrighton might be able to give direct pointers to the right checks to look at/debug through.

@rickbrew
Copy link
Contributor

rickbrew commented Nov 11, 2021

I've sent two more builds to my private testers, one compiled for SSE4.2 and another compiled for SSE2.

If the SSE4.2 build also crashes on the SSSE3 system, then the issue runs deeper. Should know relatively soon (the tester is in Belarus, not sure of time zone differences). I also sent these builds to Tanner, he says he has a Q6600 he can test on.

@rickbrew
Copy link
Contributor

My tester confirmed that the SSE4.2 build does not work on the SSSE3 system. The SSE2 build is fine.

@tannergooding
Copy link
Member Author

Closing this one because, as @jkotas indicated this actually should have no impact and is just an "early out" effectively.

We could probably just remove this function and should consider doing so when we find the actual issue. Given that SSE4.2 also has problems when run on a system without SSE4.2 support; this indicates a potentially deeper issue in the crossgen logic.

@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 15, 2021
@tannergooding tannergooding deleted the fix-61471 branch November 11, 2022 15:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReadyToRun images crash if compiled for AVX2 but run on non-AVX2 CPU
3 participants