Created
May 17, 2017 16:32
-
-
Save taeguk/0c4514ad3ec590701d104803fbb2e1da to your computer and use it in GitHub Desktop.
a.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hpx::future<std::uint64_t> fibonacci(std::uint64_t n, std::string prefix) | |
| { | |
| if (n < 2) return hpx::make_ready_future(n); | |
| if (n < threshold) return hpx::make_ready_future(fibonacci_serial(n)); | |
| auto new_prefix = prefix + "->" + std::to_string(n); | |
| std::cout << "[Debug] " << new_prefix << std::endl; | |
| hpx::future<std::uint64_t> lhs_future = hpx::async(&fibonacci, n-1, new_prefix); | |
| hpx::future<std::uint64_t> rhs_future = fibonacci(n - 2, new_prefix); | |
| if (n == 10) | |
| auto aaarhs_future = fibonacci(n - 3, "X" + new_prefix); | |
| return | |
| hpx::dataflow( | |
| hpx::util::unwrapped( | |
| [](std::uint64_t lhs, std::uint64_t rhs) | |
| { | |
| return lhs + rhs; | |
| }) | |
| , std::move(lhs_future), std::move(rhs_future) | |
| ); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fibonacci_serial(10) == 55,elapsed time:,11169,[s]
[Debug] ->10
[Debug] ->10->8
[Debug] ->10->8->6
[Debug] ->10->8->6->4
[Debug] ->10->8->6->4->2
[Debug] X->10->7
[Debug] X->10->7->5
[Debug] X->10->7->5->3
[Debug] ->10->9
[Debug] ->10->9->7
[Debug] ->10->9->7->5
[Debug] ->10->9->7->5->3
[Debug] ->10->8->7
[Debug] ->10->8->7->5
[Debug] ->10->8->7->5->3
[Debug] ->10->8->6->5
[Debug] ->10->8->6->5->3
[Debug] ->10->8->6->4->3
[Debug] X->10->7->6
[Debug] X->10->7->6->4
[Debug] X->10->7->6->4->2
[Debug] X->10->7->5->4
[Debug] X->10->7->5->4->2
[Debug] X->10->7->5->3->2
[Debug] ->10->9->8
[Debug] ->10->9->8->6
[Debug] ->10->9->8->6->4
[Debug] ->10->9->8->6->4->2
[Debug] ->10->9->7->6
[Debug] ->10->9->7->6->4
[Debug] ->10->9->7->6->4->2
[Debug] ->10->9->7->5->4
[Debug] ->10->9->7->5->4->2
[Debug] ->10->9->7->5->3->2
[Debug] ->10->8->7->6
[Debug] ->10->8->7->6->4
[Debug] ->10->8->7->6->4->2
[Debug] ->10->8->7->5->4
[Debug] ->10->8->7->5->4->2
[Debug] ->10->8->7->5->3->2
[Debug] ->10->8->6->5->4
[Debug] ->10->8->6->5->4->2
[Debug] ->10->8->6->5->3->2
[Debug] ->10->8->6->4->3->2
[Debug] X->10->7->6->5
[Debug] X->10->7->6->5->3
[Debug] X->10->7->6->4->3
[Debug] X->10->7->5->4->3
[Debug] ->10->9->8->7
[Debug] ->10->9->8->7->5
[Debug] ->10->9->8->7->5->3
[Debug] ->10->9->8->6->5
[Debug] ->10->9->8->6->5->3
[Debug] ->10->9->8->6->4->3
[Debug] ->10->9->7->6->5
[Debug] ->10->9->7->6->5->3
[Debug] ->10->9->7->6->4->3
[Debug] ->10->9->7->5->4->3
[Debug] ->10->8->7->6->5
[Debug] ->10->8->7->6->5->3
[Debug] ->10->8->7->6->4->3
[Debug] ->10->8->7->5->4->3
[Debug] ->10->8->6->5->4->3
[Debug] X->10->7->6->5->4
[Debug] X->10->7->6->5->4->2
[Debug] X->10->7->6->5->3->2
[Debug] X->10->7->6->4->3->2
[Debug] X->10->7->5->4->3->2
[Debug] ->10->9->8->7->6
[Debug] ->10->9->8->7->6->4
[Debug] ->10->9->8->7->6->4->2
[Debug] ->10->9->8->7->5->4
[Debug] ->10->9->8->7->5->4->2
[Debug] ->10->9->8->7->5->3->2
[Debug] ->10->9->8->6->5->4
[Debug] ->10->9->8->6->5->4->2
[Debug] ->10->9->8->6->5->3->2
[Debug] ->10->9->8->6->4->3->2
[Debug] ->10->9->7->6->5->4
[Debug] ->10->9->7->6->5->4->2
[Debug] ->10->9->7->6->5->3->2
[Debug] ->10->9->7->6->4->3->2
[Debug] ->10->9->7->5->4->3->2
[Debug] ->10->8->7->6->5->4
[Debug] ->10->8->7->6->5->4->2
[Debug] ->10->8->7->6->5->3->2
[Debug] ->10->8->7->6->4->3->2
[Debug] ->10->8->7->5->4->3->2
[Debug] ->10->8->6->5->4->3->2
[Debug] X->10->7->6->5->4->3
[Debug] ->10->9->8->7->6->5
[Debug] ->10->9->8->7->6->5->3
[Debug] ->10->9->8->7->6->4->3
[Debug] ->10->9->8->7->5->4->3
[Debug] ->10->9->8->6->5->4->3
[Debug] ->10->9->7->6->5->4->3
[Debug] ->10->8->7->6->5->4->3
[Debug] X->10->7->6->5->4->3->2
[Debug] ->10->9->8->7->6->5->4
[Debug] ->10->9->8->7->6->5->4->2
[Debug] ->10->9->8->7->6->5->3->2
[Debug] ->10->9->8->7->6->4->3->2
[Debug] ->10->9->8->7->5->4->3->2
[Debug] ->10->9->8->6->5->4->3->2
[Debug] ->10->9->7->6->5->4->3->2
[Debug] ->10->8->7->6->5->4->3->2
[Debug] ->10->9->8->7->6->5->4->3
[Debug] ->10->9->8->7->6->5->4->3->2
fibonacci_await(10) == 55,elapsed time:,163745764,[s]