Skip to content

Commit 6e11a0e

Browse files
committed
Extend the byteCounts array to include sizes up to 128 bytes (the upper limit used on x86/x64)
1 parent 2e80844 commit 6e11a0e

File tree

2 files changed

+153
-1
lines changed

2 files changed

+153
-1
lines changed

src/benchmarks/micro/runtime/StoreBlock/StoreBlock.cs

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,60 @@ public void CopyBlock64()
133133
Unsafe.CopyBlock(ref _dstData[startOffset], ref _srcData[startOffset], 64);
134134
}
135135
}
136+
137+
[Benchmark(OperationsPerInvoke = Size / 96)]
138+
public void InitBlockAllZeros96()
139+
{
140+
for (int startOffset = 0; startOffset < Size; startOffset += 96)
141+
{
142+
Unsafe.InitBlock(ref _dstData[startOffset], 0, 96);
143+
}
144+
}
145+
146+
[Benchmark(OperationsPerInvoke = Size / 96)]
147+
public void InitBlockAllOnes96()
148+
{
149+
for (int startOffset = 0; startOffset < Size; startOffset += 96)
150+
{
151+
Unsafe.InitBlock(ref _dstData[startOffset], 255, 96);
152+
}
153+
}
154+
155+
[Benchmark(OperationsPerInvoke = Size / 96)]
156+
public void CopyBlock96()
157+
{
158+
for (int startOffset = 0; startOffset < Size; startOffset += 96)
159+
{
160+
Unsafe.CopyBlock(ref _dstData[startOffset], ref _srcData[startOffset], 96);
161+
}
162+
}
163+
164+
[Benchmark(OperationsPerInvoke = Size / 128)]
165+
public void InitBlockAllZeros128()
166+
{
167+
for (int startOffset = 0; startOffset < Size; startOffset += 128)
168+
{
169+
Unsafe.InitBlock(ref _dstData[startOffset], 0, 128);
170+
}
171+
}
172+
173+
[Benchmark(OperationsPerInvoke = Size / 128)]
174+
public void InitBlockAllOnes128()
175+
{
176+
for (int startOffset = 0; startOffset < Size; startOffset += 128)
177+
{
178+
Unsafe.InitBlock(ref _dstData[startOffset], 255, 128);
179+
}
180+
}
181+
182+
[Benchmark(OperationsPerInvoke = Size / 128)]
183+
public void CopyBlock128()
184+
{
185+
for (int startOffset = 0; startOffset < Size; startOffset += 128)
186+
{
187+
Unsafe.CopyBlock(ref _dstData[startOffset], ref _srcData[startOffset], 128);
188+
}
189+
}
136190
}
137191

138192
[BenchmarkCategory(Categories.Runtime, Categories.JIT)]
@@ -168,6 +222,20 @@ struct Struct64
168222

169223
Struct64 fld64;
170224

225+
[StructLayout(LayoutKind.Explicit, Size=96)]
226+
struct Struct96
227+
{
228+
}
229+
230+
Struct96 fld96;
231+
232+
[StructLayout(LayoutKind.Explicit, Size=128)]
233+
struct Struct128
234+
{
235+
}
236+
237+
Struct128 fld128;
238+
171239
[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
172240
public unsafe void InitBlockAllZeros8()
173241
{
@@ -335,5 +403,89 @@ public unsafe void CopyBlock64()
335403

336404
fld64 = dstLcl;
337405
}
406+
407+
[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
408+
public unsafe void InitBlockAllZeros96()
409+
{
410+
Struct96 dstLcl;
411+
412+
for (int i = 0; i < OperationsPerInvoke; i++)
413+
{
414+
Unsafe.InitBlock(&dstLcl, 0, 96);
415+
}
416+
417+
fld96 = dstLcl;
418+
}
419+
420+
[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
421+
public unsafe void InitBlockAllOnes96()
422+
{
423+
Struct96 dstLcl;
424+
425+
for (int i = 0; i < OperationsPerInvoke; i++)
426+
{
427+
Unsafe.InitBlock(&dstLcl, 255, 96);
428+
}
429+
430+
fld96 = dstLcl;
431+
}
432+
433+
[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
434+
public unsafe void CopyBlock96()
435+
{
436+
Struct96 srcLcl;
437+
Struct96 dstLcl;
438+
439+
srcLcl = fld96;
440+
441+
for (int i = 0; i < OperationsPerInvoke; i++)
442+
{
443+
Unsafe.CopyBlock(&dstLcl, &srcLcl, 96);
444+
}
445+
446+
fld96 = dstLcl;
447+
}
448+
449+
[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
450+
public unsafe void InitBlockAllZeros128()
451+
{
452+
Struct128 dstLcl;
453+
454+
for (int i = 0; i < OperationsPerInvoke; i++)
455+
{
456+
Unsafe.InitBlock(&dstLcl, 0, 128);
457+
}
458+
459+
fld128 = dstLcl;
460+
}
461+
462+
[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
463+
public unsafe void InitBlockAllOnes128()
464+
{
465+
Struct128 dstLcl;
466+
467+
for (int i = 0; i < OperationsPerInvoke; i++)
468+
{
469+
Unsafe.InitBlock(&dstLcl, 255, 128);
470+
}
471+
472+
fld128 = dstLcl;
473+
}
474+
475+
[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
476+
public unsafe void CopyBlock128()
477+
{
478+
Struct128 srcLcl;
479+
Struct128 dstLcl;
480+
481+
srcLcl = fld128;
482+
483+
for (int i = 0; i < OperationsPerInvoke; i++)
484+
{
485+
Unsafe.CopyBlock(&dstLcl, &srcLcl, 128);
486+
}
487+
488+
fld128 = dstLcl;
489+
}
338490
}
339491
}

src/benchmarks/micro/runtime/StoreBlock/StoreBlock.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ namespace StoreBlock
131131
#>
132132
}
133133
}
134-
<#+ int[] byteCounts = new int[] { 8, 16, 32, 64 }; #>
134+
<#+ int[] byteCounts = new int[] { 8, 16, 32, 64, 96, 128 }; #>

0 commit comments

Comments
 (0)