diff --git a/app/benchmark_matrix_then_fft/main.cpp b/app/benchmark_matrix_then_fft/main.cpp index 2e12eb1..c6b8688 100644 --- a/app/benchmark_matrix_then_fft/main.cpp +++ b/app/benchmark_matrix_then_fft/main.cpp @@ -45,9 +45,9 @@ int main(int argc, char **argv) { fft::complex_vector fft_data(fft_size); fft::complex_vector fft_swap_array(fft_size); fft::fill_input(fft_data); - matrix::matrix matrix_a{settings.size_}; - matrix::matrix matrix_b{settings.size_}; - matrix::matrix matrix_result{settings.size_}; + matrix::matrix matrix_a{matrix_size}; + matrix::matrix matrix_b{matrix_size}; + matrix::matrix matrix_result{matrix_size}; if (settings.type_ == benchmark_runner::benchmark_settings::ISOLATED) { #if PLS_PROFILING_ENABLED diff --git a/app/context_switch/main.cpp b/app/context_switch/main.cpp index 97e72bd..5d69475 100644 --- a/app/context_switch/main.cpp +++ b/app/context_switch/main.cpp @@ -27,6 +27,7 @@ void custom_stack_callback(void *); void __attribute__ ((noinline)) callback() { static volatile int tmp; tmp = 0; // Force at least a single memory write + (void) tmp; } } @@ -35,6 +36,7 @@ long measure_loop() { volatile int tmp; for (unsigned int i = 0; i < NUM_RUNS; i++) { tmp = 0; + (void) tmp; } auto end_time = chrono::steady_clock::now(); return chrono::duration_cast(end_time - start_time).count(); diff --git a/extern/benchmark_base/include/benchmark_base/matrix.h b/extern/benchmark_base/include/benchmark_base/matrix.h index 3144baa..8d09e77 100644 --- a/extern/benchmark_base/include/benchmark_base/matrix.h +++ b/extern/benchmark_base/include/benchmark_base/matrix.h @@ -29,36 +29,36 @@ class matrix { } explicit matrix(size_t size) : size_{size}, data_(size * size) { - for (int i = 0; i < size_; i++) { - for (int j = 0; j < size_; j++) { + for (size_t i = 0; i < size_; i++) { + for (size_t j = 0; j < size_; j++) { data_at(i, j) = i; } } } virtual void multiply(const matrix &a, const matrix &b) { - for (int i = 0; i < size_; i++) { + for (size_t i = 0; i < size_; i++) { multiply_column(i, a, b); } } protected: void multiply_column(int i, const matrix &a, const matrix &b) { - for (int j = 0; j < size_; ++j) { + for (size_t j = 0; j < size_; ++j) { data_at(i, j) = 0; } - for (int k = 0; k < size_; ++k) { - for (int j = 0; j < size_; ++j) { + for (size_t k = 0; k < size_; ++k) { + for (size_t j = 0; j < size_; ++j) { data_at(i, j) += a.data_at(i, k) * b.data_at(i, k); } } } }; -template +template std::ostream &operator<<(std::ostream &strm, const matrix &matrix) { - for (int i = 0; i < SIZE; i++) { - for (int j = 0; j < SIZE; j++) { + for (size_t i = 0; i < matrix.size_; i++) { + for (size_t j = 0; j < matrix.size_; j++) { strm << matrix.data_at(i, j) << "\t"; } strm << std::endl; diff --git a/lib/pls/include/pls/algorithms/for_each_impl.h b/lib/pls/include/pls/algorithms/for_each_impl.h index 9ba4479..a471eee 100644 --- a/lib/pls/include/pls/algorithms/for_each_impl.h +++ b/lib/pls/include/pls/algorithms/for_each_impl.h @@ -13,10 +13,10 @@ template static void for_each_iterator(const RandomIt first, const RandomIt last, const Function &function, - const size_t min_elements) { + const long min_elements) { using namespace ::pls::internal::scheduling; - const long num_elements = std::distance(first, last); + const auto num_elements = std::distance(first, last); if (num_elements <= min_elements) { // calculate last elements in loop to avoid overhead for (auto current = first; current != last; current++) { @@ -45,10 +45,10 @@ template static void for_each_range(const long first, const long last, const Function &function, - const size_t min_elements) { + const long min_elements) { using namespace ::pls::internal::scheduling; - const long num_elements = last - first; + const auto num_elements = last - first; if (num_elements <= min_elements) { // calculate last elements in loop to avoid overhead for (auto current = first; current != last; current++) { diff --git a/lib/pls/include/pls/pls.h b/lib/pls/include/pls/pls.h index 7f5895c..db6bf92 100644 --- a/lib/pls/include/pls/pls.h +++ b/lib/pls/include/pls/pls.h @@ -22,18 +22,18 @@ using internal::scheduling::scheduler; using internal::base::heap_stack_allocator; using internal::base::mmap_stack_allocator; template -static void spawn(Function &&function) { +inline void spawn(Function &&function) { scheduler::spawn(std::forward(function)); } template -static void spawn_and_sync(Function &&function) { +inline void spawn_and_sync(Function &&function) { scheduler::spawn_and_sync(std::forward(function)); } -static void sync() { +inline void sync() { scheduler::sync(); } template -static void serial(Function &&function) { +inline void serial(Function &&function) { scheduler::serial(std::forward(function)); } diff --git a/test/scheduling_lock_free_tests.cpp b/test/scheduling_lock_free_tests.cpp index 4c73310..2e48073 100644 --- a/test/scheduling_lock_free_tests.cpp +++ b/test/scheduling_lock_free_tests.cpp @@ -100,9 +100,9 @@ TEST_CASE("external trading deque", "[internal/scheduling/lock_free/external_tra scheduler.task_manager_for(1).get_task(3)}; auto &thread_state_1 = scheduler.thread_state_for(0); - auto &task_manager_1 = scheduler.thread_state_for(0).get_task_manager(); + auto &task_manager_1 = thread_state_1.get_task_manager(); auto &thread_state_2 = scheduler.thread_state_for(1); - auto &task_manager_2 = scheduler.thread_state_for(1).get_task_manager(); + auto &task_manager_2 = thread_state_2.get_task_manager(); SECTION("Must start empty") { REQUIRE(!task_manager_1.pop_local_task());