diff --git a/docs/source/examples/.gitignore b/docs/source/examples/.gitignore index 5d3ee3e1..18937208 100644 --- a/docs/source/examples/.gitignore +++ b/docs/source/examples/.gitignore @@ -1,3 +1,4 @@ rd_implementations.ymmsl benchmark_implementations.ymmsl +dispatch_implementations.ymmsl run_* diff --git a/docs/source/examples/Makefile b/docs/source/examples/Makefile index d308b42b..1f948a6e 100644 --- a/docs/source/examples/Makefile +++ b/docs/source/examples/Makefile @@ -69,7 +69,7 @@ endif .PHONY: base -base: python rd_implementations.ymmsl benchmark_implementations.ymmsl +base: python rd_implementations.ymmsl benchmark_implementations.ymmsl dispatch_implementations.ymmsl @@ -106,6 +106,7 @@ clean: $(MAKE) -C python clean rm -f rd_implementations.ymmsl rm -f benchmark_implementations.ymmsl + rm -f dispatch_implementations.ymmsl rm -rf run_*/ @@ -129,6 +130,7 @@ test_cpp: base cpp $$(ls $$(ls -d run_checkpointing_reaction_diffusion_cpp* | tail -n1)/snapshots/*.ymmsl | head -n1) . python/build/venv/bin/activate && muscle_manager --start-all rd_implementations.ymmsl rd_python_cpp.ymmsl rd_settings.ymmsl . python/build/venv/bin/activate && muscle_manager --start-all rd_implementations.ymmsl rdmc_cpp.ymmsl rdmc_settings.ymmsl + . python/build/venv/bin/activate && muscle_manager --start-all dispatch_implementations.ymmsl dispatch_cpp.ymmsl .PHONY: test_cpp_mpi test_cpp_mpi: base cpp_mpi diff --git a/docs/source/examples/cpp/buffer.cpp b/docs/source/examples/cpp/buffer.cpp new file mode 100644 index 00000000..8cd2d4da --- /dev/null +++ b/docs/source/examples/cpp/buffer.cpp @@ -0,0 +1,31 @@ +#include "libmuscle/libmuscle.hpp" +#include "ymmsl/ymmsl.hpp" + +#include "unistd.h" + + +using libmuscle::Data; +using libmuscle::Instance; +using libmuscle::Message; +using ymmsl::Operator; + + +int main(int argc, char * argv[]) { + Instance instance(argc, argv, { + {Operator::F_INIT, {"in"}}, + {Operator::O_F, {"out"}}}); + + while (instance.reuse_instance()) { + // F_INIT + Message msg = instance.receive("in", Message(0.0, Data("Testing"))); + + // S + usleep(250000); + + // O_F + instance.send("out", msg); + } + + return 0; +} + diff --git a/docs/source/examples/cpp/build/Makefile b/docs/source/examples/cpp/build/Makefile index e6fd6332..a52fd13f 100644 --- a/docs/source/examples/cpp/build/Makefile +++ b/docs/source/examples/cpp/build/Makefile @@ -5,7 +5,9 @@ MPI_CXXFLAGS := -std=c++14 -g $(shell pkg-config --cflags libmuscle_mpi ymmsl) MPI_LDFLAGS := $(shell pkg-config --libs libmuscle_mpi ymmsl) -binaries := reaction diffusion mc_driver load_balancer checkpointing_reaction checkpointing_diffusion benchmark +binaries := reaction diffusion mc_driver load_balancer +binaries += checkpointing_reaction checkpointing_diffusion +binaries += benchmark buffer mpi_binaries := reaction_mpi diff --git a/docs/source/examples/dispatch_cpp.ymmsl b/docs/source/examples/dispatch_cpp.ymmsl new file mode 100644 index 00000000..304de8c8 --- /dev/null +++ b/docs/source/examples/dispatch_cpp.ymmsl @@ -0,0 +1,34 @@ +ymmsl_version: v0.1 + +model: + name: dispatch_cpp + + components: + component1: + implementation: buffer_cpp + ports: + o_f: out + + component2: + implementation: buffer_cpp + ports: + f_init: in + o_f: out + + component3: + implementation: buffer_cpp + ports: + f_init: in + + conduits: + component1.out: component2.in + component2.out: component3.in + +resources: + component1: + threads: 1 + component2: + threads: 1 + component3: + threads: 1 + diff --git a/docs/source/examples/dispatch_implementations.ymmsl.in b/docs/source/examples/dispatch_implementations.ymmsl.in new file mode 100644 index 00000000..553db472 --- /dev/null +++ b/docs/source/examples/dispatch_implementations.ymmsl.in @@ -0,0 +1,8 @@ +ymmsl_version: v0.1 + +implementations: + buffer_cpp: + env: + +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib + executable: MUSCLE3_EXAMPLES/cpp/build/buffer +