Compute the register histogram in the dense representation. */
| 519 | |
| 520 | /* Compute the register histogram in the dense representation. */ |
| 521 | void hllDenseRegHisto(uint8_t *registers, int* reghisto) { |
| 522 | int j; |
| 523 | |
| 524 | /* Redis default is to use 16384 registers 6 bits each. The code works |
| 525 | * with other values by modifying the defines, but for our target value |
| 526 | * we take a faster path with unrolled loops. */ |
| 527 | if (HLL_REGISTERS == 16384 && HLL_BITS == 6) { |
| 528 | uint8_t *r = registers; |
| 529 | unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, |
| 530 | r10, r11, r12, r13, r14, r15; |
| 531 | for (j = 0; j < 1024; j++) { |
| 532 | /* Handle 16 registers per iteration. */ |
| 533 | r0 = r[0] & 63; |
| 534 | r1 = (r[0] >> 6 | r[1] << 2) & 63; |
| 535 | r2 = (r[1] >> 4 | r[2] << 4) & 63; |
| 536 | r3 = (r[2] >> 2) & 63; |
| 537 | r4 = r[3] & 63; |
| 538 | r5 = (r[3] >> 6 | r[4] << 2) & 63; |
| 539 | r6 = (r[4] >> 4 | r[5] << 4) & 63; |
| 540 | r7 = (r[5] >> 2) & 63; |
| 541 | r8 = r[6] & 63; |
| 542 | r9 = (r[6] >> 6 | r[7] << 2) & 63; |
| 543 | r10 = (r[7] >> 4 | r[8] << 4) & 63; |
| 544 | r11 = (r[8] >> 2) & 63; |
| 545 | r12 = r[9] & 63; |
| 546 | r13 = (r[9] >> 6 | r[10] << 2) & 63; |
| 547 | r14 = (r[10] >> 4 | r[11] << 4) & 63; |
| 548 | r15 = (r[11] >> 2) & 63; |
| 549 | |
| 550 | reghisto[r0]++; |
| 551 | reghisto[r1]++; |
| 552 | reghisto[r2]++; |
| 553 | reghisto[r3]++; |
| 554 | reghisto[r4]++; |
| 555 | reghisto[r5]++; |
| 556 | reghisto[r6]++; |
| 557 | reghisto[r7]++; |
| 558 | reghisto[r8]++; |
| 559 | reghisto[r9]++; |
| 560 | reghisto[r10]++; |
| 561 | reghisto[r11]++; |
| 562 | reghisto[r12]++; |
| 563 | reghisto[r13]++; |
| 564 | reghisto[r14]++; |
| 565 | reghisto[r15]++; |
| 566 | |
| 567 | r += 12; |
| 568 | } |
| 569 | } else { |
| 570 | for(j = 0; j < HLL_REGISTERS; j++) { |
| 571 | unsigned long reg; |
| 572 | HLL_DENSE_GET_REGISTER(reg,registers,j); |
| 573 | reghisto[reg]++; |
| 574 | } |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | /* ================== Sparse representation implementation ================= */ |