summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gauss.c10
-rw-r--r--lib/gauss.h2
-rw-r--r--lib/zipf.c15
-rw-r--r--lib/zipf.h2
4 files changed, 26 insertions, 3 deletions
diff --git a/lib/gauss.c b/lib/gauss.c
index afd0490d..48e2fbfe 100644
--- a/lib/gauss.c
+++ b/lib/gauss.c
@@ -38,7 +38,10 @@ unsigned long long gauss_next(struct gauss_state *gs)
sum += dev;
}
- return __hash_u64(sum) % gs->nranges;
+ if (!gs->disable_hash)
+ return __hash_u64(sum) % gs->nranges;
+
+ return sum % gs->nranges;
}
void gauss_init(struct gauss_state *gs, unsigned long nranges, double dev,
@@ -54,3 +57,8 @@ void gauss_init(struct gauss_state *gs, unsigned long nranges, double dev,
gs->stddev = nranges / 2;
}
}
+
+void gauss_disable_hash(struct gauss_state *gs)
+{
+ gs->disable_hash = true;
+}
diff --git a/lib/gauss.h b/lib/gauss.h
index a76df3f2..478aa146 100644
--- a/lib/gauss.h
+++ b/lib/gauss.h
@@ -8,10 +8,12 @@ struct gauss_state {
struct frand_state r;
uint64_t nranges;
unsigned int stddev;
+ bool disable_hash;
};
void gauss_init(struct gauss_state *gs, unsigned long nranges, double dev,
unsigned int seed);
unsigned long long gauss_next(struct gauss_state *gs);
+void gauss_disable_hash(struct gauss_state *gs);
#endif
diff --git a/lib/zipf.c b/lib/zipf.c
index d8e72b15..8b581faf 100644
--- a/lib/zipf.c
+++ b/lib/zipf.c
@@ -69,7 +69,10 @@ unsigned long long zipf_next(struct zipf_state *zs)
else
val = 1 + (unsigned long long)(n * pow(eta*rand_uni - eta + 1.0, alpha));
- return (__hash_u64(val - 1) + zs->rand_off) % zs->nranges;
+ if (!zs->disable_hash)
+ return (__hash_u64(val - 1) + zs->rand_off) % zs->nranges;
+
+ return (val - 1 + zs->rand_off) % zs->nranges;
}
void pareto_init(struct zipf_state *zs, unsigned long nranges, double h,
@@ -84,5 +87,13 @@ unsigned long long pareto_next(struct zipf_state *zs)
double rand = (double) __rand(&zs->rand) / (double) FRAND32_MAX;
unsigned long long n = zs->nranges - 1;
- return (__hash_u64(n * pow(rand, zs->pareto_pow)) + zs->rand_off) % zs->nranges;
+ if (!zs->disable_hash)
+ return (__hash_u64(n * pow(rand, zs->pareto_pow)) + zs->rand_off) % zs->nranges;
+
+ return (unsigned long long) (n * pow(rand, zs->pareto_pow) + zs->rand_off) % zs->nranges;
+}
+
+void zipf_disable_hash(struct zipf_state *zs)
+{
+ zs->disable_hash = true;
}
diff --git a/lib/zipf.h b/lib/zipf.h
index f98ad818..af2d0e64 100644
--- a/lib/zipf.h
+++ b/lib/zipf.h
@@ -12,6 +12,7 @@ struct zipf_state {
double pareto_pow;
struct frand_state rand;
uint64_t rand_off;
+ bool disable_hash;
};
void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta, unsigned int seed);
@@ -19,5 +20,6 @@ unsigned long long zipf_next(struct zipf_state *zs);
void pareto_init(struct zipf_state *zs, unsigned long nranges, double h, unsigned int seed);
unsigned long long pareto_next(struct zipf_state *zs);
+void zipf_disable_hash(struct zipf_state *zs);
#endif