-
Notifications
You must be signed in to change notification settings - Fork 16
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
MPI Standalone Implementation - First Bits #46
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7a0a305
adding helloworld example code
csegarragonz cd2c581
skeleton of native mpi compilation
csegarragonz a4f6867
adding a task to run mpi-specific applications
csegarragonz feb7e8e
adding executor script
csegarragonz 6e97ea2
adding new faabric mpi main macro
csegarragonz 0d17cd6
adding scale-up and scale-down options through docker-compose and exp…
csegarragonz 732afe4
adding native mpi_executor in lieu of the overly complex macro
csegarragonz 5ae234d
adding a different target for the native mpi build, and renamed for d…
csegarragonz 0e3bd08
updates to the executor to support being linked as a dynamic library
csegarragonz b70c9d8
added option to run endpoint thread in background
csegarragonz 37919c0
helloworld working fine with one process
csegarragonz b2e2b71
helloworld working with >1 processes
csegarragonz c22aa51
finished automation for deployment and cleanup of MPI tasks
csegarragonz 6f965c9
updating the docs
csegarragonz 7534a0d
fixes
csegarragonz 448c1f3
gracefuly exit
csegarragonz 38cd510
adding build in test file
csegarragonz 8622705
fixes
csegarragonz a7aa748
adding checks in dev commands
csegarragonz 6f0afcd
addiing link directory as cmake would find pistache
csegarragonz 1f6e8a3
changes suggested in pr comments
csegarragonz 4efc512
switched deployment method to use custom docker compose file and dock…
csegarragonz 35f3447
reverting changes in endpoint, and update the docs
csegarragonz 2bd711f
moving to top-level directory to encapsulate things
csegarragonz 1ecd8f4
modified cmake and added new check in actions
csegarragonz ca25dad
building container each new release
csegarragonz 027af25
tiny typo
csegarragonz 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 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
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,29 @@ | ||
FROM faasm/grpc-root:0.0.16 | ||
ARG FAABRIC_VERSION | ||
|
||
# Note - the version of grpc-root here can be quite behind as it's rebuilt very | ||
# rarely | ||
|
||
# Redis | ||
RUN apt install -y \ | ||
libpython3-dev \ | ||
python3-dev \ | ||
python3-pip \ | ||
python3-venv \ | ||
redis-tools | ||
|
||
# Put the code in place | ||
WORKDIR /code | ||
RUN git clone -b v${FAABRIC_VERSION} https://github.com/faasm/faabric | ||
|
||
WORKDIR /code/faabric | ||
|
||
RUN pip3 install invoke | ||
|
||
# Build MPI native lib | ||
RUN inv dev.cmake --shared | ||
RUN inv dev.cc faabricmpi_native --shared | ||
RUN inv dev.install faabricmpi_native --shared | ||
|
||
# Build examples | ||
RUN inv examples.build |
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,20 @@ | ||
# Native MPI execution in Faabric | ||
|
||
Faabric supports linking MPI binaries against our custom MPI implementation | ||
used in [Faasm](https://github.com/faasm/faasm). This way, you can test the | ||
compliance of your MPI application with our API (a subset of the standard) | ||
without the burden of cross-compiling to WebAssembly. | ||
|
||
To run native MPI applications you need to first modify your binary matching | ||
the examples provided, and then build the worker image running: | ||
``` | ||
inv container.build-mpi-native | ||
csegarragonz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
Then you may run arbitrary deployments setting the right values in | ||
`mpi-native/mpi-native.env` and running `./mpi-native/run.sh`. | ||
|
||
You may remove all stopped and running container images with: | ||
```bash | ||
./mpi-native/clean.sh | ||
``` |
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,62 @@ | ||
#include <faabric/util/logging.h> | ||
|
||
#include <faabric/mpi-native/MpiExecutor.h> | ||
#include <faabric/mpi/mpi.h> | ||
|
||
int main(int argc, char** argv) | ||
csegarragonz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
auto logger = faabric::util::getLogger(); | ||
auto& scheduler = faabric::scheduler::getScheduler(); | ||
auto& conf = faabric::util::getSystemConfig(); | ||
|
||
// Global configuration | ||
conf.maxNodes = 1; | ||
conf.maxNodesPerFunction = 1; | ||
|
||
bool __isRoot; | ||
int __worldSize; | ||
if (argc < 2) { | ||
logger->debug("Non-root process started"); | ||
__isRoot = false; | ||
} else if (argc < 3) { | ||
logger->error("Root process started without specifying world size!"); | ||
return 1; | ||
} else { | ||
logger->debug("Root process started"); | ||
__worldSize = std::stoi(argv[2]); | ||
__isRoot = true; | ||
logger->debug("MPI World Size: {}", __worldSize); | ||
} | ||
|
||
// Pre-load message to bootstrap execution | ||
if (__isRoot) { | ||
faabric::Message msg = faabric::util::messageFactory("mpi", "exec"); | ||
msg.set_mpiworldsize(__worldSize); | ||
scheduler.callFunction(msg); | ||
} | ||
|
||
{ | ||
faabric::executor::SingletonPool p; | ||
p.startPool(); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int faabric::executor::mpiFunc() | ||
{ | ||
auto logger = faabric::util::getLogger(); | ||
logger->info("Hello world from Faabric MPI Main!"); | ||
|
||
MPI_Init(NULL, NULL); | ||
|
||
int rank, worldSize; | ||
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | ||
MPI_Comm_size(MPI_COMM_WORLD, &worldSize); | ||
|
||
logger->info("Hello faabric from process {} of {}", rank + 1, worldSize); | ||
|
||
MPI_Finalize(); | ||
|
||
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
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,44 @@ | ||
#pragma once | ||
|
||
#include <faabric/endpoint/FaabricEndpoint.h> | ||
#include <faabric/executor/FaabricExecutor.h> | ||
#include <faabric/executor/FaabricPool.h> | ||
#include <faabric/scheduler/Scheduler.h> | ||
#include <faabric/util/logging.h> | ||
|
||
namespace faabric::executor { | ||
class MpiExecutor final : public faabric::executor::FaabricExecutor | ||
{ | ||
public: | ||
explicit MpiExecutor(); | ||
|
||
bool doExecute(faabric::Message& msg) override; | ||
|
||
void postFinishCall() override; | ||
|
||
void postFinish() override; | ||
}; | ||
|
||
class SingletonPool : public faabric::executor::FaabricPool | ||
{ | ||
public: | ||
SingletonPool(); | ||
|
||
~SingletonPool(); | ||
|
||
void startPool(); | ||
|
||
protected: | ||
std::unique_ptr<FaabricExecutor> createExecutor(int threadIdx) override | ||
{ | ||
return std::make_unique<MpiExecutor>(); | ||
} | ||
|
||
private: | ||
faabric::endpoint::FaabricEndpoint endpoint; | ||
faabric::scheduler::Scheduler& scheduler; | ||
}; | ||
|
||
extern faabric::Message* executingCall; | ||
extern int __attribute__((weak)) mpiFunc(); | ||
} |
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,17 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
THIS_DIR=$(dirname $(readlink -f $0)) | ||
PROJ_ROOT=${THIS_DIR}/.. | ||
|
||
pushd ${PROJ_ROOT} >> /dev/null | ||
|
||
source ./mpi-native/mpi-native.env | ||
|
||
docker-compose \ | ||
--file ${COMPOSE_FILE} \ | ||
--env-file ${ENV_FILE} \ | ||
build | ||
|
||
popd >> /dev/null |
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,17 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
THIS_DIR=$(dirname $(readlink -f $0)) | ||
PROJ_ROOT=${THIS_DIR}/.. | ||
|
||
pushd ${PROJ_ROOT} >> /dev/null | ||
|
||
source ./mpi-native/mpi-native.env | ||
|
||
docker-compose \ | ||
--file ${COMPOSE_FILE} \ | ||
--env-file ${ENV_FILE} \ | ||
down | ||
|
||
popd >> /dev/null |
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,34 @@ | ||
version: "3" | ||
|
||
services: | ||
redis: | ||
image: redis | ||
|
||
worker: | ||
image: ${FAABRIC_MPI_NATIVE_IMAGE} | ||
entrypoint: /code/faabric/examples/build/${MPI_EXAMPLE} | ||
working_dir: /code/faabric | ||
privileged: true | ||
environment: | ||
- LD_LIBRARY_PATH=/usr/local/lib:/build/faabric/install/lib | ||
- FUNCTION_STORAGE=local | ||
- LOG_LEVEL=debug | ||
- REDIS_STATE_HOST=redis | ||
- REDIS_QUEUE_HOST=redis | ||
depends_on: | ||
- redis | ||
|
||
master: | ||
image: ${FAABRIC_MPI_NATIVE_IMAGE} | ||
entrypoint: ['/code/faabric/examples/build/${MPI_EXAMPLE}', 'master', '${MPI_WORLD_SIZE}'] | ||
working_dir: /code/faabric | ||
privileged: true | ||
environment: | ||
- LD_LIBRARY_PATH=/usr/local/lib:/build/faabric/install/lib | ||
- FUNCTION_STORAGE=local | ||
- LOG_LEVEL=debug | ||
- REDIS_STATE_HOST=redis | ||
- REDIS_QUEUE_HOST=redis | ||
depends_on: | ||
- redis | ||
- worker |
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,10 @@ | ||
FAABRIC_VERSION=0.0.16 | ||
FAABRIC_MPI_NATIVE_IMAGE=faasm/faabric-mpi-native:0.0.16 | ||
COMPOSE_PROJECT_NAME=faabric-mpi | ||
|
||
COMPOSE_FILE="./mpi-native/mpi-native-docker-compose.yml" | ||
ENV_FILE="./mpi-native/mpi-native.env" | ||
|
||
# Deployment-specific | ||
MPI_WORLD_SIZE=3 | ||
MPI_EXAMPLE=mpi_helloworld |
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.
Nice, this looks relatively clean. Can you move faasm and faasm-toolchain to this version of Faabric to check they both still work after (or before) merging this?
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.
Here is faasm's and here the toolchain's. Should we merge those PRs?
Note that the toolchain one would not pass for some missmatch in the submodule build (which I am looking into) but afaik everything else worked fine (as to what this PR is concerned).