Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode AVX512 UTF8 #34

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions benchmark/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,82 @@ public unsafe void RunAVX2DecodingBenchmarkWithAllocUTF16(string[] data, int[] l
}


public unsafe void RunAVX512DecodingBenchmarkUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
//string s = FileContent[i];
byte[] base64 = input[i];
byte[] dataoutput = output[i];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.AVX512.Base64.DecodeFromBase64AVX512(base64.AsSpan(), dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}

// public unsafe void RunAVX512DecodingBenchmarkUTF16(string[] data, int[] lengths)
// {
// for (int i = 0; i < FileContent.Length; i++)
// {
// string s = FileContent[i];
// ReadOnlySpan<char> base64 = s.AsSpan();
// byte[] dataoutput = output[i];
// int bytesConsumed = 0;
// int bytesWritten = 0;
// SimdBase64.AVX512.Base64.DecodeFromBase64AVX512(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
// if (bytesWritten != lengths[i])
// {
// Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
// #pragma warning disable CA2201
// throw new Exception("Error");
// }
// }
// }

public unsafe void RunAVX512DecodingBenchmarkWithAllocUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
{
Span<byte> base64 = input[i].AsSpan();
byte[] dataoutput = new byte[SimdBase64.Scalar.Base64.MaximalBinaryLengthFromBase64Scalar<byte>(base64)];
int bytesConsumed = 0;
int bytesWritten = 0;
SimdBase64.AVX512.Base64.DecodeFromBase64AVX512(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
if (bytesWritten != lengths[i])
{
Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
#pragma warning disable CA2201
throw new Exception("Error");
}
}
}

// public unsafe void RunAVX512DecodingBenchmarkWithAllocUTF16(string[] data, int[] lengths)
// {
// for (int i = 0; i < FileContent.Length; i++)
// {
// string s = FileContent[i];
// Span<char> base64 = input16[i].AsSpan();
// byte[] dataoutput = new byte[SimdBase64.Scalar.Base64.MaximalBinaryLengthFromBase64Scalar<char>(base64)];
// int bytesConsumed = 0;
// int bytesWritten = 0;
// SimdBase64.AVX512.Base64.DecodeFromBase64AVX512(base64, dataoutput, out bytesConsumed, out bytesWritten, false);
// if (bytesWritten != lengths[i])
// {
// Console.WriteLine($"Error: {bytesWritten} != {lengths[i]}");
// #pragma warning disable CA2201
// throw new Exception("Error");
// }
// }
// }


public unsafe void RunARMDecodingBenchmarkUTF8(string[] data, int[] lengths)
{
for (int i = 0; i < FileContent.Length; i++)
Expand Down Expand Up @@ -587,6 +663,20 @@ public unsafe void AVX2DecodingRealDataWithAllocUTF8()
RunAVX2DecodingBenchmarkWithAllocUTF8(FileContent, DecodedLengths);
}

[Benchmark]
[BenchmarkCategory("AVX512")]
public unsafe void AVX512DecodingRealDataUTF8()
{
RunAVX512DecodingBenchmarkUTF8(FileContent, DecodedLengths);
}

//[Benchmark]
//[BenchmarkCategory("AVX512")]
public unsafe void AVX512DecodingRealDataWithAllocUTF8()
{
RunAVX512DecodingBenchmarkWithAllocUTF8(FileContent, DecodedLengths);
}


[Benchmark]
[BenchmarkCategory("arm64")]
Expand Down Expand Up @@ -637,6 +727,20 @@ public unsafe void AVX2DecodingRealDataWithAllocUTF16()
RunAVX2DecodingBenchmarkWithAllocUTF16(FileContent, DecodedLengths);
}

//[Benchmark]
// //[BenchmarkCategory("AVX512")]
// public unsafe void AVX512DecodingRealDataUTF16()
// {
// RunAVX512DecodingBenchmarkUTF16(FileContent, DecodedLengths);
// }

// //[Benchmark]
// //[BenchmarkCategory("AVX512")]
// public unsafe void AVX512DecodingRealDataWithAllocUTF16()
// {
// RunAVX512DecodingBenchmarkWithAllocUTF16(FileContent, DecodedLengths);
// }

}
#pragma warning disable CA1515
public class Program
Expand Down
Loading