static void fill(int64_t *dst, const int size, int type) { switch (type) { case FILL_SORTED: fill_sorted(dst, size); break; case FILL_SORTED_10: fill_sorted_blocks(dst, size, 10); break; case FILL_SORTED_100: fill_sorted_blocks(dst, size, 100); break; case FILL_SORTED_10000: fill_sorted_blocks(dst, size, 10000); break; case FILL_SWAPPED_N2: fill_swapped(dst, size, size/2); break; case FILL_SWAPPED_N8: fill_swapped(dst, size, size/8); case FILL_RANDOM: default: fill_random(dst, size); break; } }
static void fill_swapped(int64_t *dst, const int size, const int swapped_cnt) { int i, tmp; size_t ind1 = 0; size_t ind2 = 0; fill_sorted(dst, size); for (i = 0; i < swapped_cnt; i++) { ind1 = lrand48(); RAND_RANGE(ind1, 0, size); ind2 = lrand48(); RAND_RANGE(ind2, 0, size); } tmp = dst[ind1]; dst[ind1] = dst[ind2]; dst[ind2] = tmp; }