From e62d846a694b6ed1f98bd7e458b98d5c72695f3a Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 12:02:20 +0800 Subject: [PATCH 01/10] Add submodule: pybind11 --- .gitmodules | 3 +++ src/lava/magma/runtime/cpp_message_infrastructure/pybind11 | 1 + 2 files changed, 4 insertions(+) create mode 160000 src/lava/magma/runtime/cpp_message_infrastructure/pybind11 diff --git a/.gitmodules b/.gitmodules index e11057ce3..16059daea 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "docs"] path = docs url = https://github.com/lava-nc/lava-docs.git +[submodule "src/lava/magma/runtime/cpp_message_infrastructure/pybind11"] + path = src/lava/magma/runtime/cpp_message_infrastructure/pybind11 + url = https://github.com/pybind/pybind11.git diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/pybind11 b/src/lava/magma/runtime/cpp_message_infrastructure/pybind11 new file mode 160000 index 000000000..ba5ccd845 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/pybind11 @@ -0,0 +1 @@ +Subproject commit ba5ccd845a2261e538df651e3d528dc1bece094d From 4586654452ce71ec32f2b5f1864256392bcd5d3d Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 12:11:51 +0800 Subject: [PATCH 02/10] Add initial abstract cpp classes declaration --- .../include/abstract_actor.h | 33 +++++++++++++++++ .../include/abstract_channel.h | 17 +++++++++ .../include/abstract_port.h | 35 +++++++++++++++++++ .../include/abstract_port_implementation.h | 27 ++++++++++++++ .../include/multiprocessing.h | 21 +++++++++++ .../include/process_model.h | 12 +++++++ .../include/runtime.h | 11 ++++++ .../cpp_message_infrastructure/include/shm.h | 20 +++++++++++ .../include/shmem_channel.h | 14 ++++++++ .../include/shmem_port.h | 18 ++++++++++ .../include/utils.h | 18 ++++++++++ 11 files changed, 226 insertions(+) create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h new file mode 100644 index 000000000..eafd1e352 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef ABSTACT_ACTOR_H_ +#define ABSTACT_ACTOR_H_ + +class AbstractActor { + public: + virtual int GetPid() = 0; + virtual int Stop() = 0; + virtual int Pause() = 0; + + int pid_; +}; + +class PosixActor : public AbstractActor { + public: + explicit PosixActor(int pid){ + this->pid_ = pid; + } + int GetPid(){ + return this->pid_; + }; + int Stop(){ + return 0; + }; + int Pause(){ + return 0; + }; +}; + +#endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h new file mode 100644 index 000000000..533c5fcce --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef ABSTACT_CHANNEL_H_ +#define ABSTACT_CHANNEL_H_ + +#include "abstract_port.h" +#include "utils.h" + +class AbstractChannel { + public: + AbstractSendPort *src_port_ = NULL; + AbstractSendPort *dst_port_ = NULL; +}; + +#endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h new file mode 100644 index 000000000..f43f3d49f --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef ABSTRACT_PORT_H_ +#define ABSTRACT_PORT_H_ + +#include +#include + +#include "shm.h" +#include "utils.h" + +class AbstractPort { + public: + virtual int Start() = 0; + virtual int Join() = 0; + + std::string name_; + DataType dtype_; + std::vector shape_; + size_t size_; +}; + +class AbstractSendPort : public AbstractPort { + public: + virtual int Send() = 0; +}; + +class AbstractRecvPort : public AbstractPort { + public: + virtual int Recv() = 0; +}; + +#endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h new file mode 100644 index 000000000..5f247435a --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef ABSTRACT_PORT_IMPLEMENTATION_H_ +#define ABSTRACT_PORT_IMPLEMENTATION_H_ + +#include + +#include "abstract_port.h" +#include "process_model.h" + +class AbstractPortImplementation { + public: + int Start(); + int Join(); + std::vector GetShape(); + std::vector GetPorts(); + + DataType dtype_; + std::vector shape_; + size_t size_; + ProcessModel process_model_; + std::vector ports_; +}; + +#endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h new file mode 100644 index 000000000..440bfc2c7 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h @@ -0,0 +1,21 @@ +#ifndef MULTIPROCESSING_H_ +#define MULTIPROCESSING_H_ + +#include +#include + +#include "abstract_actor.h" +#include "shm.h" + +class MultiProcessing { + public: + // stop each actor in vector actors; + void Stop(); + void BuildActor(std::function); + void CheckActor(); + private: + std::vector actors_; + //SharedMemManager shmm_; +}; + +#endif diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h new file mode 100644 index 000000000..d0a72ea61 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h @@ -0,0 +1,12 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef PROCESS_MODEL_H_ +#define PROCESS_MODEL_H_ + +class ProcessModel { + +}; + +#endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h new file mode 100644 index 000000000..d16a2c6ca --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h @@ -0,0 +1,11 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef RUNTIME_H_ +#define RUNTIME_H_ + +class Runtime { +}; + +#endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h new file mode 100644 index 000000000..29cfd6612 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h @@ -0,0 +1,20 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef SHM_H_ +#define SHM_H_ + +#include +#include +#include +#include +#include +#include +#include + +class SharedMemory { + +}; + +#endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h new file mode 100644 index 000000000..d58707426 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef SHMEM_CHANNEL_H_ +#define SHMEM_CHANNEL_H_ + +#include "abstract_channel.h" + +class ShmemChannel : public AbstractChannel { + +}; + +#endif diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h new file mode 100644 index 000000000..7b7e96075 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef SHMEM_PORT_H_ +#define SHMEM_PORT_H_ + +#include "abstract_port.h" + +class ShmemSendPort : public AbstractSendPort { + +}; + +class ShmemRecvPort : public AbstractRecvPort { + +}; + +#endif diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h new file mode 100644 index 000000000..a069fb41d --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#ifndef UTILS_H_ +#define UTILS_H_ + +enum ChannelType { + ShmemChannel = 0, + RpcChannel = 1, + DdsChannel = 2 +}; + +enum DataType { + // dtype +}; + +#endif \ No newline at end of file From 3e50a99f7a52c1f6c7befebb1108c9857cdf2bb6 Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 12:13:48 +0800 Subject: [PATCH 03/10] Add multiprocessing example & document for using py_wrapper --- .../cpp_message_infrastructure/CMakeLists.txt | 16 ++++++++ .../cpp_message_infrastructure/docs/.gitkeep | 0 .../docs/run_example.md | 13 +++++++ .../cpp_message_infrastructure/setenv.sh | 2 + .../src/abstract_port_implementation.cc | 25 +++++++++++++ .../src/multiprocessing.cc | 37 +++++++++++++++++++ .../src/py_wrapper.cc | 15 ++++++++ .../cpp_message_infrastructure/test/.gitkeep | 0 .../test/test_example.py | 16 ++++++++ 9 files changed, 124 insertions(+) create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/docs/.gitkeep create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/docs/run_example.md create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/setenv.sh create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/test/.gitkeep create mode 100644 src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt b/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt new file mode 100644 index 000000000..4b4db4aaf --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 2.8.3) +project(message_passing) + +set (CMAKE_CXX_STANDARD 17) +include_directories(include) + +file (GLOB MULTI_PROC_SRCS "src/multiprocessing.cc") + +file (GLOB PY_WRAPPER "src/py_wrapper.cc") + +add_subdirectory(pybind11) + +add_library(multi_processing SHARED ${MULTI_PROC_SRCS}) + +pybind11_add_module(PyWrapper ${PY_WRAPPER}) +target_link_libraries(PyWrapper PRIVATE multi_processing) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/docs/.gitkeep b/src/lava/magma/runtime/cpp_message_infrastructure/docs/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/docs/run_example.md b/src/lava/magma/runtime/cpp_message_infrastructure/docs/run_example.md new file mode 100644 index 000000000..560fa3f6b --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/docs/run_example.md @@ -0,0 +1,13 @@ +# An Example for PYWrapper + +*Welcome to the messaging refactory project, and this will show how an example run* + +``` +mkdir build +cd build +cmake .. +make +cd .. +source setenv.sh +python test/test_example.py +``` diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/setenv.sh b/src/lava/magma/runtime/cpp_message_infrastructure/setenv.sh new file mode 100644 index 000000000..f8d8b5786 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/setenv.sh @@ -0,0 +1,2 @@ +export PYTHONPATH=${PWD}/build +export LD_LIBRARY_PATH=${PWD}/build diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc new file mode 100644 index 000000000..48fe3cb9e --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + +#include "abstract_port_implementation.h" + +int AbstractPortImplementation::Start() { + for (auto port : this->ports_){ + port.Start(); + } +} + +int AbstractPortImplementation::Join() { + for (auto port : this->ports_){ + port.Join(); + } +} + +std::vector AbstractPortImplementation::GetShape() { + return this->shape_; +} + +std::vector AbstractPortImplementation::GetPorts() { + return this->ports_; +} \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc new file mode 100644 index 000000000..23891ad10 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc @@ -0,0 +1,37 @@ +#include "multiprocessing.h" + +#include +#include +#include + +#define CPP_INFO "[CPP_INFO] " + +void MultiProcessing::BuildActor(std::function target_fn) { + pid_t pid = fork(); + + if (pid < 0) { + std::cout << CPP_INFO << "cannot allocate pid\n"; + } + + if (pid > 0) { + std::cout << CPP_INFO << "parent, create actor\n"; + AbstractActor *actor = new PosixActor(pid); + actors_.push_back(actor); + } + + if (pid == 0) { + std::cout << CPP_INFO << "child, new process\n"; + target_fn(); + exit(0); + } + +} + +void MultiProcessing::Stop() { +} + +void MultiProcessing::CheckActor() { + for(auto actor : actors_){ + std::cout << CPP_INFO << actor->pid_ << std::endl; + } +} diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc new file mode 100644 index 000000000..deff4c04e --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc @@ -0,0 +1,15 @@ +#include +#include + +#include "multiprocessing.h" +//#include "abstract_port_implementation.h" + +namespace py = pybind11; + +PYBIND11_MODULE(PyWrapper, m) { + py::class_ (m, "MultiProcessing") + .def(py::init<>()) + .def("build_actor", &MultiProcessing::BuildActor) + .def("check_actor", &MultiProcessing::CheckActor) + .def("stop", &MultiProcessing::Stop); +} diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/test/.gitkeep b/src/lava/magma/runtime/cpp_message_infrastructure/test/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py b/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py new file mode 100644 index 000000000..1aca91ca8 --- /dev/null +++ b/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py @@ -0,0 +1,16 @@ +from PyWrapper import MultiProcessing +import time + + +def print_hello(): + print("hello") +def main(): + mp = MultiProcessing() + for i in range(5): + mp.build_actor(print_hello) + + mp.check_actor() + +main() +print("sleep 5") +time.sleep(5) From c267de44303fba102b6e2558403ce64517d064bf Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 12:40:56 +0800 Subject: [PATCH 04/10] Add License header for some code files --- .../cpp_message_infrastructure/include/multiprocessing.h | 4 ++++ .../cpp_message_infrastructure/src/multiprocessing.cc | 4 ++++ .../runtime/cpp_message_infrastructure/src/py_wrapper.cc | 4 ++++ .../runtime/cpp_message_infrastructure/test/test_example.py | 5 ++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h index 440bfc2c7..d8791cd26 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h @@ -1,3 +1,7 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + #ifndef MULTIPROCESSING_H_ #define MULTIPROCESSING_H_ diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc index 23891ad10..ede0c885f 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc @@ -1,3 +1,7 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + #include "multiprocessing.h" #include diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc index deff4c04e..318f4316b 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc @@ -1,3 +1,7 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// See: https://spdx.org/licenses/ + #include #include diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py b/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py index 1aca91ca8..e4b9585a8 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py +++ b/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py @@ -1,7 +1,10 @@ +# Copyright (C) 2021 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause +# See: https://spdx.org/licenses/ + from PyWrapper import MultiProcessing import time - def print_hello(): print("hello") def main(): From 789caf07d4c08a950418add3611db699ee2739dc Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 12:52:13 +0800 Subject: [PATCH 05/10] Follow Google coding style for test/test_example.py file --- .../runtime/cpp_message_infrastructure/test/test_example.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py b/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py index e4b9585a8..5936cacf2 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py +++ b/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py @@ -5,8 +5,11 @@ from PyWrapper import MultiProcessing import time + def print_hello(): print("hello") + + def main(): mp = MultiProcessing() for i in range(5): @@ -14,6 +17,7 @@ def main(): mp.check_actor() + main() print("sleep 5") time.sleep(5) From ed172e429a64d393ea2673bfb477f02563360614 Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 13:19:14 +0800 Subject: [PATCH 06/10] Update wrapper name to MessageInfrastructurePywrapper --- .../magma/runtime/cpp_message_infrastructure/CMakeLists.txt | 4 ++-- .../runtime/cpp_message_infrastructure/docs/run_example.md | 2 +- .../runtime/cpp_message_infrastructure/src/py_wrapper.cc | 2 +- .../runtime/cpp_message_infrastructure/test/test_example.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt b/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt index 4b4db4aaf..0d4f5a8f6 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt +++ b/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt @@ -12,5 +12,5 @@ add_subdirectory(pybind11) add_library(multi_processing SHARED ${MULTI_PROC_SRCS}) -pybind11_add_module(PyWrapper ${PY_WRAPPER}) -target_link_libraries(PyWrapper PRIVATE multi_processing) +pybind11_add_module(MessageInfrastructurePywrapper ${PY_WRAPPER}) +target_link_libraries(MessageInfrastructurePywrapper PRIVATE multi_processing) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/docs/run_example.md b/src/lava/magma/runtime/cpp_message_infrastructure/docs/run_example.md index 560fa3f6b..448b4a188 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/docs/run_example.md +++ b/src/lava/magma/runtime/cpp_message_infrastructure/docs/run_example.md @@ -1,4 +1,4 @@ -# An Example for PYWrapper +# An Example for MessageInfrastructurePywrapper *Welcome to the messaging refactory project, and this will show how an example run* diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc index 318f4316b..02b8292e5 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc @@ -10,7 +10,7 @@ namespace py = pybind11; -PYBIND11_MODULE(PyWrapper, m) { +PYBIND11_MODULE(MessageInfrastructurePywrapper, m) { py::class_ (m, "MultiProcessing") .def(py::init<>()) .def("build_actor", &MultiProcessing::BuildActor) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py b/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py index 5936cacf2..40ba6aacf 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py +++ b/src/lava/magma/runtime/cpp_message_infrastructure/test/test_example.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause # See: https://spdx.org/licenses/ -from PyWrapper import MultiProcessing +from MessageInfrastructurePywrapper import MultiProcessing import time From 5265c602686315dbe3ffb558bf65e72ce70206b1 Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 13:49:27 +0800 Subject: [PATCH 07/10] Add alias for pointer type & use smart pointers --- .../cpp_message_infrastructure/include/abstract_actor.h | 3 +++ .../cpp_message_infrastructure/include/abstract_channel.h | 5 +++-- .../cpp_message_infrastructure/include/abstract_port.h | 4 ++++ .../include/abstract_port_implementation.h | 4 ++-- .../cpp_message_infrastructure/include/multiprocessing.h | 2 +- .../src/abstract_port_implementation.cc | 6 +++--- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h index eafd1e352..4bc224ce2 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h @@ -30,4 +30,7 @@ class PosixActor : public AbstractActor { }; }; +using ActorPtr = AbstractActor *; +using PosixActorPtr = PosixActor *; + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h index 533c5fcce..b92c91cf5 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h @@ -7,11 +7,12 @@ #include "abstract_port.h" #include "utils.h" +#include class AbstractChannel { public: - AbstractSendPort *src_port_ = NULL; - AbstractSendPort *dst_port_ = NULL; + std::shared_ptr src_port_; + std::shared_ptr dst_port_; }; #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h index f43f3d49f..56c4ac777 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h @@ -32,4 +32,8 @@ class AbstractRecvPort : public AbstractPort { virtual int Recv() = 0; }; +using PortPtr = AbstractPort *; +using SendPortPtr = AbstractSendPort *; +using RecvPortPtr = AbstractRecvPort *; + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h index 5f247435a..e83b4302f 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h @@ -15,13 +15,13 @@ class AbstractPortImplementation { int Start(); int Join(); std::vector GetShape(); - std::vector GetPorts(); + std::vector GetPorts(); DataType dtype_; std::vector shape_; size_t size_; ProcessModel process_model_; - std::vector ports_; + std::vector ports_; }; #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h index d8791cd26..69d3298d1 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h @@ -18,7 +18,7 @@ class MultiProcessing { void BuildActor(std::function); void CheckActor(); private: - std::vector actors_; + std::vector actors_; //SharedMemManager shmm_; }; diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc index 48fe3cb9e..9c6b38b53 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc @@ -6,13 +6,13 @@ int AbstractPortImplementation::Start() { for (auto port : this->ports_){ - port.Start(); + port->Start(); } } int AbstractPortImplementation::Join() { for (auto port : this->ports_){ - port.Join(); + port->Join(); } } @@ -20,6 +20,6 @@ std::vector AbstractPortImplementation::GetShape() { return this->shape_; } -std::vector AbstractPortImplementation::GetPorts() { +std::vector AbstractPortImplementation::GetPorts() { return this->ports_; } \ No newline at end of file From 5548d96a5f4b699233ac508bbddc59adeef8ee00 Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 14:26:15 +0800 Subject: [PATCH 08/10] Add message_infrastructure namespace --- .../cpp_message_infrastructure/include/abstract_actor.h | 4 ++++ .../cpp_message_infrastructure/include/abstract_channel.h | 4 ++++ .../cpp_message_infrastructure/include/abstract_port.h | 4 ++++ .../include/abstract_port_implementation.h | 4 ++++ .../cpp_message_infrastructure/include/multiprocessing.h | 4 ++++ .../cpp_message_infrastructure/include/process_model.h | 4 ++++ .../runtime/cpp_message_infrastructure/include/runtime.h | 4 ++++ .../magma/runtime/cpp_message_infrastructure/include/shm.h | 4 ++++ .../cpp_message_infrastructure/include/shmem_channel.h | 4 ++++ .../runtime/cpp_message_infrastructure/include/shmem_port.h | 4 ++++ .../runtime/cpp_message_infrastructure/include/utils.h | 4 ++++ .../src/abstract_port_implementation.cc | 6 +++++- .../cpp_message_infrastructure/src/multiprocessing.cc | 6 +++++- .../runtime/cpp_message_infrastructure/src/py_wrapper.cc | 4 ++++ 14 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h index 4bc224ce2..c69da1ab4 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h @@ -5,6 +5,8 @@ #ifndef ABSTACT_ACTOR_H_ #define ABSTACT_ACTOR_H_ +namespace message_infrastrature{ + class AbstractActor { public: virtual int GetPid() = 0; @@ -33,4 +35,6 @@ class PosixActor : public AbstractActor { using ActorPtr = AbstractActor *; using PosixActorPtr = PosixActor *; +} // namespace message_infrastrature + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h index b92c91cf5..c9bd050f4 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h @@ -9,10 +9,14 @@ #include "utils.h" #include +namespace message_infrastrature{ + class AbstractChannel { public: std::shared_ptr src_port_; std::shared_ptr dst_port_; }; +} // namespace message_infrastrature + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h index 56c4ac777..a1f5dd742 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h @@ -11,6 +11,8 @@ #include "shm.h" #include "utils.h" +namespace message_infrastrature{ + class AbstractPort { public: virtual int Start() = 0; @@ -36,4 +38,6 @@ using PortPtr = AbstractPort *; using SendPortPtr = AbstractSendPort *; using RecvPortPtr = AbstractRecvPort *; +} // namespace message_infrastrature + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h index e83b4302f..72c517b88 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h @@ -10,6 +10,8 @@ #include "abstract_port.h" #include "process_model.h" +namespace message_infrastrature{ + class AbstractPortImplementation { public: int Start(); @@ -24,4 +26,6 @@ class AbstractPortImplementation { std::vector ports_; }; +} // namespace message_infrastrature + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h index 69d3298d1..1f8989995 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h @@ -11,6 +11,8 @@ #include "abstract_actor.h" #include "shm.h" +namespace message_infrastrature{ + class MultiProcessing { public: // stop each actor in vector actors; @@ -22,4 +24,6 @@ class MultiProcessing { //SharedMemManager shmm_; }; +} // namespace message_infrastrature + #endif diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h index d0a72ea61..3ebaf831d 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h @@ -5,8 +5,12 @@ #ifndef PROCESS_MODEL_H_ #define PROCESS_MODEL_H_ +namespace message_infrastrature{ + class ProcessModel { }; +} // namespace message_infrastrature + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h index d16a2c6ca..92c908114 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h @@ -5,7 +5,11 @@ #ifndef RUNTIME_H_ #define RUNTIME_H_ +namespace message_infrastrature{ + class Runtime { }; +} // namespace message_infrastrature + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h index 29cfd6612..8331073df 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h @@ -13,8 +13,12 @@ #include #include +namespace message_infrastrature{ + class SharedMemory { }; +} // namespace message_infrastrature + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h index d58707426..ee5b7e4bb 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h @@ -7,8 +7,12 @@ #include "abstract_channel.h" +namespace message_infrastrature{ + class ShmemChannel : public AbstractChannel { }; +} // namespace message_infrastrature + #endif diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h index 7b7e96075..ae692e28d 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h @@ -7,6 +7,8 @@ #include "abstract_port.h" +namespace message_infrastrature{ + class ShmemSendPort : public AbstractSendPort { }; @@ -15,4 +17,6 @@ class ShmemRecvPort : public AbstractRecvPort { }; +} // namespace message_infrastrature + #endif diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h index a069fb41d..95d12219a 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h @@ -5,6 +5,8 @@ #ifndef UTILS_H_ #define UTILS_H_ +namespace message_infrastrature{ + enum ChannelType { ShmemChannel = 0, RpcChannel = 1, @@ -15,4 +17,6 @@ enum DataType { // dtype }; +} // namespace message_infrastrature + #endif \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc index 9c6b38b53..94328d325 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc @@ -4,6 +4,8 @@ #include "abstract_port_implementation.h" +namespace message_infrastrature{ + int AbstractPortImplementation::Start() { for (auto port : this->ports_){ port->Start(); @@ -22,4 +24,6 @@ std::vector AbstractPortImplementation::GetShape() { std::vector AbstractPortImplementation::GetPorts() { return this->ports_; -} \ No newline at end of file +} + +} // namespace message_infrastrature \ No newline at end of file diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc index ede0c885f..efb625c3c 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc @@ -8,6 +8,8 @@ #include #include +namespace message_infrastrature{ + #define CPP_INFO "[CPP_INFO] " void MultiProcessing::BuildActor(std::function target_fn) { @@ -19,7 +21,7 @@ void MultiProcessing::BuildActor(std::function target_fn) { if (pid > 0) { std::cout << CPP_INFO << "parent, create actor\n"; - AbstractActor *actor = new PosixActor(pid); + ActorPtr actor = new PosixActor(pid); actors_.push_back(actor); } @@ -39,3 +41,5 @@ void MultiProcessing::CheckActor() { std::cout << CPP_INFO << actor->pid_ << std::endl; } } + +} // namespace message_infrastrature diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc index 02b8292e5..f2705f299 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc @@ -8,6 +8,8 @@ #include "multiprocessing.h" //#include "abstract_port_implementation.h" +namespace message_infrastrature{ + namespace py = pybind11; PYBIND11_MODULE(MessageInfrastructurePywrapper, m) { @@ -17,3 +19,5 @@ PYBIND11_MODULE(MessageInfrastructurePywrapper, m) { .def("check_actor", &MultiProcessing::CheckActor) .def("stop", &MultiProcessing::Stop); } + +} // namespace message_infrastrature From e0e09b15fbbda20e0aba2354936a8e14545448d3 Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 14:37:20 +0800 Subject: [PATCH 09/10] add space betwen namespace & { --- .../runtime/cpp_message_infrastructure/include/abstract_actor.h | 2 +- .../cpp_message_infrastructure/include/abstract_channel.h | 2 +- .../runtime/cpp_message_infrastructure/include/abstract_port.h | 2 +- .../include/abstract_port_implementation.h | 2 +- .../cpp_message_infrastructure/include/multiprocessing.h | 2 +- .../runtime/cpp_message_infrastructure/include/process_model.h | 2 +- .../magma/runtime/cpp_message_infrastructure/include/runtime.h | 2 +- src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h | 2 +- .../runtime/cpp_message_infrastructure/include/shmem_channel.h | 2 +- .../runtime/cpp_message_infrastructure/include/shmem_port.h | 2 +- .../magma/runtime/cpp_message_infrastructure/include/utils.h | 2 +- .../src/abstract_port_implementation.cc | 2 +- .../runtime/cpp_message_infrastructure/src/multiprocessing.cc | 2 +- .../magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h index c69da1ab4..c4aeab341 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_actor.h @@ -5,7 +5,7 @@ #ifndef ABSTACT_ACTOR_H_ #define ABSTACT_ACTOR_H_ -namespace message_infrastrature{ +namespace message_infrastrature { class AbstractActor { public: diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h index c9bd050f4..80c658066 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_channel.h @@ -9,7 +9,7 @@ #include "utils.h" #include -namespace message_infrastrature{ +namespace message_infrastrature { class AbstractChannel { public: diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h index a1f5dd742..4739933e6 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port.h @@ -11,7 +11,7 @@ #include "shm.h" #include "utils.h" -namespace message_infrastrature{ +namespace message_infrastrature { class AbstractPort { public: diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h index 72c517b88..5df045dcf 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/abstract_port_implementation.h @@ -10,7 +10,7 @@ #include "abstract_port.h" #include "process_model.h" -namespace message_infrastrature{ +namespace message_infrastrature { class AbstractPortImplementation { public: diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h index 1f8989995..9d6502879 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/multiprocessing.h @@ -11,7 +11,7 @@ #include "abstract_actor.h" #include "shm.h" -namespace message_infrastrature{ +namespace message_infrastrature { class MultiProcessing { public: diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h index 3ebaf831d..5371d6264 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/process_model.h @@ -5,7 +5,7 @@ #ifndef PROCESS_MODEL_H_ #define PROCESS_MODEL_H_ -namespace message_infrastrature{ +namespace message_infrastrature { class ProcessModel { diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h index 92c908114..fc5be9c18 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/runtime.h @@ -5,7 +5,7 @@ #ifndef RUNTIME_H_ #define RUNTIME_H_ -namespace message_infrastrature{ +namespace message_infrastrature { class Runtime { }; diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h index 8331073df..a4088de67 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/shm.h @@ -13,7 +13,7 @@ #include #include -namespace message_infrastrature{ +namespace message_infrastrature { class SharedMemory { diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h index ee5b7e4bb..b68ec6a1e 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_channel.h @@ -7,7 +7,7 @@ #include "abstract_channel.h" -namespace message_infrastrature{ +namespace message_infrastrature { class ShmemChannel : public AbstractChannel { diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h index ae692e28d..0073bf7d4 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/shmem_port.h @@ -7,7 +7,7 @@ #include "abstract_port.h" -namespace message_infrastrature{ +namespace message_infrastrature { class ShmemSendPort : public AbstractSendPort { diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h b/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h index 95d12219a..3f10ee193 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h +++ b/src/lava/magma/runtime/cpp_message_infrastructure/include/utils.h @@ -5,7 +5,7 @@ #ifndef UTILS_H_ #define UTILS_H_ -namespace message_infrastrature{ +namespace message_infrastrature { enum ChannelType { ShmemChannel = 0, diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc index 94328d325..a6f849156 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/abstract_port_implementation.cc @@ -4,7 +4,7 @@ #include "abstract_port_implementation.h" -namespace message_infrastrature{ +namespace message_infrastrature { int AbstractPortImplementation::Start() { for (auto port : this->ports_){ diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc index efb625c3c..59c6143bd 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/multiprocessing.cc @@ -8,7 +8,7 @@ #include #include -namespace message_infrastrature{ +namespace message_infrastrature { #define CPP_INFO "[CPP_INFO] " diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc index f2705f299..329663324 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc +++ b/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc @@ -8,7 +8,7 @@ #include "multiprocessing.h" //#include "abstract_port_implementation.h" -namespace message_infrastrature{ +namespace message_infrastrature { namespace py = pybind11; From aa2fd5d3efa2ace804e8f0fa17c74c6d8d8ed540 Mon Sep 17 00:00:00 2001 From: hexu1 Date: Fri, 5 Aug 2022 14:46:56 +0800 Subject: [PATCH 10/10] Change py_wrapper name to message_infrastructure_py_wrapper --- .../magma/runtime/cpp_message_infrastructure/CMakeLists.txt | 2 +- .../src/{py_wrapper.cc => message_infrastructure_py_wrapper.cc} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/lava/magma/runtime/cpp_message_infrastructure/src/{py_wrapper.cc => message_infrastructure_py_wrapper.cc} (100%) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt b/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt index 0d4f5a8f6..6002ec4e6 100644 --- a/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt +++ b/src/lava/magma/runtime/cpp_message_infrastructure/CMakeLists.txt @@ -6,7 +6,7 @@ include_directories(include) file (GLOB MULTI_PROC_SRCS "src/multiprocessing.cc") -file (GLOB PY_WRAPPER "src/py_wrapper.cc") +file (GLOB PY_WRAPPER "src/message_infrastructure_py_wrapper.cc") add_subdirectory(pybind11) diff --git a/src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc b/src/lava/magma/runtime/cpp_message_infrastructure/src/message_infrastructure_py_wrapper.cc similarity index 100% rename from src/lava/magma/runtime/cpp_message_infrastructure/src/py_wrapper.cc rename to src/lava/magma/runtime/cpp_message_infrastructure/src/message_infrastructure_py_wrapper.cc