after a few rounds of k-means-clustering, we should have a set of 2, 3 or 4 partitions; we turn this set into 2, 3 or 4 bitmaps. Then, for each of the ( 64 bit uses 1024) (32 bit uses ???) partitions, we try to match the bitmaps as well as possible. maybe an issue for GPU to work in 64bits static inline
| 9044 | //# maybe an issue for GPU to work in 64bits |
| 9045 | //static inline |
| 9046 | int bitcount(uint64_cl p) |
| 9047 | { |
| 9048 | #ifdef ENABLE_64Bit_Support |
| 9049 | bool isTrue = sizeof(void*) > 4; |
| 9050 | if (isTrue) |
| 9051 | { |
| 9052 | uint64_cl mask1 = 0x5555555555555555ULL; |
| 9053 | uint64_cl mask2 = 0x3333333333333333ULL; |
| 9054 | uint64_cl mask3 = 0x0F0F0F0F0F0F0F0FULL; |
| 9055 | // best-known algorithm for 64-bit bitcount, assuming 64-bit processor |
| 9056 | // should probably be adapted for use with 32-bit processors and/or processors |
| 9057 | // with a POPCNT instruction, but leave that for later. |
| 9058 | p -= (p >> 1) & mask1; |
| 9059 | p = (p & mask2) + ((p >> 2) & mask2); |
| 9060 | p += p >> 4; |
| 9061 | p &= mask3; |
| 9062 | p *= 0x0101010101010101ULL; |
| 9063 | p >>= 56; |
| 9064 | return (int)p; |
| 9065 | } |
| 9066 | else |
| 9067 | #endif |
| 9068 | { |
| 9069 | uint32_t mask1 = 0x55555555U; |
| 9070 | uint32_t mask2 = 0x33333333U; |
| 9071 | uint32_t mask3 = 0x0F0F0F0FU; |
| 9072 | |
| 9073 | // on 32-bit processor, split the 64-bit input argument in two, |
| 9074 | // and bitcount each half separately. |
| 9075 | uint32_t p1 = (uint32_t)p; |
| 9076 | |
| 9077 | p1 = p1 - ((p1 >> 1) & mask1); |
| 9078 | p1 = (p1 & mask2) + ((p1 >> 2) & mask2); |
| 9079 | p1 += p1 >> 4; |
| 9080 | p1 &= mask3; |
| 9081 | |
| 9082 | #ifdef ENABLE_64Bit_Support |
| 9083 | uint32_t p2 = (uint32_t)(p >> 32); |
| 9084 | p2 = p2 - ((p2 >> 1) & mask1); |
| 9085 | p2 = (p2 & mask2) + ((p2 >> 2) & mask2); |
| 9086 | p2 += p2 >> 4; |
| 9087 | p2 &= mask3; |
| 9088 | p1 += p2; |
| 9089 | #endif |
| 9090 | p1 *= 0x01010101U; |
| 9091 | p1 >>= 24; |
| 9092 | return (int)p1; |
| 9093 | } |
| 9094 | } |
| 9095 | |
| 9096 | //static inline |
| 9097 | int MIN3(int a, int b, int c) |
no outgoing calls
no test coverage detected