4#if defined(TTG_HAVE_CUDA)
5#define ES ttg::ExecutionSpace::CUDA
6#include "cuda_runtime.h"
9#error " CUDA is required to build this test!"
17 std::unique_ptr<int64_t[]>
F;
20 Fn() :
F(
std::make_unique<int64_t[]>(2)),
b(
F.get(), 2) {
F[0] = 1;
F[1] = 0; }
27 template <
typename Archive>
31 template <
typename Archive>
41 auto fib = ttg::make_tt<ES>(
42 [=](int64_t n,
Fn&& f_n) -> ttg::device::Task {
44 ttg::trace(
"in fib: n=", n,
" F_n=", f_n.F[0]);
46 co_await ttg::device::select(f_n.b);
51 co_await ttg::device::wait(f_n.b);
54 co_await ttg::device::forward(ttg::device::send<0>(n + 1, std::move(f_n)));
56 co_await ttg::device::forward(ttg::device::sendv<1>(std::move(f_n)));
60 auto print = ttg::make_tt(
62 std::cout <<
"The largest Fibonacci number smaller than " <<
F_n_max <<
" is " << f_n.F[1] << std::endl;
66 auto ins = std::make_tuple(fib->template in<0>());
67 std::vector<std::unique_ptr<::ttg::TTBase>> ops;
68 ops.emplace_back(std::move(fib));
69 ops.emplace_back(std::move(print));
70 return make_ttg(std::move(ops), ins, std::make_tuple(),
"Fib_n < N");
73int main(
int argc,
char* argv[]) {
77 if (argc > 1) N = std::atol(argv[1]);
87 fib->template in<0>()->send(1,
Fn{});;
Edge is used to connect In and Out terminals.
void next_value(int64_t *fn_and_fnm1)
int main(int argc, char *argv[])
auto make_ttg_fib_lt(const int64_t F_n_max=1000)
ttg::World ttg_default_execution_context()
void execute(ttg::World world)
Starts the execution in the given execution context.
void initialize(int argc, char **argv, int num_threads=-1, RestOfArgs &&...)
void trace_on()
enables tracing; if trace_enabled()==true this has no effect
World default_execution_context()
Accesses the default backend's default execution context.
void fence(ttg::World world)
Returns when all tasks associated with the given execution context have finished on all ranks.
void finalize()
Finalizes the TTG runtime.
std::enable_if_t<(std::is_convertible_v< decltype(*(std::declval< TTBasePtrs >())), TTBase & > &&...), bool > make_graph_executable(TTBasePtrs &&...tts)
Make the TTG tts executable. Applies.
void trace(const T &t, const Ts &... ts)
auto edges(inedgesT &&...args)
Make a tuple of Edges to pass to.
N.B. contains values of F_n and F_{n-1}.
Fn & operator=(Fn &&other)=default
std::unique_ptr< int64_t[]> F
Fn & operator=(const Fn &other)=delete
void serialize(Archive &ar, const unsigned int)
void serialize(Archive &ar)