File: benchmark.cpp

package info (click to toggle)
xenium 0.0.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,088 kB
  • sloc: cpp: 12,297; makefile: 20
file content (35 lines) | stat: -rw-r--r-- 920 bytes parent folder | download | duplicates (3)
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
#include "benchmark.hpp"
#include "execution.hpp"

#include <tao/config/value.hpp>

using config_t = tao::config::value;

namespace config {
  void prefill::setup(const config_t& config, std::uint64_t default_count) {
    count = default_count;
    auto node = config.find("prefill");
    if (node) {
      if (node->is_integer()) {
        count = node->get_unsigned();
      } else {
        serial = node->optional<bool>("serial").value_or(false);
        count = node->optional<std::uint64_t>("count").value_or(count);
      }
    }
  }

  std::uint64_t prefill::get_thread_quota(std::uint32_t thread_id, std::uint32_t num_threads) {
    thread_id &= execution::thread_id_mask;
    std::uint64_t result = 0;
    if (serial) {
      if (thread_id == 0)
        result = count;
    } else {
      result = count / num_threads;
      if (thread_id < count % num_threads)
        ++result;
    }
    return result;
  }
}