diff --git a/app/playground/main.cpp b/app/playground/main.cpp index 2a48764..e35d4a3 100644 --- a/app/playground/main.cpp +++ b/app/playground/main.cpp @@ -1,17 +1,13 @@ // Headers are available because we added the pls target #include - #include +#include #include -#include -#include +#include int main() { - pls::dataflow::inputs in; - pls::dataflow::outputs out1; - pls::dataflow::outputs out2; + using namespace pls::dataflow; - out1.get<0>().connect(in.get<0>()); - out2.get<0>().connect(in.get<1>()); + graph, outputs, 8> graph; } diff --git a/lib/pls/CMakeLists.txt b/lib/pls/CMakeLists.txt index 3dae953..45b0740 100644 --- a/lib/pls/CMakeLists.txt +++ b/lib/pls/CMakeLists.txt @@ -10,12 +10,12 @@ add_library(pls STATIC include/pls/algorithms/scan_impl.h include/pls/dataflow/dataflow.h - include/pls/dataflow/token.h + include/pls/dataflow/internal/token.h include/pls/dataflow/graph.h - include/pls/dataflow/inputs.h - include/pls/dataflow/outputs.h - include/pls/dataflow/input.h - include/pls/dataflow/output.h + include/pls/dataflow/internal/inputs.h + include/pls/dataflow/internal/outputs.h + include/pls/dataflow/internal/input.h + include/pls/dataflow/internal/output.h include/pls/internal/base/spin_lock.h include/pls/internal/base/tas_spin_lock.h src/internal/base/tas_spin_lock.cpp @@ -47,7 +47,7 @@ add_library(pls STATIC include/pls/internal/scheduling/scheduler_impl.h include/pls/internal/scheduling/task.h src/internal/scheduling/task.cpp include/pls/internal/scheduling/scheduler_memory.h src/internal/scheduling/scheduler_memory.cpp - include/pls/internal/scheduling/lambda_task.h) + include/pls/internal/scheduling/lambda_task.h include/pls/dataflow/inputs.h include/pls/dataflow/outputs.h) # Add everything in `./include` to be in the include path of this project target_include_directories(pls PUBLIC diff --git a/lib/pls/include/pls/dataflow/graph.h b/lib/pls/include/pls/dataflow/graph.h index 1f94b02..1a05a57 100644 --- a/lib/pls/include/pls/dataflow/graph.h +++ b/lib/pls/include/pls/dataflow/graph.h @@ -2,14 +2,17 @@ #ifndef PLS_DATAFLOW_GRAPH_H_ #define PLS_DATAFLOW_GRAPH_H_ +#include "inputs.h" +#include "outputs.h" + namespace pls { namespace dataflow { -template< +template class graph { - + using internal_inputs = typename I::template internal_inputs

; + using internal_outputs = typename O::template internal_outputs

; }; - } } diff --git a/lib/pls/include/pls/dataflow/inputs.h b/lib/pls/include/pls/dataflow/inputs.h index 24f7d95..c7d453e 100644 --- a/lib/pls/include/pls/dataflow/inputs.h +++ b/lib/pls/include/pls/dataflow/inputs.h @@ -4,21 +4,15 @@ #include -#include "input.h" +#include "internal/inputs.h" namespace pls { namespace dataflow { template -class inputs { - using values_type = std::tuple, input...>; - values_type values_; - - public: - template - typename std::tuple_element::type &get() { - return std::get(values_); - } +struct inputs { + template + using internal_inputs = internal::inputs; }; } diff --git a/lib/pls/include/pls/dataflow/input.h b/lib/pls/include/pls/dataflow/internal/input.h similarity index 84% rename from lib/pls/include/pls/dataflow/input.h rename to lib/pls/include/pls/dataflow/internal/input.h index c47581a..fba2a54 100644 --- a/lib/pls/include/pls/dataflow/input.h +++ b/lib/pls/include/pls/dataflow/internal/input.h @@ -1,6 +1,6 @@ -#ifndef PLS_DATAFLOW_INPUT_H_ -#define PLS_DATAFLOW_INPUT_H_ +#ifndef PLS_DATAFLOW_INTERNAL_INPUT_H_ +#define PLS_DATAFLOW_INTERNAL_INPUT_H_ #include "token.h" @@ -8,6 +8,7 @@ namespace pls { namespace dataflow { +namespace internal { template class input { @@ -26,16 +27,19 @@ class input { connected_ = true; } - public: input() : filled_{false}, connected_{false} {}; - bool has_token(color color) const { + bool has_token(token_color color) const { return filled_ && token_.color() == color; } const token &get_token() const { return token_; } + + public: + }; } } +} -#endif //PLS_DATAFLOW_INPUT_H_ +#endif //PLS_DATAFLOW_INTERNAL_INPUT_H_ diff --git a/lib/pls/include/pls/dataflow/output.h b/lib/pls/include/pls/dataflow/internal/output.h similarity index 85% rename from lib/pls/include/pls/dataflow/output.h rename to lib/pls/include/pls/dataflow/internal/output.h index 2c2c3cb..eb19dce 100644 --- a/lib/pls/include/pls/dataflow/output.h +++ b/lib/pls/include/pls/dataflow/internal/output.h @@ -1,6 +1,6 @@ -#ifndef PLS_DATAFLOW_OUTPUT_H_ -#define PLS_DATAFLOW_OUTPUT_H_ +#ifndef PLS_DATAFLOW_INTERNAL_OUTPUT_H_ +#define PLS_DATAFLOW_INTERNAL_OUTPUT_H_ #include "token.h" #include "input.h" @@ -9,6 +9,7 @@ namespace pls { namespace dataflow { +namespace internal { template class output { @@ -31,5 +32,6 @@ class output { } } +} -#endif //PLS_DATAFLOW_OUTPUT_H_ +#endif //PLS_DATAFLOW_INTERNAL_OUTPUT_H_ diff --git a/lib/pls/include/pls/dataflow/token.h b/lib/pls/include/pls/dataflow/internal/token.h similarity index 74% rename from lib/pls/include/pls/dataflow/token.h rename to lib/pls/include/pls/dataflow/internal/token.h index 6492944..b0c609a 100644 --- a/lib/pls/include/pls/dataflow/token.h +++ b/lib/pls/include/pls/dataflow/internal/token.h @@ -1,30 +1,32 @@ -#ifndef PLS_DATAFLOW_TOKEN_H_ -#define PLS_DATAFLOW_TOKEN_H_ +#ifndef PLS_DATAFLOW_INTERNAL_TOKEN_H_ +#define PLS_DATAFLOW_INTERNAL_TOKEN_H_ namespace pls { namespace dataflow { +namespace internal { /** * Parallel invocations of the same sub-graph are usually working with some kind of coloring * for tokens to distinguishe different invocations. As this concept is abstract and we could * change it in the future (for e.g. more advanced features/dataflows) we encapsulate it. */ -struct color { +struct token_color { unsigned int clock_; }; template class token { T value_; - color color_; + token_color color_; public: T value() const { return value_; } - color color() const { return color_; } + token_color color() const { return color_; } }; } } +} -#endif //PLS_DATAFLOW_TOKEN_H_ +#endif //PLS_DATAFLOW_INTERNAL_TOKEN_H_ diff --git a/lib/pls/include/pls/dataflow/outputs.h b/lib/pls/include/pls/dataflow/outputs.h index 68f1f20..e7a5a80 100644 --- a/lib/pls/include/pls/dataflow/outputs.h +++ b/lib/pls/include/pls/dataflow/outputs.h @@ -2,23 +2,16 @@ #ifndef PLS_DATAFLOW_OUTPUTS_H_ #define PLS_DATAFLOW_OUTPUTS_H_ -#include - -#include "output.h" +#include "internal/outputs.h" +#include "outputs.h" namespace pls { namespace dataflow { template -class outputs { - using values_type = std::tuple, output...>; - values_type values_; - - public: - template - typename std::tuple_element::type &get() { - return std::get(values_); - } +struct outputs { + template + using internal_outputs = internal::outputs; }; }