#ifdef __aarch64__
-std::vector<Benchmark> aarch64_benchmarks(Config config)
+std::vector<Benchmark> aarch64_benchmarks(const Config &config)
{
std::vector<Benchmark> retval;
// TODO: add aarch64 benchmarks
#else
-std::vector<Benchmark> aarch64_benchmarks(Config)
+std::vector<Benchmark> aarch64_benchmarks(const Config &)
{
return {};
}
-#endif
\ No newline at end of file
+#endif
#include "../harness.h"
-std::vector<Benchmark> aarch64_benchmarks(Config config);
\ No newline at end of file
+std::vector<Benchmark> aarch64_benchmarks(const Config &config);
#include <algorithm>
#include <iterator>
-std::vector<Benchmark> all_benchmarks(Config config)
+std::vector<Benchmark> all_benchmarks(const Config &config)
{
std::vector<Benchmark> retval = common_benchmarks(config);
{
std::back_inserter(retval));
}
return retval;
-}
\ No newline at end of file
+}
#include "harness.h"
-std::vector<Benchmark> all_benchmarks(Config config);
\ No newline at end of file
+std::vector<Benchmark> all_benchmarks(const Config &config);
template <typename T> using Buf = std::shared_ptr<std::vector<std::atomic<T>>>;
template <typename Fn, typename T, typename... NameParts>
-static void push_atomic_bench(std::vector<Benchmark> &benches, Config config,
- Buf<T> buf, Fn fn, NameParts &&...name_parts)
+static void push_atomic_bench(std::vector<Benchmark> &benches,
+ const Config &config, Buf<T> buf, Fn fn,
+ NameParts &&...name_parts)
{
auto log2_stride = config.log2_stride;
std::size_t index_mask = 1;
}
template <typename T, std::memory_order order>
-static void rmw_benchmarks(std::vector<Benchmark> &benches, Config config,
- Buf<T> buf)
+static void rmw_benchmarks(std::vector<Benchmark> &benches,
+ const Config &config, Buf<T> buf)
{
push_atomic_bench(
benches, config, buf,
}
template <typename T, std::memory_order order>
-static void load_benchmarks(std::vector<Benchmark> &benches, Config config,
- Buf<T> buf)
+static void load_benchmarks(std::vector<Benchmark> &benches,
+ const Config &config, Buf<T> buf)
{
push_atomic_bench(
benches, config, buf,
}
template <typename T, std::memory_order order>
-static void store_benchmarks(std::vector<Benchmark> &benches, Config config,
- Buf<T> buf)
+static void store_benchmarks(std::vector<Benchmark> &benches,
+ const Config &config, Buf<T> buf)
{
push_atomic_bench(
benches, config, buf,
}
template <typename T, std::memory_order succ, std::memory_order fail>
-static void cmp_xchg_benchmarks(std::vector<Benchmark> &benches, Config config,
- Buf<T> buf)
+static void cmp_xchg_benchmarks(std::vector<Benchmark> &benches,
+ const Config &config, Buf<T> buf)
{
push_atomic_bench(
benches, config, buf,
}
template <typename T>
-static void benchmarks(std::vector<Benchmark> &benches, Config config)
+static void benchmarks(std::vector<Benchmark> &benches, const Config &config)
{
std::size_t buf_size = 1;
buf_size <<= config.log2_memory_location_count;
std::memory_order_seq_cst>(benches, config, buf);
}
-std::vector<Benchmark> c11_atomics_benchmarks(Config config)
+std::vector<Benchmark> c11_atomics_benchmarks(const Config &config)
{
std::vector<Benchmark> benches;
benchmarks<std::uint8_t>(benches, config);
#include "../../harness.h"
-std::vector<Benchmark> c11_atomics_benchmarks(Config config);
\ No newline at end of file
+std::vector<Benchmark> c11_atomics_benchmarks(const Config &config);
#include "common_benchmarks.h"
#include "c11_atomics/c11_atomics_benchmarks.h"
-std::vector<Benchmark> common_benchmarks(Config config)
+std::vector<Benchmark> common_benchmarks(const Config &config)
{
auto retval = c11_atomics_benchmarks(config);
return retval;
-}
\ No newline at end of file
+}
#include "../harness.h"
-std::vector<Benchmark> common_benchmarks(Config config);
\ No newline at end of file
+std::vector<Benchmark> common_benchmarks(const Config &config);
};
void BenchHarnessBase::base_run(
- Config config,
+ const Config &config,
void (*fn)(BenchHarnessBase *bench_harness_base,
std::uint64_t iteration_count, std::uint32_t thread_num))
{
std::shared_ptr<void> BenchHarnessBase::get_thread_cache()
{
return ThreadCache::get();
-}
\ No newline at end of file
+}
std::shared_ptr<void> thread_cache;
class ThreadCache;
friend class ThreadCache;
- void base_run(Config config,
+ void base_run(const Config &config,
void (*fn)(BenchHarnessBase *bench_harness_base,
std::uint64_t iteration_count,
std::uint32_t thread_num));
: fn(std::move(fn)), input(std::move(input))
{
}
- void run(Config config)
+ void run(const Config &config)
{
base_run(config, [](BenchHarnessBase *bench_harness_base,
std::uint64_t iteration_count,
{
private:
std::string m_name;
- std::function<void(Config config)> m_run;
+ std::function<void(const Config &config)> m_run;
public:
template <typename Fn, typename Input>
explicit Benchmark(Fn fn, Input input, std::string name)
- : m_name(std::move(name)), m_run([fn, input](Config config) {
+ : m_name(std::move(name)), m_run([fn, input](const Config &config) {
return BenchHarness(std::move(fn), std::move(input)).run(config);
})
{
}
- void run(Config config)
+ void run(const Config &config)
{
return m_run(config);
}
#if defined(__powerpc64__) && BYTE_ORDER == LITTLE_ENDIAN
-std::vector<Benchmark> powerpc64le_benchmarks(Config config)
+std::vector<Benchmark> powerpc64le_benchmarks(const Config &config)
{
std::vector<Benchmark> retval;
// TODO: add powerpc64le benchmarks
#else
-std::vector<Benchmark> powerpc64le_benchmarks(Config)
+std::vector<Benchmark> powerpc64le_benchmarks(const Config &)
{
return {};
}
-#endif
\ No newline at end of file
+#endif
#include "../harness.h"
-std::vector<Benchmark> powerpc64le_benchmarks(Config config);
\ No newline at end of file
+std::vector<Benchmark> powerpc64le_benchmarks(const Config &config);
#ifdef __x86_64__
-std::vector<Benchmark> x86_64_benchmarks(Config config)
+std::vector<Benchmark> x86_64_benchmarks(const Config &config)
{
std::vector<Benchmark> retval;
// TODO: add x86_64 benchmarks
#else
-std::vector<Benchmark> x86_64_benchmarks(Config)
+std::vector<Benchmark> x86_64_benchmarks(const Config &)
{
return {};
}
-#endif
\ No newline at end of file
+#endif
#include "../harness.h"
-std::vector<Benchmark> x86_64_benchmarks(Config config);
\ No newline at end of file
+std::vector<Benchmark> x86_64_benchmarks(const Config &config);