From 88cf7c69049f030ad80005becfbbc863b4c4cd1c Mon Sep 17 00:00:00 2001 From: mancini <mancini@astron.nl> Date: Thu, 6 Feb 2025 13:58:29 +0100 Subject: [PATCH] Fix memory test --- benchmarks/access_to_memory.cpp | 2 ++ benchmarks/matrix_multiplication.cpp | 2 ++ code/access_to_memory.h | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/benchmarks/access_to_memory.cpp b/benchmarks/access_to_memory.cpp index 1cdc1a1..372ddc4 100644 --- a/benchmarks/access_to_memory.cpp +++ b/benchmarks/access_to_memory.cpp @@ -5,6 +5,7 @@ #include <memory> constexpr size_t MB = 1024 * 1024; +namespace { class InitializeInput : public benchmark::Fixture { public: void SetUp(::benchmark::State& state) { @@ -31,6 +32,7 @@ class InitializeInput : public benchmark::Fixture { float* B; size_t array_size; }; +} // namespace BENCHMARK_F(InitializeInput, MemoryAccessRandomAccessData) (benchmark::State& state) { diff --git a/benchmarks/matrix_multiplication.cpp b/benchmarks/matrix_multiplication.cpp index 75a058d..fb33ae1 100644 --- a/benchmarks/matrix_multiplication.cpp +++ b/benchmarks/matrix_multiplication.cpp @@ -1,6 +1,7 @@ #include <benchmark/benchmark.h> #include <matrix_multiplication.h> +namespace { class InitializeInput : public benchmark::Fixture { public: void SetUp(::benchmark::State& state) { @@ -25,6 +26,7 @@ class InitializeInput : public benchmark::Fixture { std::complex<float>* B; std::complex<float>* C; }; +} // namespace // Reference standard BENCHMARK_F(InitializeInput, MatrixMultiplicationReference) diff --git a/code/access_to_memory.h b/code/access_to_memory.h index f4bda63..8d8375e 100644 --- a/code/access_to_memory.h +++ b/code/access_to_memory.h @@ -6,8 +6,9 @@ inline void Initialize(float* a, size_t size) { // Initialize matrices with random complex values - std::random_device rd; - std::mt19937 gen(rd()); + std::seed_seq seed({42}); + std::mt19937 gen(seed); + std::uniform_real_distribution<float> dis(-1.0, 1.0); for (size_t i = 0; i < size; i++) { a[i] = dis(gen); -- GitLab