-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathworkload.cc
More file actions
52 lines (44 loc) · 1.49 KB
/
workload.cc
File metadata and controls
52 lines (44 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <aio.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "opts.hpp"
#include "utils.hpp"
#include "workload.hpp"
int is_done(off64_t offset, workload_config_t *config)
{
if(config->workload == wl_rnd)
return 0;
if(config->workload == wl_seq && config->operation == op_write && config->direction == opd_forward)
return 0;
if(config->direction == opd_forward) {
return offset >= config->offset + config->length;
} else if(config->direction == opd_backward) {
return offset < config->device_length - config->offset - config->length;
}
return 0;
}
off64_t prepare_offset(long long ops, rnd_gen_t rnd_gen, workload_config_t *config)
{
off64_t offset = -1;
// Setup the offset
if(config->workload == wl_rnd) {
offset = config->offset +
(get_random(rnd_gen, config->dist, config->length, config->sigma)
/ config->stride * config->stride);
} else if(config->workload == wl_seq) {
if(config->direction == opd_forward)
offset = config->offset + ops * config->stride;
else if(config->direction == opd_backward) {
size_t boundary = config->device_length - config->offset;
boundary = boundary / 512 * 512;
offset = boundary - config->block_size - ops * config->stride;
}
}
return offset;
}