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

Packing 2 bits values into a bigger #24

Closed
Darshvino opened this issue Jun 16, 2022 · 5 comments
Closed

Packing 2 bits values into a bigger #24

Darshvino opened this issue Jun 16, 2022 · 5 comments

Comments

@Darshvino
Copy link

Hi @lemire,

Thank you for all your work and all the resources you had provided.

Is there any reference to efficiently pack the 2 bits into a larger data type(basically int64)?

A = 0000.........10(64 bit), B = 0000........11(64 bit), C = 0000........01, and so on, these are int64 values containing 2-bit values.

So, I want to pack them in an int64 datatype(32 2-bit values)
Z = 101101...........(int64 value, containing packed values of A, B, C, D, .............. )

I want to perform this efficiently. So It would be helpful if you can help me with some references.

Thanks in advance!

@lemire
Copy link
Member

lemire commented Jun 16, 2022

Please refer to our documentation and examples… You can pack 2-bit values using the simdcomp library as follows:
simdpackwithoutmask(datain, buffer, 2).

I believe that we provide references, see our README.

If you encounter issues using simdcomp, please start by describing the work you have and be specific on the issue.

@lemire lemire closed this as completed Jun 16, 2022
@Darshvino
Copy link
Author

Hi @lemire,

Thanks a lot for your reply.

I think this will be the main reference for 2 bits packing: https://github.com/lemire/simdcomp/blob/631f8a7a27cb3398be275f0144ab9133d0a2ea4c/src/simdbitpacking.c#L113

1.) Whether there is an implementation with an AVX2 instruction set(like using 256-bit registers)?

2.) And the input is the unpacked value(A = 0000.........10(64 bit), B = 0000........11(64 bit), C = 0000........01, and so on) and the output is the packed value(Z = 101101...........(int64 value, containing packed values of A, B, C, D, .............. ), is this right with the above implementation?

Thanks

@lemire
Copy link
Member

lemire commented Jun 16, 2022

Please refer to the papers, e.g.,

@Darshvino
Copy link
Author

Thank you a lot @lemire. I will refer to the above references

@Darshvino
Copy link
Author

Hi @lemire,

I interpreted the implementation of 2-bit packing using simdpackwithoutmask(datain, buffer, 2).

What I found wrt packing is:

If I have an Input array something like this: (3,2,1,3,1,3,2,0,1,1,2,3,2,3,3,2,0,2,0,0.....) each is of type int32
-> Then I load 4 values each into a 128 bit registers:
(3,2,1,3), (1,3,2,0), (1,1,2,3), (2,3,3,2),(0,2,0,0).....................

-> And then the packing will not happen serially, instead it happens something like this:
(.....0,2,1,1,3,........2,3,1,3,2,.........0,3,2,2,1,.........0,2,3,0,3......) --> Packed 2 bits data

What I mean to say is that the values in the packed data are not serial like the original.

It would be great if you can add few comments on this and give clarification on the way the data is being packed.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants