Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use SIMD for block inits with GC fields#102132

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
EgorBo merged 5 commits intodotnet:mainfromEgorBo:simd-blk-gc-init
May 15, 2024

Conversation

@EgorBo
Copy link
Member

@EgorBoEgorBo commentedMay 12, 2024
edited
Loading

Closes#83297

Currently, we conservatively give up on using SIMDs for structs (blocks) with GC references since SIMD (on x86/64 arch) has certain requirements to provide atomicity guarantees (data needs to be 16 byte aligned, CPU must support AVX2 and we must use aligned store instructions). Let's at least use SIMD for continuous non-GC parts of such structs, example:

structMyStruct{stringgc1;longa;longb;longc;longd;longe;longf;longg;longh;}MyStructTest()=>new();

Codegen diff:

; Method Bench:Test():Bench+MyStruct:this (FullOpts)       xor      eax, eax       mov      qword ptr [rdx], rax ;; <-- GC slot-      mov      qword ptr [rdx+0x08], rax-      mov      qword ptr [rdx+0x10], rax-      mov      qword ptr [rdx+0x18], rax-      mov      qword ptr [rdx+0x20], rax-      mov      qword ptr [rdx+0x28], rax-      mov      qword ptr [rdx+0x30], rax-      mov      qword ptr [rdx+0x38], rax-      mov      qword ptr [rdx+0x40], rax+      vxorps   xmm0, xmm0, xmm0+      vmovdqu32 zmmword ptr [rdx+0x08], zmm0       mov      rax, rdx       ret-; Total bytes of code: 41+; Total bytes of code: 23

am11, En3Tho, PaulusParssinen, omariom, MihaZupan, neon-sunset, hughbe, GerardSmit, and hendriklhf reacted with rocket emoji
@ghostghost added the area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labelMay 12, 2024
@dotnetdotnet deleted a comment fromEgorBotMay 12, 2024
@dotnetdotnet deleted a comment fromEgorBotMay 12, 2024
@dotnetdotnet deleted a comment fromEgorBotMay 12, 2024
@EgorBo
Copy link
MemberAuthor

@EgorBot

usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Running;BenchmarkRunner.Run<Bench>(args:args);publicclassBench{publicstructMyStructWithGC{objectgc;longa;longb;longc;longd;longe;longf;longg;longh;}MyStructWithGC_fld1;MyStructWithGC_fld2;[Benchmark]publicvoidZeroing(){_fld1=default;_fld2=default;}}

@EgorBot
Copy link

@EgorBo

BenchmarkDotNet v0.13.12, Ubuntu 22.04.4 LTS (Jammy Jellyfish)AMD EPYC 7763, 1 CPU, 2 logical cores and 1 physical core.NET SDK 9.0.100-preview.3.24204.13  [Host]     : .NET 9.0.0 (9.0.24.17209), X64 RyuJIT AVX2  Job-BWFEHP : .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX2  Job-NQQMIR : .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX2
MethodToolchainMeanRatio
Zeroing/Main/corerun1.9355 ns1.00
Zeroing/PR/corerun0.4288 ns0.22
omariom reacted with thumbs up emojiPaulusParssinen and danielmarbach reacted with hooray emoji

@EgorBoEgorBo marked this pull request as ready for reviewMay 12, 2024 18:23
@EgorBo
Copy link
MemberAuthor

@jakobbotsch@kunalspathak @dotnet/jit-contrib PTAL,diffs aren't too big

@EgorBo
Copy link
MemberAuthor

Ping@jakobbotsch@kunalspathak @dotnet/jit-contrib 🙂#102209 depends on it (for simpler diffs)

@jakobbotsch
Copy link
Member

jakobbotsch commentedMay 15, 2024
edited
Loading

It would be nice to support it for copies as well (I think that would fix#90196 and#7469)

omariom and neon-sunset reacted with thumbs up emoji

Copy link
Contributor

@kunalspathakkunalspathak left a comment

Choose a reason for hiding this comment

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

LGTM

@EgorBoEgorBo merged commit2b0c1de intodotnet:mainMay 15, 2024
@EgorBoEgorBo deleted the simd-blk-gc-init branchMay 15, 2024 15:13
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull requestMay 30, 2024
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 15, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@jakobbotschjakobbotschjakobbotsch approved these changes

+1 more reviewer

@kunalspathakkunalspathakkunalspathak approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

@EgorBoEgorBo

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Suboptimal struct zeroing in case of gc pointers

4 participants

@EgorBo@EgorBot@jakobbotsch@kunalspathak

[8]ページ先頭

©2009-2025 Movatter.jp