t/nvmept_trim: increase transfer size for some tests
[fio.git] / lib / zipf.c
index 1ff8568094dcecc34ad8350b9f364051de756dd5..14d7928f664a0dfadf8d005e5c87414407cc91fa 100644 (file)
@@ -8,7 +8,7 @@
 
 static void zipf_update(struct zipf_state *zs)
 {
-       unsigned long to_gen;
+       uint64_t to_gen;
        unsigned int i;
 
        /*
@@ -22,20 +22,22 @@ static void zipf_update(struct zipf_state *zs)
                zs->zetan += pow(1.0 / (double) (i + 1), zs->theta);
 }
 
-static void shared_rand_init(struct zipf_state *zs, unsigned long nranges,
-                            unsigned int seed)
+static void shared_rand_init(struct zipf_state *zs, uint64_t nranges,
+                            double center, unsigned int seed)
 {
        memset(zs, 0, sizeof(*zs));
        zs->nranges = nranges;
 
        init_rand_seed(&zs->rand, seed, 0);
        zs->rand_off = __rand(&zs->rand);
+       if (center != -1)
+               zs->rand_off = nranges * center;
 }
 
-void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta,
-              unsigned int seed)
+void zipf_init(struct zipf_state *zs, uint64_t nranges, double theta,
+              double center, unsigned int seed)
 {
-       shared_rand_init(zs, nranges, seed);
+       shared_rand_init(zs, nranges, center, seed);
 
        zs->theta = theta;
        zs->zeta2 = pow(1.0, zs->theta) + pow(0.5, zs->theta);
@@ -43,7 +45,7 @@ void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta,
        zipf_update(zs);
 }
 
-unsigned long long zipf_next(struct zipf_state *zs)
+uint64_t zipf_next(struct zipf_state *zs)
 {
        double alpha, eta, rand_uni, rand_z;
        unsigned long long n = zs->nranges;
@@ -70,14 +72,14 @@ unsigned long long zipf_next(struct zipf_state *zs)
        return (val + zs->rand_off) % zs->nranges;
 }
 
-void pareto_init(struct zipf_state *zs, unsigned long nranges, double h,
-                unsigned int seed)
+void pareto_init(struct zipf_state *zs, uint64_t nranges, double h,
+                double center, unsigned int seed)
 {
-       shared_rand_init(zs, nranges, seed);
+       shared_rand_init(zs, nranges, center, seed);
        zs->pareto_pow = log(h) / log(1.0 - h);
 }
 
-unsigned long long pareto_next(struct zipf_state *zs)
+uint64_t pareto_next(struct zipf_state *zs)
 {
        double rand = (double) __rand(&zs->rand) / (double) FRAND32_MAX;
        unsigned long long n;