Base64 icon indicating copy to clipboard operation
Base64 copied to clipboard

Add AVX512Support

Open eveloki opened this issue 5 months ago • 3 comments

https://learn.microsoft.com/en-us/dotnet/api/system.runtime.intrinsics.x86.avx512vbmi?view=net-9.0

If .Net Version > Net 8.0 Add AVX512Support

It seems that we only need to add Vector512Decode in class Base64Impl<TBase64Encoder>, check if maxSrcLength is greater than or equal to 60 or more, and add the corresponding Test I'm not sure if you welcome PR, and I'm concerned about whether my technical skills meet the requirements Please evaluate the relevant issues

eveloki avatar Aug 13 '25 08:08 eveloki

It seems that we only need to add Vector512Decode in class Base64Impl, check if maxSrcLength is greater than or equal to 60 or more, and add the corresponding Test

It would be nice if it would be so easy, but that's not the case. For base64 the bits need to be shuffled around to produce 6-bit values for encoding, and to read from 6-bit values for decoding ($2^6 = 64$, thus it's called base64).

So a proper implementation should be based on something like AVX512F base64 coding and decoding.

ATM I don't have a DEV-box with AVX512 and that's why support for AVX512 isn't done yet.

I'm not sure if you welcome PR

Yes, they're welcome, but the (unwritten) requirements should be met (at least after PR review).

gfoidl avatar Aug 13 '25 12:08 gfoidl

It seems that we only need to add Vector512Decode in class Base64Impl, check if maxSrcLength is greater than or equal to 60 or more, and add the corresponding Test

It would be nice if it would be so easy, but that's not the case. For base64 the bits need to be shuffled around to produce 6-bit values for encoding, and to read from 6-bit values for decoding ( 2 6 = 64 , thus it's called base64).

So a proper implementation should be based on something like AVX512F base64 coding and decoding.

ATM I don't have a DEV-box with AVX512 and that's why support for AVX512 isn't done yet.

I'm not sure if you welcome PR

Yes, they're welcome, but the (unwritten) requirements should be met (at least after PR review).

Thank you so much for your reply. I had always assumed that Intel® SDE (which can emulate the AVX512 instruction set,it works on C++ programs) could solve this issue, but unfortunately, I just tried it and found that it doesn't support .NET. After searching, I discovered that support is still in development (https://github.com/dotnet/runtime/issues/110672) , and it seems like it will be ready in .NET 11.0? I seriously underestimated the complexity of the implementation. Let’s wait for the development to mature.

eveloki avatar Aug 13 '25 14:08 eveloki

Or I just by a new PC 😉.

But thanks for bringing this up anyway.

gfoidl avatar Aug 13 '25 17:08 gfoidl