#include #include #include static pls::static_scheduler_memory<8, 2 << 14> my_scheduler_memory; static constexpr int CUTOFF = 10; long fib_serial(long n) { if (n == 0) { return 0; } if (n == 1) { return 1; } return fib_serial(n - 1) + fib_serial(n - 2); } long fib(long n) { if (n <= CUTOFF) { return fib_serial(n); } // Actual 'invoke_parallel' logic/code int left, right; pls::invoke_parallel( [&] { left = fib(n - 1); }, [&] { right = fib(n - 2); } ); return left + right; } int main() { EASY_PROFILER_ENABLE; pls::scheduler scheduler{&my_scheduler_memory, 8}; long result; scheduler.perform_work([&] { EASY_MAIN_THREAD; // Call looks just the same, only requirement is // the enclosure in the perform_work lambda. result = fib(30); }); std::cout << "Fib(30)=" << result << std::endl; profiler::dumpBlocksToFile("test_profile.prof"); }