Skip to content

Commit

Permalink
ReStructured
Browse files Browse the repository at this point in the history
  • Loading branch information
hyndavi17 committed Apr 17, 2024
1 parent 4e4cd4f commit 7cd3c9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
1 change: 1 addition & 0 deletions doc/dox/dev/devsamp/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ find_package(ttg REQUIRED)

add_ttg_executable(test test.cpp NOT_EXCLUDE_FROM_ALL)

add_ttg_executable(fibonacci fibonacci.cc LINK_LIBRARIES std::coroutine RUNTIMES "parsec")
# Fib device test
if (TTG_HAVE_CUDA)
add_ttg_executable(fibonacci_device fibonacci_device.cc
Expand Down
29 changes: 10 additions & 19 deletions doc/dox/dev/devsamp/main/fibonacci/fibonacci.cc
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
#include <ttg.h>
#include "ttg/serialization.h"

const int64_t F_n_max = 1000;
/// N.B. contains values of F_n and F_{n-1}
struct Fn : public ttg::TTValue<Fn> {
std::unique_ptr<int64_t[]> F; // F[0] = F_n, F[1] = F_{n-1}

Fn() : F(std::make_unique<int64_t[]>(2)) { F[0] = 1; F[1] = 0; }

Fn(const Fn&) = delete;
Fn(Fn&& other) = default;
Fn& operator=(const Fn& other) = delete;
Fn& operator=(Fn&& other) = default;

struct Fn {
int64_t F[2]; // F[0] = F_n, F[1] = F_{n-1}
Fn() { F[0] = 1; F[1] = 0; }
template <typename Archive>
void serialize(Archive& ar) {
ttg::ttg_abort();
ar & F;
}
template <typename Archive>
void serialize(Archive& ar, const unsigned int) {
ttg::ttg_abort();
ar & F;
}
};
auto make_ttg_fib_lt(const int64_t) {
auto make_ttg_fib_lt(const int64_t F_n_max =1000) {
ttg::Edge<int64_t, Fn> f2f;
ttg::Edge<void, Fn> f2p;

Expand All @@ -32,9 +24,9 @@ auto make_ttg_fib_lt(const int64_t) {
f_n.F[1] = f_n.F[0];
f_n.F[0] = next_f_n;
if (next_f_n < F_n_max) {
ttg::send<0>(n + 1, std::move(f_n));
ttg::send<0>(n + 1, f_n);
} else {
ttg::send<1>(n, std::move(f_n));
ttg::send<1>(n, f_n);
}
},
ttg::edges(f2f), ttg::edges(f2f, f2p), "fib");
Expand All @@ -51,10 +43,8 @@ auto make_ttg_fib_lt(const int64_t) {
return make_ttg(std::move(ops), ins, std::make_tuple(), "Fib_n < N");
}


int main(int argc, char* argv[]) {
ttg::initialize(argc, argv, -1);
ttg::trace_on();
int64_t N = 1000;
if (argc > 1) N = std::atol(argv[1]);

Expand All @@ -65,6 +55,7 @@ int main(int argc, char* argv[]) {

ttg::execute();
ttg::fence();

ttg::finalize();
return 0;
}
}

0 comments on commit 7cd3c9b

Please sign in to comment.