-
Notifications
You must be signed in to change notification settings - Fork 13
Sdk #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Sdk #78
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5b07ca5
base changes for sdk, bug fix for export_dependency_graph to a .dot file
OmerMajNition 0035b41
first draft of sdk, work in progress
OmerMajNition fb31d00
reverted back info logs
OmerMajNition 9be2807
command line arguments support added to SDK, copied files used by LF
OmerMajNition b7ace70
homogeneous and heterogeneous configuration support, config files gen…
OmerMajNition 38ebfca
Parameter changes and homogenoeus heterogeneous config generation
OmerMajNition 438c067
added reacion dependencies feature with a test case
OmerMajNition 3ab09b9
parameters with default values, able to be passed from parent when co…
OmerMajNition 008a4a5
Default parameters support with ReactorBanks
OmerMajNition 46c4346
hello world and Workers examples added for LF weekly meeting
OmerMajNition a21791b
Workers example with published parameters
OmerMajNition 4ea3411
fixed a bug
OmerMajNition 5058c3c
gradually moving towards unified wiring function call that dumps the …
OmerMajNition 591bc73
added reaction internals class that would help users define reactions…
OmerMajNition 6eb494a
added conveneient macros to ease out reactions definition inside reactor
OmerMajNition 294f2a2
bank index support in ReactionInternals and some more examples ported
OmerMajNition 21a4b65
input to reactor bank input port wiring added
OmerMajNition 5821e42
ported examples and tests to new ReactionInternals design, now reacti…
OmerMajNition 5e1ecf2
fixed compilation issue
OmerMajNition 5927709
ReactionChamber renaming, fix for gcc < 13 compiler versions
OmerMajNition 35ce140
removing the function that would never get hit, gcc < 13 is already f…
OmerMajNition 37055b1
compilation fix for TimePoint cout overload
OmerMajNition File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") | ||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") | ||
endif() | ||
|
||
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) | ||
string(REGEX REPLACE "\n" ";" files "${files}") | ||
foreach(file ${files}) | ||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}") | ||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") | ||
exec_program( | ||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" | ||
OUTPUT_VARIABLE rm_out | ||
RETURN_VALUE rm_retval | ||
) | ||
if(NOT "${rm_retval}" STREQUAL 0) | ||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") | ||
endif() | ||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") | ||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.") | ||
endif() | ||
endforeach() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
cmake_minimum_required(VERSION 3.9) | ||
project(src_sink_fanout VERSION 0.0.0 LANGUAGES CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard is cached for visibility in external tools." FORCE) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) | ||
|
||
set(LF_MAIN_TARGET src_sink_fanout) | ||
|
||
find_package(reactor-cpp PATHS ) | ||
find_package(reactor-sdk PATHS ) | ||
|
||
add_executable(${LF_MAIN_TARGET} | ||
main.cc | ||
) | ||
|
||
include_directories(${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
target_link_libraries(${LF_MAIN_TARGET} reactor-cpp) | ||
target_link_libraries(${LF_MAIN_TARGET} reactor-sdk) | ||
|
||
target_compile_options(${LF_MAIN_TARGET} PRIVATE -Wall -Wextra -pedantic) | ||
|
||
include(Sink/SinkReactor.cmake) | ||
include(Source/SourceReactor.cmake) | ||
include(Main/MainReactor.cmake) | ||
include(Config-a/Config-a.cmake) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "Config-a.hh" | ||
|
||
UserParameters cfg_parameters; | ||
|
||
ConfigParameter<int, uint32_t>::ParametersMap UserParameters::homogeneous_config() { | ||
return { | ||
{"Main.Source.iterations", ConfigParameterMetadata<int> { 5 } } | ||
}; | ||
} | ||
|
||
ConfigParameter<int, uint32_t>::ParametersMap UserParameters::heterogeneous_config() { | ||
return { | ||
{"Main.Source.iterations", ConfigParameterMetadata<int> { 20 } }, | ||
{"Main.Sink.n_ports", ConfigParameterMetadata<int> { 2 } } | ||
|
||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
include_directories(${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
set(INCLUDE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/Config-a.hh" | ||
) | ||
|
||
set(SOURCE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/Config-a.cc" | ||
) | ||
|
||
|
||
foreach(file IN LISTS INCLUDE_FILES) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${file}") | ||
endforeach() | ||
|
||
target_sources(${LF_MAIN_TARGET} PRIVATE ${SOURCE_FILES}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef USER_PARAMETERS_H | ||
#define USER_PARAMETERS_H | ||
|
||
#include <reactor-sdk/reactor-sdk.hh> | ||
#include <map> | ||
#include <variant> | ||
#include <string> | ||
|
||
using namespace sdk; | ||
|
||
struct UserParameters : public ConfigParameter<int, uint32_t> { | ||
ConfigParameter<int, uint32_t>::ParametersMap homogeneous_config(); | ||
ConfigParameter<int, uint32_t>::ParametersMap heterogeneous_config(); | ||
}; | ||
|
||
extern UserParameters cfg_parameters; | ||
|
||
#endif // USER_PARAMETERS_H |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "MainReactor.hh" | ||
|
||
void MainReactor::construction() { | ||
|
||
cout << "Construction Main\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you overload cout? or did I miss the |
||
|
||
src = std::make_unique<SourceReactor>("Source", this); | ||
snk = std::make_unique<SinkReactor>("Sink", this); | ||
} | ||
|
||
void MainReactor::assembling() { | ||
cout << "Assembling Main\n"; | ||
|
||
src->req -->> snk->req; | ||
snk->rsp --> src->rsp; | ||
|
||
reaction("reaction_1"). | ||
triggers(&startup). | ||
dependencies(). | ||
effects(). | ||
function( | ||
[&](Startup& startup) { | ||
cout << "(" << get_elapsed_logical_time() << ", " << get_microstep() << "), physical_time: " << get_elapsed_physical_time() << " " << | ||
"Starting up reaction\n" << "Bank:" << bank_index << " name:" << parameters.alias.value << " fqn:" << fqn() << endl; | ||
} | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
include_directories(${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
set(INCLUDE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/MainReactor.hh" | ||
) | ||
|
||
set(SOURCE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/MainReactor.cc" | ||
) | ||
|
||
|
||
foreach(file IN LISTS INCLUDE_FILES) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${file}") | ||
endforeach() | ||
|
||
target_sources(${LF_MAIN_TARGET} PRIVATE ${SOURCE_FILES}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include <reactor-sdk/reactor-sdk.hh> | ||
|
||
#include "Source/SourceReactor.hh" | ||
#include "Sink/SinkReactor.hh" | ||
|
||
using namespace sdk; | ||
|
||
class MainReactor: public Reactor { | ||
public: | ||
struct Parameters : public SystemParameter<string> { | ||
REACTOR_PARAMETER (string, alias, "Alternate name", "another", "another", "Src-Sink-Fanout-Example"); | ||
|
||
Parameters(Reactor *container) | ||
: SystemParameter<string>(container) { | ||
register_parameters (alias); | ||
} | ||
}; | ||
|
||
private: | ||
Parameters parameters{this}; | ||
|
||
std::unique_ptr<SourceReactor> src; | ||
std::unique_ptr<SinkReactor> snk; | ||
|
||
public: | ||
MainReactor(const std::string &name, Environment *env) | ||
: Reactor(name, env) {} | ||
MainReactor(const std::string &name, Reactor *container) | ||
: Reactor(name, container) {} | ||
|
||
void construction() override; | ||
void assembling() override; | ||
}; | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "SinkReactor.hh" | ||
using namespace std; | ||
|
||
void SinkReactor::construction() { | ||
cout << "Construction Sink n_ports:" << parameters.n_ports.value << "\n"; | ||
req.set_width (parameters.n_ports.value); | ||
rsp.set_width (parameters.n_ports.value); | ||
} | ||
|
||
void SinkReactor::assembling() { | ||
|
||
cout << "Assembling Sink\n"; | ||
|
||
reaction("startup_reaction"). | ||
triggers(&startup). | ||
dependencies(). | ||
effects(). | ||
function(pass_function(startup_reaction) | ||
); | ||
|
||
reaction("process_request"). | ||
triggers(&req). | ||
dependencies(). | ||
effects(&rsp). | ||
function(pass_function(process_request) | ||
); | ||
} | ||
|
||
|
||
|
||
void SinkReactor::startup_reaction (Startup& startup) { | ||
cout << "(" << get_elapsed_logical_time() << ", " << get_microstep() << "), physical_time: " << get_elapsed_physical_time() << " " << | ||
"Starting up reaction\n" << "Bank:" << bank_index << " name:" << parameters.name.value << " fqn:" << fqn() << endl; | ||
} | ||
|
||
void SinkReactor::process_request (MultiportInput<int>& req, MultiportOutput<int>& rsp) { | ||
for (int i = 0; i < parameters.n_ports.value; ++i) { | ||
if (req[i].is_present()) { | ||
cout << "(" << get_elapsed_logical_time() << ", " << get_microstep() << "), physical_time: " << get_elapsed_physical_time() << " " << | ||
"Received input:" << *req[i].get() << " port:" << i << endl; | ||
rsp[i].set (*req[i].get()); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
set(INCLUDE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/SinkReactor.hh" | ||
) | ||
|
||
set(SOURCE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/SinkReactor.cc" | ||
) | ||
|
||
|
||
foreach(file IN LISTS INCLUDE_FILES) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${file}") | ||
endforeach() | ||
|
||
target_sources(${LF_MAIN_TARGET} PRIVATE ${SOURCE_FILES}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
#include <reactor-sdk/reactor-sdk.hh> | ||
using namespace std; | ||
using namespace sdk; | ||
|
||
class SinkReactor : public Reactor { | ||
public: | ||
struct Parameters : public SystemParameter<string, int> { | ||
REACTOR_PARAMETER (string, name, "Alternate name", "Sink", "Sink", "Sink"); | ||
REACTOR_PARAMETER (int, n_ports, "Size of multiports", 1, 10, 1); | ||
|
||
Parameters(Reactor *container) | ||
: SystemParameter<string, int>(container) { | ||
register_parameters (name, n_ports); | ||
} | ||
}; | ||
|
||
SinkReactor(const std::string &name, Environment *env) | ||
: Reactor(name, env) {} | ||
SinkReactor(const std::string &name, Reactor *container) | ||
: Reactor(name, container) {} | ||
|
||
Parameters parameters{this}; | ||
|
||
MultiportInput<int> req{"req", this}; | ||
MultiportOutput<int> rsp{"rsp", this}; | ||
|
||
void construction() override; | ||
void assembling() override; | ||
|
||
void startup_reaction (Startup &startup); | ||
void process_request (MultiportInput<int>& req, MultiportOutput<int>& rsp); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
#include "SourceReactor.hh" | ||
using namespace std; | ||
|
||
void SourceReactor::construction() { | ||
|
||
cout << "Construction Source iterations:" << parameters.iterations.value << "\n"; | ||
} | ||
|
||
void SourceReactor::assembling() { | ||
cout << "Assembling Source iterations:" << parameters.iterations.value << "\n"; | ||
reaction("reaction_1"). | ||
triggers(&startup). | ||
dependencies(). | ||
effects(&sch). | ||
function( | ||
[&](Startup& startup, LogicalAction<int>& sched) { | ||
cout << "(" << get_elapsed_logical_time() << ", " << get_microstep() << "), physical_time: " << get_elapsed_physical_time() << " " << | ||
"Starting up reaction\n" << "Bank:" << bank_index << " name:" << name << " fqn:" << fqn() << " iterations:" << parameters.iterations.value << endl; | ||
if (itr < parameters.iterations.value) { | ||
sched.schedule (itr, 0ms); | ||
++itr; | ||
} | ||
} | ||
); | ||
|
||
reaction("reaction_2"). | ||
triggers(&sch). | ||
dependencies(). | ||
effects(&req). | ||
function( | ||
[&](LogicalAction<int>& sch, Output<int>& req) { | ||
cout << "(" << get_elapsed_logical_time() << ", " << get_microstep() << "), physical_time: " << get_elapsed_physical_time() << " " << | ||
"Scheduling iteration:" << *sch.get() << endl; | ||
req.set (*sch.get()); | ||
} | ||
); | ||
|
||
reaction("reaction_3"). | ||
triggers(&rsp). | ||
dependencies(). | ||
effects(&sch). | ||
function( | ||
[&](Input<int>& rsp, LogicalAction<int>& sch) { | ||
if (rsp.is_present()) { | ||
cout << "(" << get_elapsed_logical_time() << ", " << get_microstep() << "), physical_time: " << get_elapsed_physical_time() << " " << | ||
"Recevied response:" << *rsp.get() << endl; | ||
} | ||
|
||
if (itr < parameters.iterations.value) { | ||
sch.schedule (itr, 0ms); | ||
++itr; | ||
} else { | ||
request_stop(); | ||
} | ||
} | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
set(INCLUDE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/SourceReactor.hh" | ||
) | ||
|
||
set(SOURCE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/SourceReactor.cc" | ||
) | ||
|
||
foreach(file IN LISTS INCLUDE_FILES) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${file}") | ||
endforeach() | ||
|
||
target_sources(${LF_MAIN_TARGET} PRIVATE ${SOURCE_FILES}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a folder for all the sdk stuff:
/examples/sdk/SrcSinkFanout/ConfigA/ConfigA.cc