int write_ops = 0;
for (off = 0; off < io_bytes; ) {
+ // Issue I/O
i = 0;
while (i < io_threads && off < io_bytes) {
bool read_flag = should_read(read_proportion);
b.wait_for(io_threads - 1);
b.start_io(io_threads, thread_offset[i], io_size, op_flags, read_flag);
- if (random) {
- thread_offset[i] = (rand() % (size / io_size)) * io_size;
- } else {
- thread_offset[i] += io_size;
- if (thread_offset[i] + io_size > size)
- thread_offset[i] = 0;
- }
++i;
++ios;
off += io_size;
write_ops++;
}
+ // Set the thread_offsets of next I/O
+ for (i = 0; i < io_threads; ++i) {
+ if (random) {
+ thread_offset[i] = (rand() % (size / io_size)) * io_size;
+ continue;
+ }
+ if (off < (io_size * unit_len * io_threads) ) {
+ thread_offset[i] += io_size;
+ } else {
+ // thread_offset is adjusted to the chunks unassigned to threads.
+ thread_offset[i] = off + (i * io_size);
+ }
+ if (thread_offset[i] + io_size > size)
+ thread_offset[i] = unit_len * i * io_size;
+ }
+
coarse_mono_time now = coarse_mono_clock::now();
chrono::duration<double> elapsed = now - start;
if (last == chrono::duration<double>::zero()) {