Unify gauss and zipf/pareto input values
authorJens Axboe <axboe@fb.com>
Wed, 8 Apr 2015 21:49:18 +0000 (15:49 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 8 Apr 2015 21:49:18 +0000 (15:49 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
cconv.c
filesetup.c
lib/gauss.c
lib/gauss.h
options.c
thread_options.h

diff --git a/cconv.c b/cconv.c
index fbe784e7e2ff281001dc30ba416f65845a6bebf5..68f119f18c2f4312a5dfca7d9b850bebb80c8b9b 100644 (file)
--- a/cconv.c
+++ b/cconv.c
@@ -163,9 +163,9 @@ void convert_thread_options_to_cpu(struct thread_options *o,
        o->fsync_on_close = le32_to_cpu(top->fsync_on_close);
        o->bs_is_seq_rand = le32_to_cpu(top->bs_is_seq_rand);
        o->random_distribution = le32_to_cpu(top->random_distribution);
-       o->gauss_dev = le32_to_cpu(top->gauss_dev);
        o->zipf_theta.u.f = fio_uint64_to_double(le64_to_cpu(top->zipf_theta.u.i));
        o->pareto_h.u.f = fio_uint64_to_double(le64_to_cpu(top->pareto_h.u.i));
+       o->gauss_dev.u.f = fio_uint64_to_double(le64_to_cpu(top->gauss_dev.u.i));
        o->random_generator = le32_to_cpu(top->random_generator);
        o->hugepage_size = le32_to_cpu(top->hugepage_size);
        o->rw_min_bs = le32_to_cpu(top->rw_min_bs);
@@ -338,9 +338,9 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
        top->fsync_on_close = cpu_to_le32(o->fsync_on_close);
        top->bs_is_seq_rand = cpu_to_le32(o->bs_is_seq_rand);
        top->random_distribution = cpu_to_le32(o->random_distribution);
-       top->gauss_dev = cpu_to_le32(o->gauss_dev);
        top->zipf_theta.u.i = __cpu_to_le64(fio_double_to_uint64(o->zipf_theta.u.f));
        top->pareto_h.u.i = __cpu_to_le64(fio_double_to_uint64(o->pareto_h.u.f));
+       top->gauss_dev.u.i = __cpu_to_le64(fio_double_to_uint64(o->gauss_dev.u.f));
        top->random_generator = cpu_to_le32(o->random_generator);
        top->hugepage_size = cpu_to_le32(o->hugepage_size);
        top->rw_min_bs = cpu_to_le32(o->rw_min_bs);
index 7dceddbbf4dc21077d312dace3fa2321ba04f037..09e877f639809689e9c95c86112d945ba954c7bc 100644 (file)
@@ -1001,7 +1001,7 @@ static int __init_rand_distribution(struct thread_data *td, struct fio_file *f)
        else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
                pareto_init(&f->zipf, nranges, td->o.pareto_h.u.f, seed);
        else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
-               gauss_init(&f->gauss, nranges, td->o.gauss_dev, seed);
+               gauss_init(&f->gauss, nranges, td->o.gauss_dev.u.f, seed);
 
        return 1;
 }
index 5c3203c05754b8ae52b57aee6393b441a16050bc..1bb6c41d9ab035b12ef3a3e7c7290679f472f823 100644 (file)
@@ -41,14 +41,15 @@ unsigned long long gauss_next(struct gauss_state *gs)
        return __hash_u64(sum) % gs->nranges;
 }
 
-void gauss_init(struct gauss_state *gs, unsigned long nranges, unsigned int d,
+void gauss_init(struct gauss_state *gs, unsigned long nranges, double dev,
                unsigned int seed)
 {
        memset(gs, 0, sizeof(*gs));
        init_rand_seed(&gs->r, seed);
        gs->nranges = nranges;
-       if (d) {
-               gs->stddev = (nranges * 100) / d;
+
+       if (dev != 0.0) {
+               gs->stddev = ceil((double) (nranges * 100.0) / dev);
                if (gs->stddev > nranges / 2)
                        gs->stddev = nranges / 2;
        }
index be45249c4cbab662eab928c5f4abbba92b25f2ce..a76df3f27206a46dfe2e3ff5741bfdce37c518a5 100644 (file)
@@ -10,7 +10,7 @@ struct gauss_state {
        unsigned int stddev;
 };
 
-void gauss_init(struct gauss_state *gs, unsigned long nranges, unsigned int d,
+void gauss_init(struct gauss_state *gs, unsigned long nranges, double dev,
                unsigned int seed);
 unsigned long long gauss_next(struct gauss_state *gs);
 
index fbb291b73f65d2b069bc62faae5a61d2d7be5d3a..95e0e0c92f4c4df6fac94b97be9c9034187c3c03 100644 (file)
--- a/options.c
+++ b/options.c
@@ -749,7 +749,7 @@ static int str_random_distribution_cb(void *data, const char *str)
                        log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
                        return 1;
                }
-               td->o.gauss_dev = val;
+               td->o.gauss_dev.u.f = val;
        }
 
        return 0;
index 693180664b1fa6f6307e2a07e51be296a779644d..ee1114d1f8ee234e662f1e96944f9ee2e00f46af 100644 (file)
@@ -126,10 +126,10 @@ struct thread_options {
        unsigned int verify_only;
 
        unsigned int random_distribution;
-       unsigned int gauss_dev;
 
        fio_fp64_t zipf_theta;
        fio_fp64_t pareto_h;
+       fio_fp64_t gauss_dev;
 
        unsigned int random_generator;
 
@@ -355,9 +355,11 @@ struct thread_options_pack {
        uint32_t bs_is_seq_rand;
 
        uint32_t random_distribution;
-       uint32_t gauss_dev;
+       uint32_t pad;
+
        fio_fp64_t zipf_theta;
        fio_fp64_t pareto_h;
+       fio_fp64_t gauss_dev;
 
        uint32_t random_generator;