Skip to content

Commit

Permalink
Extend the byteCounts array to include sizes up to 128 bytes (the upp…
Browse files Browse the repository at this point in the history
…er limit used on x86/x64)
  • Loading branch information
echesakov committed Dec 3, 2021
1 parent 2e80844 commit 6e11a0e
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 1 deletion.
152 changes: 152 additions & 0 deletions src/benchmarks/micro/runtime/StoreBlock/StoreBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,60 @@ public void CopyBlock64()
Unsafe.CopyBlock(ref _dstData[startOffset], ref _srcData[startOffset], 64);
}
}

[Benchmark(OperationsPerInvoke = Size / 96)]
public void InitBlockAllZeros96()
{
for (int startOffset = 0; startOffset < Size; startOffset += 96)
{
Unsafe.InitBlock(ref _dstData[startOffset], 0, 96);
}
}

[Benchmark(OperationsPerInvoke = Size / 96)]
public void InitBlockAllOnes96()
{
for (int startOffset = 0; startOffset < Size; startOffset += 96)
{
Unsafe.InitBlock(ref _dstData[startOffset], 255, 96);
}
}

[Benchmark(OperationsPerInvoke = Size / 96)]
public void CopyBlock96()
{
for (int startOffset = 0; startOffset < Size; startOffset += 96)
{
Unsafe.CopyBlock(ref _dstData[startOffset], ref _srcData[startOffset], 96);
}
}

[Benchmark(OperationsPerInvoke = Size / 128)]
public void InitBlockAllZeros128()
{
for (int startOffset = 0; startOffset < Size; startOffset += 128)
{
Unsafe.InitBlock(ref _dstData[startOffset], 0, 128);
}
}

[Benchmark(OperationsPerInvoke = Size / 128)]
public void InitBlockAllOnes128()
{
for (int startOffset = 0; startOffset < Size; startOffset += 128)
{
Unsafe.InitBlock(ref _dstData[startOffset], 255, 128);
}
}

[Benchmark(OperationsPerInvoke = Size / 128)]
public void CopyBlock128()
{
for (int startOffset = 0; startOffset < Size; startOffset += 128)
{
Unsafe.CopyBlock(ref _dstData[startOffset], ref _srcData[startOffset], 128);
}
}
}

[BenchmarkCategory(Categories.Runtime, Categories.JIT)]
Expand Down Expand Up @@ -168,6 +222,20 @@ struct Struct64

Struct64 fld64;

[StructLayout(LayoutKind.Explicit, Size=96)]
struct Struct96
{
}

Struct96 fld96;

[StructLayout(LayoutKind.Explicit, Size=128)]
struct Struct128
{
}

Struct128 fld128;

[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
public unsafe void InitBlockAllZeros8()
{
Expand Down Expand Up @@ -335,5 +403,89 @@ public unsafe void CopyBlock64()

fld64 = dstLcl;
}

[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
public unsafe void InitBlockAllZeros96()
{
Struct96 dstLcl;

for (int i = 0; i < OperationsPerInvoke; i++)
{
Unsafe.InitBlock(&dstLcl, 0, 96);
}

fld96 = dstLcl;
}

[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
public unsafe void InitBlockAllOnes96()
{
Struct96 dstLcl;

for (int i = 0; i < OperationsPerInvoke; i++)
{
Unsafe.InitBlock(&dstLcl, 255, 96);
}

fld96 = dstLcl;
}

[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
public unsafe void CopyBlock96()
{
Struct96 srcLcl;
Struct96 dstLcl;

srcLcl = fld96;

for (int i = 0; i < OperationsPerInvoke; i++)
{
Unsafe.CopyBlock(&dstLcl, &srcLcl, 96);
}

fld96 = dstLcl;
}

[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
public unsafe void InitBlockAllZeros128()
{
Struct128 dstLcl;

for (int i = 0; i < OperationsPerInvoke; i++)
{
Unsafe.InitBlock(&dstLcl, 0, 128);
}

fld128 = dstLcl;
}

[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
public unsafe void InitBlockAllOnes128()
{
Struct128 dstLcl;

for (int i = 0; i < OperationsPerInvoke; i++)
{
Unsafe.InitBlock(&dstLcl, 255, 128);
}

fld128 = dstLcl;
}

[Benchmark(OperationsPerInvoke = OperationsPerInvoke)]
public unsafe void CopyBlock128()
{
Struct128 srcLcl;
Struct128 dstLcl;

srcLcl = fld128;

for (int i = 0; i < OperationsPerInvoke; i++)
{
Unsafe.CopyBlock(&dstLcl, &srcLcl, 128);
}

fld128 = dstLcl;
}
}
}
2 changes: 1 addition & 1 deletion src/benchmarks/micro/runtime/StoreBlock/StoreBlock.tt
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ namespace StoreBlock
#>
}
}
<#+ int[] byteCounts = new int[] { 8, 16, 32, 64 }; #>
<#+ int[] byteCounts = new int[] { 8, 16, 32, 64, 96, 128 }; #>

0 comments on commit 6e11a0e

Please sign in to comment.