KEMBAR78
[mono] Unaligned read/write only when NO_UNALIGNED_ACCESS is set by matouskozak · Pull Request #91813 · dotnet/runtime · GitHub
Skip to content

Conversation

@matouskozak
Copy link
Member

@matouskozak matouskozak commented Sep 8, 2023

Using unaligned read code path only when NO_UNALIGNED_ACCESS is set. Otherwise emit regular memory load (EMIT_NEW_LOAD_MEMBASE_TYPE) without using memcpy.

Edit: Increased the scope of the change to both load/store operations. When CPU supports unaligned memory access (NO_UNALIGNED_ACCESS is not set) we let CPU handle the unaligned load/store operation rather than handling it ourselves.


Locally confirmed that it fixes Perf_Matrix3x2.CreateRotation* benchmarks (#91361)

@ghost ghost added the area-Codegen-JIT-mono label Sep 8, 2023
@ghost ghost assigned matouskozak Sep 8, 2023
@matouskozak matouskozak changed the title [mono] Detect aligned read in ReadUnaligned [mono] Unaligned read in ReadUnaligned only when NO_UNALIGNED_ACCESS is set Sep 19, 2023
@matouskozak
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@matouskozak
Copy link
Member Author

Microbenchmarks results from x64-Ubuntu22.04

Microbenchmark ecef854 65536eb this PR
CreateRotationBenchmark 95.55 201.7 95.04
CreateRotationWithCenterBenchmark 99.09 209.7 98.62

@matouskozak matouskozak changed the title [mono] Unaligned read in ReadUnaligned only when NO_UNALIGNED_ACCESS is set [mono] Unaligned read/write only when NO_UNALIGNED_ACCESS is set Sep 22, 2023
@vargaz
Copy link
Contributor

vargaz commented Sep 25, 2023

What change caused the regression ?

@matouskozak
Copy link
Member Author

matouskozak commented Sep 25, 2023

What change caused the regression ?

It was introduced in #89364 by changing BitCast to use ReadUnaligned.

@matouskozak
Copy link
Member Author

The failures seem unrelated, and all can be found on main (e.g. bbe5c66)

@matouskozak matouskozak merged commit 169e22c into dotnet:main Sep 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 26, 2023
@matouskozak matouskozak deleted the conditional-ReadUnaligned branch October 3, 2024 13:15
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.

4 participants