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::shared_ptr<int64_t[]>
F;
20 Fn() :
F(
std::make_shared<int64_t[]>(2)),
b(
F, 2) {
F[0] = 1;
F[1] = 0; }
27#ifdef TTG_SERIALIZATION_SUPPORTS_MADNESS
28 template <
typename Archive>
30 ar & madness::archive::wrap(
F.get(), 2) &
b;
33#ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
34 template <
typename Archive>
35 void serialize(Archive& ar,
const unsigned int) {
36 ar & boost::serialization::make_array(
F.get(), 2) &
b;
45 auto fib = ttg::make_tt<ES>(
46 [=](int64_t n,
Fn&& f_n) -> ttg::device::Task {
48 ttg::trace(
"in fib: n=", n,
" F_n=", f_n.F[0]);
50 co_await ttg::device::select(f_n.b);
55 co_await ttg::device::wait(f_n.b);
58 co_await ttg::device::forward(ttg::device::send<0>(n + 1, std::move(f_n)));
60 co_await ttg::device::forward(ttg::device::sendv<1>(std::move(f_n)));
64 auto print = ttg::make_tt(
66 std::cout <<
"The largest Fibonacci number smaller than " <<
F_n_max <<
" is " << f_n.F[1] << std::endl;
70 auto ins = std::make_tuple(fib->template in<0>());
71 std::vector<std::unique_ptr<::ttg::TTBase>> ops;
72 ops.emplace_back(std::move(fib));
73 ops.emplace_back(std::move(print));
74 return make_ttg(std::move(ops), ins, std::make_tuple(),
"Fib_n < N");
77int main(
int argc,
char* argv[]) {
81 if (argc > 1) N = std::atol(argv[1]);
91 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
Fn & operator=(const Fn &other)=delete
std::shared_ptr< int64_t[]> F
void serialize(Archive &ar)