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

Light up BitArray APIs with Vector512 code path #91903

Merged
merged 13 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
adding test for AVX512 and Making sure we are shifting the bits corre…
…ctly
  • Loading branch information
khushal1996 committed Sep 11, 2023
commit ac56638c8b57f151c03c946b6343c599ab49b194
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ public unsafe void CopyTo(Array array, int index)
{
for (; (i + Vector512ByteCount) <= (uint)m_length; i += Vector512ByteCount)
{
long bits = m_array[i / (uint)BitsPerInt32] + m_array[(i / (uint)BitsPerInt32) + 1];
long bits = m_array[i / (uint)BitsPerInt32] + (m_array[(i / (uint)BitsPerInt32) + 1] << BitsPerInt32);
Vector512<long> scalar = Vector512.Create(bits);
Vector512<byte> shuffled = Vector512.Shuffle(scalar.AsByte(), shuffleMask);
Vector512<byte> extracted = Avx512F.And(shuffled, bitMask);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,13 @@ public static void CopyToByteArray()
[Fact]
public static void CopyToBoolArray()
{
for (int size = 4; size < 100; size++)
for (int size = 10000; size < 10100; size++)
{
var bitArray = new BitArray(size);
bitArray[1] = true;
bitArray[3] = true;
bitArray[31] = true;
bitArray[34] = true;

for (int i = 0; i < 100; i++)
{
Expand All @@ -366,6 +368,8 @@ public static void CopyToBoolArray()

expectedOutput[i + 1] = true;
expectedOutput[i + 3] = true;
expectedOutput[i + 31] = true;
expectedOutput[i + 34] = true;
bitArray.CopyTo(actualOutput, i);

Assert.Equal(expectedOutput, actualOutput);
Expand Down