forked from lava-nc/lava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from lava-nc/messaging_refactor_develop
Merging PR lava-nc#310 from upstream
- Loading branch information
Showing
22 changed files
with
459 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,4 @@ | ||
from MessageInfrastructurePywrapper import CppMultiProcessing | ||
from MessageInfrastructurePywrapper import SharedMemManager | ||
from MessageInfrastructurePywrapper import Actor | ||
from MessageInfrastructurePywrapper import ProcessType |
This file contains 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
28 changes: 28 additions & 0 deletions
28
...ntime/message_infrastructure/message_infrastructure/csrc/message_infrastructure_logging.h
This file contains 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 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// See: https://spdx.org/licenses/ | ||
|
||
#ifndef MESSAGE_INFRASTRUCTURE_LOGGING_H_ | ||
#define MESSAGE_INFRASTRUCTURE_LOGGING_H_ | ||
|
||
#include <stdio.h> | ||
#define LOG_MP (1) // log for multiprocessing | ||
|
||
|
||
#define LAVA_LOG(_cond, _fmt, ...) { \ | ||
if ((_cond)) { \ | ||
printf("[CPP INFO]" _fmt, ## __VA_ARGS__); \ | ||
} \ | ||
} | ||
|
||
#define LAVA_LOG_WARN(_cond, _fmt, ...) { \ | ||
if ((_cond)) { \ | ||
printf("[CPP WARNING]" _fmt, __FUNCTION__, ## __VA_ARGS__); \ | ||
} \ | ||
} | ||
|
||
#define LAVA_LOG_ERR(_fmt, ...) { \ | ||
printf("[CPP ERROR]" _fmt, __FUNCTION__, ## __VA_ARGS__); \ | ||
} | ||
|
||
#endif // MESSAGE_INFRASTRUCTURE_LOGGING_H_ |
This file contains 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 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 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
33 changes: 33 additions & 0 deletions
33
src/lava/magma/runtime/message_infrastructure/message_infrastructure/csrc/posix_actor.cc
This file contains 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,33 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// See: https://spdx.org/licenses/ | ||
|
||
#include "abstract_actor.h" | ||
#include "message_infrastructure_logging.h" | ||
|
||
#include <sys/wait.h> | ||
#include <sys/types.h> | ||
|
||
namespace message_infrastructure { | ||
|
||
int PosixActor::Stop() { | ||
int status; | ||
// TODO: Add the options can be as args of the function | ||
int options = 0; | ||
int ret = waitpid(this->pid_, &status, options); | ||
|
||
if (ret < 0) { | ||
LAVA_LOG_ERR("process %d waitpid error\n", this->pid_); | ||
return -1; | ||
} | ||
|
||
// Check the status | ||
return 0; | ||
|
||
} | ||
|
||
int PosixActor::Wait() { | ||
return 0; | ||
} | ||
|
||
} |
This file contains 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
18 changes: 18 additions & 0 deletions
18
src/lava/magma/runtime/message_infrastructure/message_infrastructure/factory.py
This file contains 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 @@ | ||
# Copyright (C) 2021-22 Intel Corporation | ||
# SPDX-License-Identifier: LGPL 2.1 or later | ||
# See: https://spdx.org/licenses/ | ||
from message_infrastructure.message_interface_enum import ActorType | ||
from message_infrastructure.multiprocessing import MultiProcessing | ||
|
||
"""Factory class to create the messaging infrastructure""" | ||
|
||
|
||
class MessageInfrastructureFactory: | ||
"""Creates the message infrastructure instance based on type""" | ||
@staticmethod | ||
def create(factory_type: ActorType): | ||
"""type of actor framework being chosen""" | ||
if factory_type == ActorType.MultiProcessing: | ||
return MultiProcessing() | ||
else: | ||
raise Exception("Unsupported factory_type") |
Oops, something went wrong.