Skip to content

Commit

Permalink
adding new faabric mpi main macro
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Jan 4, 2021
1 parent 27f5a5d commit 1d196dc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
53 changes: 51 additions & 2 deletions examples/mpi_helloworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,60 @@

#include <unistd.h>

int main()
#define FAABRIC_MPI_MAIN()
class _Executor final : public FaabricExecutor
{
faabric::util::initLogging();
public:
explicit _Executor() : FaabricExecutor(0) {}

bool doExecute(faabric::Message& msg) override
{
return _execMpiFunc();
}
};
class _SingletonPool : public FaabricPool
{
public:
explicit _SingletonPool() : FaabricPool(1) {}

std::unique_ptr<FaabricExecutor> createExecutor(int threadIdx) override
{
return std::make_unique<_Executor>(threadIdx);
}
};
int main(int argc, char** argv)
{
faabric::util::initLogging()
auto logger = faabric::util::getLogger();
auto scheduler = faabric::scheduler::getScheduler();
auto conf = faabric::util::getSystemConfig();

// Add host to the global set
scheduler.addHostToGlobalSet();

// Print current configuration
conf.print();

// Start the thread pool (nThreads == 1) and the state and function
// call servers.
_SingletonPool p();
p.startThreadPool();
p.startStateServer();
p.startFunctionCallServer();

const char* funcName = "hellompi";
auto msg = faabric::util::messageFactory("mpi", funcName);
msg.set_mpiworldsize(1);

// Shutdown
scheduler.clear();
p.shutdown();
}

bool _execMpiFunc(int argc, char** argv)

FAABRIC_MPI_MAIN
{
MPI_Init(NULL, NULL);

int rank, worldSize;
Expand Down
1 change: 1 addition & 0 deletions examples/mpi_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#define EXAMPLE_BUILD_PATH "/code/faabric/examples/build"


// Macro defined in include/faabric/executor/FaabricPool.h
// bool _execFunc(faabric::Message& msg)
FAABRIC_EXECUTOR
Expand Down

0 comments on commit 1d196dc

Please sign in to comment.