Commit 998e43af by FritzFlorian

Remove EasyProfiler references.

Remove easy profiler for now. It might be useful for later on to get a grasp of general behaviour, but because of its issues with coroutines it is not worth profiling code with it right now.
parent c2117e94
Pipeline #1471 passed with stages
in 3 minutes 37 seconds
#include "pls/internal/scheduling/scheduler.h" #include "pls/pls.h"
using namespace pls::internal::scheduling; using namespace pls;
#include "benchmark_runner.h" #include "benchmark_runner.h"
#include "benchmark_base/fft.h" #include "benchmark_base/fft.h"
...@@ -20,20 +20,20 @@ void pls_conquer(fft::complex_vector::iterator data, fft::complex_vector::iterat ...@@ -20,20 +20,20 @@ void pls_conquer(fft::complex_vector::iterator data, fft::complex_vector::iterat
fft::conquer(data, swap_array, n / 2); fft::conquer(data, swap_array, n / 2);
fft::conquer(data + n / 2, swap_array + n / 2, n / 2); fft::conquer(data + n / 2, swap_array + n / 2, n / 2);
} else { } else {
scheduler::spawn([data, n, swap_array]() { spawn([data, n, swap_array]() {
pls_conquer(data, swap_array, n / 2); pls_conquer(data, swap_array, n / 2);
}); });
scheduler::spawn([data, n, swap_array]() { spawn([data, n, swap_array]() {
pls_conquer(data + n / 2, swap_array + n / 2, n / 2); pls_conquer(data + n / 2, swap_array + n / 2, n / 2);
}); });
scheduler::sync(); sync();
} }
fft::combine(data, n); fft::combine(data, n);
} }
constexpr int MAX_NUM_TASKS = 32; constexpr int MAX_NUM_TASKS = 16;
constexpr int MAX_STACK_SIZE = 1024 * 4; constexpr int MAX_STACK_SIZE = 4096 * 1;
int main(int argc, char **argv) { int main(int argc, char **argv) {
int num_threads; int num_threads;
......
#include "pls/internal/scheduling/scheduler.h" #include "pls/pls.h"
using namespace pls::internal::scheduling; using namespace pls;
#include <iostream> #include <iostream>
...@@ -18,19 +18,19 @@ int pls_fib(int n) { ...@@ -18,19 +18,19 @@ int pls_fib(int n) {
} }
int a, b; int a, b;
scheduler::spawn([n, &a]() { spawn([n, &a]() {
a = pls_fib(n - 1); a = pls_fib(n - 1);
}); });
scheduler::spawn([n, &b]() { spawn([n, &b]() {
b = pls_fib(n - 2); b = pls_fib(n - 2);
}); });
scheduler::sync(); sync();
return a + b; return a + b;
} }
constexpr int MAX_NUM_TASKS = 32; constexpr int MAX_NUM_TASKS = 32;
constexpr int MAX_STACK_SIZE = 1024 * 32; constexpr int MAX_STACK_SIZE = 4096 * 1;
int main(int argc, char **argv) { int main(int argc, char **argv) {
int num_threads; int num_threads;
......
#include "pls/internal/scheduling/scheduler.h" #include "pls/pls.h"
#include "pls/algorithms/for_each.h"
using namespace pls::internal::scheduling; using namespace pls;
#include "benchmark_runner.h" #include "benchmark_runner.h"
#include "benchmark_base/matrix.h" #include "benchmark_base/matrix.h"
......
...@@ -25,7 +25,7 @@ add_library(pls STATIC ...@@ -25,7 +25,7 @@ add_library(pls STATIC
include/pls/internal/data_structures/optional.h include/pls/internal/data_structures/optional.h
include/pls/internal/helpers/prohibit_new.h include/pls/internal/helpers/prohibit_new.h
include/pls/internal/helpers/profiler.h include/pls/internal/helpers/easy_profiler.h
include/pls/internal/helpers/unique_id.h include/pls/internal/helpers/unique_id.h
include/pls/internal/helpers/range.h include/pls/internal/helpers/range.h
include/pls/internal/helpers/seqence.h include/pls/internal/helpers/seqence.h
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#define PLS_DATAFLOW_INTERNAL_FUNCTION_NODE_IMPL_H_ #define PLS_DATAFLOW_INTERNAL_FUNCTION_NODE_IMPL_H_
#include "graph.h" #include "graph.h"
#include "pls/internal/helpers/profiler.h" #include "pls/internal/helpers/easy_profiler.h"
namespace pls { namespace pls {
namespace dataflow { namespace dataflow {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#ifndef PLS_DATAFLOW_INTERNAL_GRAPH_IMPL_H_ #ifndef PLS_DATAFLOW_INTERNAL_GRAPH_IMPL_H_
#define PLS_DATAFLOW_INTERNAL_GRAPH_IMPL_H_ #define PLS_DATAFLOW_INTERNAL_GRAPH_IMPL_H_
#include "pls/internal/helpers/profiler.h" #include "pls/internal/helpers/easy_profiler.h"
namespace pls { namespace pls {
namespace dataflow { namespace dataflow {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#define PLS_BACKOFF_H_ #define PLS_BACKOFF_H_
#include "pls/internal/base/system_details.h" #include "pls/internal/base/system_details.h"
#include "pls/internal/helpers/profiler.h"
#include <random> #include <random>
#include <thread> #include <thread>
...@@ -30,11 +29,9 @@ class backoff { ...@@ -30,11 +29,9 @@ class backoff {
backoff() : current_{INITIAL_SPIN_ITERS}, random_{std::random_device{}()} {} backoff() : current_{INITIAL_SPIN_ITERS}, random_{std::random_device{}()} {}
void do_backoff() { void do_backoff() {
PROFILE_LOCK("Backoff")
spin(random_() % std::min(current_, MAX_SPIN_ITERS)); spin(random_() % std::min(current_, MAX_SPIN_ITERS));
if (current_ >= YELD_ITERS) { if (current_ >= YELD_ITERS) {
PROFILE_LOCK("Yield")
using namespace std::chrono_literals; using namespace std::chrono_literals;
std::this_thread::sleep_for(5us); std::this_thread::sleep_for(5us);
} }
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include <atomic> #include <atomic>
#include "pls/internal/helpers/profiler.h"
namespace pls { namespace pls {
namespace internal { namespace internal {
namespace base { namespace base {
......
...@@ -6,33 +6,41 @@ ...@@ -6,33 +6,41 @@
#include <easy/profiler.h> #include <easy/profiler.h>
#include <easy/arbitrary_value.h> #include <easy/arbitrary_value.h>
#define PROFILE_TASK(msg) EASY_BLOCK(msg, profiler::colors::LightBlue) // 'bad' events that eat time
#define PROFILE_CONTINUATION(msg) EASY_BLOCK(msg, profiler::colors::LightBlue) #define PROFILE_SYSCALL(msg) EASY_BLOCK(msg, profiler::colors::Red)
#define PROFILE_FAST_PATH(msg) EASY_BLOCK(msg, profiler::colors::Green) #define PROFILE_STEAL(msg) EASY_BLOCK(msg, profiler::colors::Orange)
#define PROFILE_STEALING(msg) EASY_BLOCK(msg, profiler::colors::Orange) #define PROFILE_SCHED(msg) EASY_BLOCK(msg, profiler::colors::Yellow)
#define PROFILE_LOCK(msg) EASY_BLOCK(msg, profiler::colors::Red)
// 'good' events that actually do work
#define PROFILE_WORK(msg) EASY_BLOCK(msg, profiler::colors::Green)
// heplers for saving/initializing
#define PROFILE_END_BLOCK EASY_END_BLOCK #define PROFILE_END_BLOCK EASY_END_BLOCK
#define PROFILE_SAVE(filename) profiler::dumpBlocksToFile(filename); #define PROFILE_SAVE(filename) profiler::dumpBlocksToFile(filename);
#define PROFILE_ENABLE EASY_PROFILER_ENABLE #define PROFILE_ENABLE EASY_PROFILER_ENABLE
#define PROFILE_MAIN_THREAD EASY_MAIN_THREAD #define PROFILE_MAIN_THREAD EASY_MAIN_THREAD
#define PROFILE_WORKER_THREAD EASY_THREAD("Worker")
#define PROFILE_VALUE(name, value) EASY_VALUE(name, value) #define PROFILE_VALUE(name, value) EASY_VALUE(name, value)
#else //ENABLE_EASY_PROFILER #else //ENABLE_EASY_PROFILER
#define PROFILE_TASK(msg) // 'bad' events that eat time
#define PROFILE_CONTINUATION(msg) #define PROFILE_SYSCALL(msg)
#define PROFILE_FAST_PATH(msg) #define PROFILE_STEAL(msg)
#define PROFILE_STEALING(msg) #define PROFILE_SCHED(msg)
#define PROFILE_LOCK(msg)
// 'good' events that actually do work
#define PROFILE_WORK(msg)
// heplers for saving/initializing
#define PROFILE_END_BLOCK #define PROFILE_END_BLOCK
#define PROFILE_SAVE(filename) #define PROFILE_SAVE(filename)
#define PROFILE_ENABLE #define PROFILE_ENABLE
#define PROFILE_MAIN_THREAD #define PROFILE_MAIN_THREAD
#define PROFILE_WORKER_THREAD
#define PROFILE_VALUE(name, value) #define PROFILE_VALUE(name, value)
......
...@@ -86,7 +86,6 @@ class external_trading_deque { ...@@ -86,7 +86,6 @@ class external_trading_deque {
private: private:
void reset_bot_and_top(); void reset_bot_and_top();
void decrease_bot();
// info on this deque // info on this deque
unsigned thread_id_; unsigned thread_id_;
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include "pls/internal/helpers/profiler.h"
#include "pls/internal/base/barrier.h" #include "pls/internal/base/barrier.h"
#include "pls/internal/base/stack_allocator.h" #include "pls/internal/base/stack_allocator.h"
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include "context_switcher/context_switcher.h" #include "context_switcher/context_switcher.h"
#include "context_switcher/continuation.h" #include "context_switcher/continuation.h"
#include "pls/internal/helpers/profiler.h"
#include "pls/internal/scheduling/task_manager.h" #include "pls/internal/scheduling/task_manager.h"
#include "pls/internal/scheduling/base_task.h" #include "pls/internal/scheduling/base_task.h"
#include "base_task.h" #include "base_task.h"
...@@ -65,7 +63,7 @@ class scheduler::init_function_impl : public init_function { ...@@ -65,7 +63,7 @@ class scheduler::init_function_impl : public init_function {
explicit init_function_impl(F &function) : function_{function} {} explicit init_function_impl(F &function) : function_{function} {}
void run() override { void run() override {
base_task *root_task = thread_state::get().get_active_task(); base_task *root_task = thread_state::get().get_active_task();
root_task->run_as_task([root_task, this](::context_switcher::continuation cont) { root_task->run_as_task([root_task, this](auto cont) {
root_task->is_synchronized_ = true; root_task->is_synchronized_ = true;
thread_state::get().main_continuation() = std::move(cont); thread_state::get().main_continuation() = std::move(cont);
function_(); function_();
......
...@@ -6,7 +6,6 @@ namespace internal { ...@@ -6,7 +6,6 @@ namespace internal {
namespace base { namespace base {
bool swmr_spin_lock::reader_try_lock() { bool swmr_spin_lock::reader_try_lock() {
PROFILE_LOCK("Try Acquire Read Lock")
if (write_request_.load(std::memory_order_acquire) == 1) { if (write_request_.load(std::memory_order_acquire) == 1) {
return false; return false;
} }
...@@ -22,12 +21,10 @@ bool swmr_spin_lock::reader_try_lock() { ...@@ -22,12 +21,10 @@ bool swmr_spin_lock::reader_try_lock() {
} }
void swmr_spin_lock::reader_unlock() { void swmr_spin_lock::reader_unlock() {
PROFILE_LOCK("Release Read Lock")
readers_--; readers_--;
} }
void swmr_spin_lock::writer_lock() { void swmr_spin_lock::writer_lock() {
PROFILE_LOCK("Acquire Write Lock")
// Tell the readers that we would like to write // Tell the readers that we would like to write
write_request_ = 1; write_request_ = 1;
...@@ -37,7 +34,6 @@ void swmr_spin_lock::writer_lock() { ...@@ -37,7 +34,6 @@ void swmr_spin_lock::writer_lock() {
} }
void swmr_spin_lock::writer_unlock() { void swmr_spin_lock::writer_unlock() {
PROFILE_LOCK("Release Write Lock")
write_request_ = 0; write_request_ = 0;
} }
......
#include "pls/internal/helpers/profiler.h"
#include "pls/internal/base/tas_spin_lock.h" #include "pls/internal/base/tas_spin_lock.h"
#include "pls/internal/base/backoff.h" #include "pls/internal/base/backoff.h"
...@@ -7,7 +6,6 @@ namespace internal { ...@@ -7,7 +6,6 @@ namespace internal {
namespace base { namespace base {
void tas_spin_lock::lock() { void tas_spin_lock::lock() {
PROFILE_LOCK("Acquire Lock")
backoff backoff_strategy; backoff backoff_strategy;
while (true) { while (true) {
...@@ -19,7 +17,6 @@ void tas_spin_lock::lock() { ...@@ -19,7 +17,6 @@ void tas_spin_lock::lock() {
} }
bool tas_spin_lock::try_lock(unsigned int num_tries) { bool tas_spin_lock::try_lock(unsigned int num_tries) {
PROFILE_LOCK("Try Acquire Lock")
backoff backoff_strategy; backoff backoff_strategy;
while (true) { while (true) {
...@@ -37,7 +34,6 @@ bool tas_spin_lock::try_lock(unsigned int num_tries) { ...@@ -37,7 +34,6 @@ bool tas_spin_lock::try_lock(unsigned int num_tries) {
} }
void tas_spin_lock::unlock() { void tas_spin_lock::unlock() {
PROFILE_LOCK("Unlock")
flag_.clear(std::memory_order_release); flag_.clear(std::memory_order_release);
} }
......
#include "pls/internal/helpers/profiler.h"
#include "pls/internal/base/ttas_spin_lock.h" #include "pls/internal/base/ttas_spin_lock.h"
#include "pls/internal/base/backoff.h" #include "pls/internal/base/backoff.h"
...@@ -7,7 +6,6 @@ namespace internal { ...@@ -7,7 +6,6 @@ namespace internal {
namespace base { namespace base {
void ttas_spin_lock::lock() { void ttas_spin_lock::lock() {
PROFILE_LOCK("Acquire Lock")
int expected = 0; int expected = 0;
backoff backoff_; backoff backoff_;
...@@ -24,7 +22,6 @@ void ttas_spin_lock::lock() { ...@@ -24,7 +22,6 @@ void ttas_spin_lock::lock() {
} }
bool ttas_spin_lock::try_lock(unsigned int num_tries) { bool ttas_spin_lock::try_lock(unsigned int num_tries) {
PROFILE_LOCK("Try Acquire Lock")
int expected = 0; int expected = 0;
backoff backoff_; backoff backoff_;
...@@ -50,7 +47,6 @@ bool ttas_spin_lock::try_lock(unsigned int num_tries) { ...@@ -50,7 +47,6 @@ bool ttas_spin_lock::try_lock(unsigned int num_tries) {
} }
void ttas_spin_lock::unlock() { void ttas_spin_lock::unlock() {
PROFILE_LOCK("Unlock")
flag_.store(0, std::memory_order_release); flag_.store(0, std::memory_order_release);
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace pls::internal::scheduling::lock_free { namespace pls::internal::scheduling::lock_free {
task * external_trading_deque::peek_traded_object(task *target_task) { task *external_trading_deque::peek_traded_object(task *target_task) {
traded_cas_field current_cas = target_task->external_trading_deque_cas_.load(); traded_cas_field current_cas = target_task->external_trading_deque_cas_.load();
if (current_cas.is_filled_with_object()) { if (current_cas.is_filled_with_object()) {
return current_cas.get_trade_object(); return current_cas.get_trade_object();
...@@ -12,7 +12,7 @@ task * external_trading_deque::peek_traded_object(task *target_task) { ...@@ -12,7 +12,7 @@ task * external_trading_deque::peek_traded_object(task *target_task) {
} }
} }
task * external_trading_deque::get_trade_object(task *target_task) { task *external_trading_deque::get_trade_object(task *target_task) {
traded_cas_field current_cas = target_task->external_trading_deque_cas_.load(); traded_cas_field current_cas = target_task->external_trading_deque_cas_.load();
if (current_cas.is_filled_with_object()) { if (current_cas.is_filled_with_object()) {
task *result = current_cas.get_trade_object(); task *result = current_cas.get_trade_object();
...@@ -53,17 +53,10 @@ void external_trading_deque::reset_bot_and_top() { ...@@ -53,17 +53,10 @@ void external_trading_deque::reset_bot_and_top() {
top_.store({bot_internal_.stamp, 0}); top_.store({bot_internal_.stamp, 0});
} }
void external_trading_deque::decrease_bot() { task *external_trading_deque::pop_bot() {
if (bot_internal_.value > 0) {
bot_internal_.value--; bot_internal_.value--;
bot_.store(bot_internal_.value, std::memory_order_relaxed); bot_.store(bot_internal_.value, std::memory_order_relaxed);
}
task * external_trading_deque::pop_bot() {
if (bot_internal_.value == 0) {
reset_bot_and_top();
return nullptr;
}
decrease_bot();
auto &current_entry = entries_[bot_internal_.value]; auto &current_entry = entries_[bot_internal_.value];
auto *popped_task = current_entry.traded_task_.load(std::memory_order_relaxed); auto *popped_task = current_entry.traded_task_.load(std::memory_order_relaxed);
...@@ -78,10 +71,11 @@ task * external_trading_deque::pop_bot() { ...@@ -78,10 +71,11 @@ task * external_trading_deque::pop_bot() {
empty_cas_field, empty_cas_field,
std::memory_order_acq_rel)) { std::memory_order_acq_rel)) {
return popped_task; return popped_task;
} else { }
}
reset_bot_and_top(); reset_bot_and_top();
return nullptr; return nullptr;
}
} }
external_trading_deque::peek_result external_trading_deque::peek_top() { external_trading_deque::peek_result external_trading_deque::peek_top() {
...@@ -95,7 +89,7 @@ external_trading_deque::peek_result external_trading_deque::peek_top() { ...@@ -95,7 +89,7 @@ external_trading_deque::peek_result external_trading_deque::peek_top() {
} }
} }
task * external_trading_deque::pop_top(task *offered_task, peek_result peek_result) { task *external_trading_deque::pop_top(task *offered_task, peek_result peek_result) {
stamped_integer expected_top = peek_result.top_pointer_; stamped_integer expected_top = peek_result.top_pointer_;
auto local_bot = bot_.load(); auto local_bot = bot_.load();
if (expected_top.value >= local_bot) { if (expected_top.value >= local_bot) {
......
...@@ -95,7 +95,6 @@ void scheduler::sync() { ...@@ -95,7 +95,6 @@ void scheduler::sync() {
spawned_task->run_as_task([active_task, spawned_task, &syncing_state](context_switcher::continuation cont) { spawned_task->run_as_task([active_task, spawned_task, &syncing_state](context_switcher::continuation cont) {
active_task->continuation_ = std::move(cont); active_task->continuation_ = std::move(cont);
syncing_state.set_active_task(spawned_task); syncing_state.set_active_task(spawned_task);
return slow_return(syncing_state); return slow_return(syncing_state);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment