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

Adding support for the X86Base.Pause intrinsic on Mono #61707

Merged
merged 2 commits into from
Nov 22, 2021

Conversation

tannergooding
Copy link
Member

This resolves #61693

@tannergooding
Copy link
Member Author

CC. @fanyang-mono, @EgorBo

What's the correct CI leg that needs to be kicked off to validate things here?

@lambdageek
Copy link
Member

I don't think this is enough. This only adds a mini opcode and an LLVM lowering for it.

You also need at least:

Actually, the new mini opcode isn't necessary. There's already OP_RELAXED_NOP (used for SpinWait_nop) which is lowered to SSE2 pause on x86/amd64

@tannergooding
Copy link
Member Author

Actually, the new mini opcode isn't necessary. There's already OP_RELAXED_NOP (used for SpinWait_nop) which is lowered to SSE2 pause on x86/amd64

I don't think its a good idea to rely on OP_RELAXED_NOP always being lowered to pause. We don't want a RELAXED_NOP, we want exactly X86Base.Pause. There should be no exceptions to this and future changes shouldn't impact it.

Implement non-LLVM JIT/AOT support for the new mini opcode

I'll add the additional handling for the non-LLVM path.

@lambdageek
Copy link
Member

I'll add the additional handling for the non-LLVM path.

Hmm... now I'm not sure... the x86base group is not marked as JIT supported in simd-intrinsics. So maybe it's fine for this to be LLVM-only? a bit surprising since it seems like we should be able to support these instructions in the JIT, too.

@tannergooding
Copy link
Member Author

tannergooding commented Nov 17, 2021

Updated to match what SFENCE/LFENCE/MFENCE do.

I was going to also add support for ArmBase.Yield, but it looks like the support isn't quite there and its a more complex fix.

For the JIT, the actual instruction encoding is D503 203F and so, theoretically, this is:

#define arm_yield(p) arm_hint ((p), 0x1)

For LLVM, it'd be aarch64_hint with a value of 1, so roughly:

Function *F = CGM.getIntrinsic(Intrinsic::aarch64_hint);
return Builder.CreateCall(F, llvm::ConstantInt::get(Int32Ty, 1));

but the overall mono logic here is different from what I'm familiar with and I'm not quite sure what the "right" fix is.

@vargaz
Copy link
Contributor

vargaz commented Nov 17, 2021

Most intrinsics in simd-intrinsic.c are only supported with llvm right now.

@fanyang-mono
Copy link
Member

/azp runtime-staging-manual

@azure-pipelines
Copy link

Command 'runtime-staging-manual' is not supported by Azure Pipelines.

Supported commands
  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

@fanyang-mono
Copy link
Member

/azp run runtime-staging-manual

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@fanyang-mono
Copy link
Member

Lane runtime-staging-manual (Build Android x86 Release AllSubsets_Mono) should be able to qualify the change here.

@agocke
Copy link
Member

agocke commented Nov 17, 2021

FYI, I've disabled the test in #61743 for now. If you merge in main you should be able to re-enable it in this branch.

@fanyang-mono
Copy link
Member

Lane runtime-staging-manual (Build Android x86 Release AllSubsets_Mono) should be able to qualify the change here.

Actually, what I sad earlier was not true. Since the newly added intrinsics will only be added for LLVM and X86Base.Pause is really for all intel architectures. So to qualify this change, Mono llvmaot Pri0 Runtime Tests Run Linux x64 release needs to run.

@imhameed
Copy link
Contributor

imhameed commented Nov 18, 2021

I'll add the additional handling for the non-LLVM path.

Hmm... now I'm not sure... the x86base group is not marked as JIT supported in simd-intrinsics. So maybe it's fine for this to be LLVM-only?

It's fine for this to be LLVM-only for now.

a bit surprising since it seems like we should be able to support these instructions in the JIT, too.

Adding bsf, bsr, and rep nop/pause to mini-amd64.c shouldn't be too bad, although I don't think it's very urgent.

@fanyang-mono
Copy link
Member

/azp run runtime-manual

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tannergooding
Copy link
Member Author

/azp run runtime-manual

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tannergooding
Copy link
Member Author

Can this be merged. It looks like all the failures are Android/iOS/WASM and are unrelated.

@vargaz
Copy link
Contributor

vargaz commented Nov 30, 2021

This does work for me locally:

0000000000000025	pause
0000000000000027	popq	%rax
0000000000000028	retq

but only when running with --llvm

@fanyang-mono
Copy link
Member

Followup: Mono llvmaot lane passed on rolling build.

@fanyang-mono
Copy link
Member

Followup: Mono llvmaot lane passed on rolling build.

By the time that I exam the rolling build tests results, this change has been reverted. My previous comment could be ignored.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 5, 2022
@tannergooding tannergooding deleted the pause-intrinsic branch May 9, 2024 01:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mono jit/hardwareintrinsics/x86/x86base/pause tests failing
6 participants