From f020b5ff002e73b2617abf754583a0dffcb0b2ab Mon Sep 17 00:00:00 2001 From: Mateusz Gienieczko Date: Wed, 27 Sep 2023 14:35:16 +0100 Subject: [PATCH] Tweaks. --- .../SimdCheatCodesForFreePerformance.razor | 25 ++++++++++-------- src/Sorcery/Pages/Sourcery/Sourcery.razor | 2 +- src/Sorcery/Shared/Components/Header2.razor | 2 +- src/Sorcery/Shared/Components/Header3.razor | 2 +- src/Sorcery/Shared/Components/Header4.razor | 2 +- .../Shared/Components/LatexRenderer.razor | 26 +++++++++---------- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/Sorcery/Pages/Sourcery/Posts/SimdCheatCodesForFreePerformance.razor b/src/Sorcery/Pages/Sourcery/Posts/SimdCheatCodesForFreePerformance.razor index 12819c0..bdde5bc 100644 --- a/src/Sorcery/Pages/Sourcery/Posts/SimdCheatCodesForFreePerformance.razor +++ b/src/Sorcery/Pages/Sourcery/Posts/SimdCheatCodesForFreePerformance.razor @@ -8,7 +8,7 @@ public static readonly RenderFragment Introduction = __builder => { - However, modern CPUs have special instructions for a more complex mode of execution, + Modern CPUs have special instructions for a more complex mode of execution, together with separate registers for those instructions only. These are cheat codes that compilers and library developers use to get massive performance gains without fundamentally changing the algorithm being executed. @@ -48,8 +48,8 @@ The magical world of new instructions and registers I mentioned at the start is not actually needed to apply this concept. Consider the following toy problem. - - The Discrepancy Problem. — + + The Discrepancy Problem — We are given two streams of $8$-bit measurements from two sensors over some time period. We expect them to be the same, but since anomalies can occur we want to detect the first place at which they differ, if it exists. @@ -154,6 +154,7 @@ private int? Simd64(ReadOnlySpan sensor1, ReadOnlySpan sensor2) { throw new ArgumentException(""Unequal stream lengths""); } + const int Size = 8; // Take the cleanly divisible part and leave the remainders for later. @@ -238,7 +239,8 @@ code, including memory latency, and without proper profiling we cannot identify Clever Bitwise Tricks
- There's a small wrinkle that doesn't really affect performance, but understanding + There's a small wrinkle that doesn't really affect performance in this case – it happens + at most once at the end – but understanding how to fix it will go a long way. The sequential part of finding the exact place in a block where there's a discrepancy is not elegant and can be done with a small trick. @@ -262,14 +264,15 @@ code, including memory latency, and without proper profiling we cannot identify vectors were identical. Thus, the check on the blocks now becomes: diff --git a/src/Sorcery/Pages/Sourcery/Sourcery.razor b/src/Sorcery/Pages/Sourcery/Sourcery.razor index 0d7e0c7..dcb2cfd 100644 --- a/src/Sorcery/Pages/Sourcery/Sourcery.razor +++ b/src/Sorcery/Pages/Sourcery/Sourcery.razor @@ -18,7 +18,7 @@ @foreach (var post in BlogBook.Posts.Take(3)) { - + } diff --git a/src/Sorcery/Shared/Components/Header2.razor b/src/Sorcery/Shared/Components/Header2.razor index 52dd85c..a2a11b4 100644 --- a/src/Sorcery/Shared/Components/Header2.razor +++ b/src/Sorcery/Shared/Components/Header2.razor @@ -1,4 +1,4 @@ -@ChildContent +@ChildContent @code { diff --git a/src/Sorcery/Shared/Components/Header3.razor b/src/Sorcery/Shared/Components/Header3.razor index 82f3b8b..7371637 100644 --- a/src/Sorcery/Shared/Components/Header3.razor +++ b/src/Sorcery/Shared/Components/Header3.razor @@ -1,4 +1,4 @@ -@ChildContent +@ChildContent @code { diff --git a/src/Sorcery/Shared/Components/Header4.razor b/src/Sorcery/Shared/Components/Header4.razor index 6b4d9e5..527aec7 100644 --- a/src/Sorcery/Shared/Components/Header4.razor +++ b/src/Sorcery/Shared/Components/Header4.razor @@ -1,4 +1,4 @@ -@ChildContent +@ChildContent @code { diff --git a/src/Sorcery/Shared/Components/LatexRenderer.razor b/src/Sorcery/Shared/Components/LatexRenderer.razor index 61fe510..28cd002 100644 --- a/src/Sorcery/Shared/Components/LatexRenderer.razor +++ b/src/Sorcery/Shared/Components/LatexRenderer.razor @@ -12,19 +12,19 @@ { delimiters = new[] { - new - { - left = "$$", - right = "$$", - display = true - }, - new - { - left = "$", - right = "$", - display = false - } - }, + new + { + left = "$$", + right = "$$", + display = true + }, + new + { + left = "$", + right = "$", + display = false + } + }, throwOnError = true };