From f5f20abc8f8736dc156a9d97711bcc0e9ba905a0 Mon Sep 17 00:00:00 2001 From: Mateusz Gienieczko Date: Thu, 28 Sep 2023 01:08:56 +0100 Subject: [PATCH] Add SharpLab link. --- .../Discrepancy/Program.cs | 4 ++-- .../Sourcery/Posts/SimdCheatCodesForFreePerformance.razor | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/BlogPostCode/SimdCheatCodesForFreePerformance/Discrepancy/Program.cs b/src/BlogPostCode/SimdCheatCodesForFreePerformance/Discrepancy/Program.cs index 021483c..1c75092 100644 --- a/src/BlogPostCode/SimdCheatCodesForFreePerformance/Discrepancy/Program.cs +++ b/src/BlogPostCode/SimdCheatCodesForFreePerformance/Discrepancy/Program.cs @@ -8,8 +8,6 @@ using BenchmarkDotNet.Running; using Sse2 = System.Runtime.Intrinsics.X86.Sse2; using Avx2 = System.Runtime.Intrinsics.X86.Avx2; -using System.IO; -using Dia2Lib; BenchmarkRunner.Run(); @@ -34,8 +32,10 @@ public void Setup() var rng = new Random(Seed); rng.NextBytes(Stream1); + // Make the streams identical, but... Stream1.CopyTo(Stream2, 0); + // ... forcefully introduce a discrepancy on the last byte. Stream2[^1] ^= 0x01; } diff --git a/src/Sorcery/Pages/Sourcery/Posts/SimdCheatCodesForFreePerformance.razor b/src/Sorcery/Pages/Sourcery/Posts/SimdCheatCodesForFreePerformance.razor index 1c403eb..748e4e5 100644 --- a/src/Sorcery/Pages/Sourcery/Posts/SimdCheatCodesForFreePerformance.razor +++ b/src/Sorcery/Pages/Sourcery/Posts/SimdCheatCodesForFreePerformance.razor @@ -599,8 +599,11 @@ private int? Simd128Portable(ReadOnlySpan sensor1, ReadOnlySpan sens } ")" /> - Whew. The reference handling is a bit scary with all the "unsafe", but the rest is rather - simple. So, it's a bit harder to code in this paradigm, but are the performance gains + Whew. The reference handling is a bit scary with all the "unsafe", but the rest should be + understandable with our walkthrough. You can play around with the code from + my GitHub + or on this SharpLab demo. + So, it's a bit harder to code in this paradigm, but are the performance gains worth it?