- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good afternoon.
I have some function for calculate parity number on any x86 computers:
Source: http://graphics.stanford.edu/~seander/bithacks.html#ParityNaive
[bash]static const bool ParityTable256[256] = { # define P2(n) n, n^1, n^1, n # define P4(n) P2(n), P2(n^1), P2(n^1), P2(n) # define P6(n) P4(n), P4(n^1), P4(n^1), P4(n) P6(0), P6(1), P6(1), P6(0) }; unsigned int __forceinline parity(unsigned __int32 v) { v ^= v >> 16; v ^= v >> 8; return ParityTable256[v & 0xff]; }
[/bash]
and for computer with SSE4.2 instruction:
[bash]UINT __forceinline parity( UINT32 word ) { return _mm_popcnt_u32( word ) & 1; }[/bash]
How force compiler create two code branches for x86 proccessor and proccesor with SSE 4.2, but without using of CPUID instruction?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's a little strange that the original documentation comes up first in a search, and so you want the current names for use in icc.
I would advise testing this on every platform each time you change library versions.
I would advise testing this on every platform each time you change library versions.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's a little strange that the original documentation comes up first in a search, and so you want the current names for use in icc.
I would advise testing this on every platform each time you change library versions.
I would advise testing this on every platform each time you change library versions.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page