Created
August 2, 2011 05:32
-
-
Save chadbrewbaker/1119642 to your computer and use it in GitHub Desktop.
Simple radix histogram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Simple radix histogram | |
// | |
#include <string.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#define HIST_SIZE 2048 | |
#define _0(v) ((v) & 0x7FF) | |
#define _1(v) (((v) >> 11) & 0x7FF) | |
#define _2(v) (((v) >> 22) & 0x7FF) | |
#define _3(v) (((v) >> 33) & 0x7FF) | |
#define _4(v) (((v) >> 44) & 0x7FF) | |
#define _5(v) (((v) >> 55) & 0x7FF) | |
template <class T> | |
void run_test64_11(T* a, T* b0, size_t sz){ | |
T* dest; | |
size_t j; | |
size_t pos; | |
size_t n, sum0=0,sum1=0,sum2=0,sum3=0,sum4=0,sum5=0,tsum=0; | |
T *b1, *b2, *b3, *b4, *b5; | |
b1 = b0 + HIST_SIZE; | |
b2 = b1 + HIST_SIZE; | |
b3 = b2 + HIST_SIZE; | |
b4 = b3 + HIST_SIZE; | |
b5 = b4 + HIST_SIZE; | |
memset(b0,0,6 * HIST_SIZE*sizeof(T)); | |
for (n=0; n < sz; n++) { | |
b0[_0(a[n])]++; | |
b1[_1(a[n])]++; | |
b2[_2(a[n])]++; | |
b3[_3(a[n])]++; | |
b4[_4(a[n])]++; | |
b5[_5(a[n])]++; | |
} | |
return; | |
}; | |
int main(){ | |
int i; | |
size_t sz = 10000000; | |
uint64_t* a; | |
uint64_t* b0; | |
a = (uint64_t*)malloc(sizeof(uint64_t)*sz); | |
b0 = (uint64_t*) malloc(HIST_SIZE * 6 * sizeof(uint64_t)); | |
for(i=0;i<40;i++){ | |
run_test64_11<uint64_t>(a, b0, sz); | |
} | |
free(a); | |
free(b0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment