-
Notifications
You must be signed in to change notification settings - Fork 69
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 support in WAMR #731
Merged
Merged
MPI support in WAMR #731
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c7949cd
wamr: barebones mpi implmenetation to run lammps
csegarragonz 7e5e25f
wamr: mpi asynchronous api working
csegarragonz b6e6793
wamr: more mpi functions working
csegarragonz 13f9134
wamr: fix MPI_IN_PLACE detection to get MPI_Reduce to work properly
csegarragonz 9645cd9
wamr: implement more mpi calls, mpi_cart_create not working
csegarragonz 5c23490
wamr: fix mpi_cart_create
csegarragonz 35c684b
wamr: all mpi stubs for lammps in place
csegarragonz d2b5dbf
wamr: mpi tests passing locally
csegarragonz 2512abb
nits: self-review cleanup
csegarragonz c78d8d4
mpi: add logging
csegarragonz 6a346c0
wamr: unaligned write to make ubsan happy
csegarragonz 3bb1c75
wamr: make ubsan happy with mpi cart creation
csegarragonz c0ec8c1
wamr: more ubsan fixes
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 |
---|---|---|
|
@@ -3,17 +3,78 @@ | |
#include <faabric/util/bytes.h> | ||
#include <faabric/util/logging.h> | ||
#include <faabric/util/macros.h> | ||
|
||
#include <wamr/WAMRWasmModule.h> | ||
#include <wamr/native.h> | ||
#include <wasm/WasmExecutionContext.h> | ||
#include <wasm/WasmModule.h> | ||
#include <wasm/chaining.h> | ||
|
||
#include <wasm_export.h> | ||
|
||
using namespace faabric::scheduler; | ||
|
||
namespace wasm { | ||
|
||
static std::shared_ptr<faabric::state::StateKeyValue> getStateKV( | ||
int32_t* keyPtr, | ||
size_t size) | ||
{ | ||
WAMRWasmModule* module = getExecutingWAMRModule(); | ||
module->validateNativePointer(keyPtr, sizeof(int32_t)); | ||
|
||
const faabric::Message* call = &ExecutorContext::get()->getMsg(); | ||
char* key = reinterpret_cast<char*>(keyPtr); // second | ||
|
||
faabric::state::State& s = faabric::state::getGlobalState(); | ||
auto kv = s.getKV(call->user(), key, size); | ||
|
||
return kv; | ||
} | ||
|
||
/** | ||
* Await a chained function's completion | ||
*/ | ||
static int32_t __faasm_await_call_wrapper(wasm_exec_env_t exec_env, | ||
int32_t callId) | ||
{ | ||
SPDLOG_DEBUG("S - faasm_await_call {}", callId); | ||
|
||
int32_t result = wasm::awaitChainedCall((uint32_t)callId); | ||
return result; | ||
} | ||
|
||
/** | ||
* Chain a function by function pointer | ||
*/ | ||
static int32_t __faasm_chain_ptr_wrapper(wasm_exec_env_t exec_env, | ||
int32_t wasmFuncPtr, | ||
char* inBuff, | ||
int32_t inLen) | ||
{ | ||
SPDLOG_DEBUG("S - faasm_chain_ptr {} {} {}", wasmFuncPtr, inBuff, inLen); | ||
|
||
faabric::Message& call = ExecutorContext::get()->getMsg(); | ||
std::vector<uint8_t> inputData(BYTES(inBuff), BYTES(inBuff) + inLen); | ||
return makeChainedCall(call.function(), wasmFuncPtr, nullptr, inputData); | ||
} | ||
|
||
static void __faasm_pull_state_wrapper(wasm_exec_env_t execEnv, | ||
int32_t* keyPtr, | ||
int32_t stateLen) | ||
{ | ||
auto kv = getStateKV(keyPtr, stateLen); | ||
SPDLOG_DEBUG("S - pull_state - {} {}", kv->key, stateLen); | ||
|
||
kv->pull(); | ||
} | ||
|
||
static void __faasm_push_state_wrapper(wasm_exec_env_t execEnv, int32_t* keyPtr) | ||
{ | ||
auto kv = getStateKV(keyPtr, 0); | ||
SPDLOG_DEBUG("S - push_state - {}", kv->key); | ||
kv->pushFull(); | ||
} | ||
|
||
/** | ||
* Read the function input | ||
*/ | ||
|
@@ -51,38 +112,13 @@ static void __faasm_write_output_wrapper(wasm_exec_env_t exec_env, | |
call.set_outputdata(outBuff, outLen); | ||
} | ||
|
||
/** | ||
* Chain a function by function pointer | ||
*/ | ||
static int32_t __faasm_chain_ptr_wrapper(wasm_exec_env_t exec_env, | ||
int32_t wasmFuncPtr, | ||
char* inBuff, | ||
int32_t inLen) | ||
{ | ||
SPDLOG_DEBUG("S - faasm_chain_ptr {} {} {}", wasmFuncPtr, inBuff, inLen); | ||
|
||
faabric::Message& call = ExecutorContext::get()->getMsg(); | ||
std::vector<uint8_t> inputData(BYTES(inBuff), BYTES(inBuff) + inLen); | ||
return makeChainedCall(call.function(), wasmFuncPtr, nullptr, inputData); | ||
} | ||
|
||
/** | ||
* Await a chained function's completion | ||
*/ | ||
static int32_t __faasm_await_call_wrapper(wasm_exec_env_t exec_env, | ||
int32_t callId) | ||
{ | ||
SPDLOG_DEBUG("S - faasm_await_call {}", callId); | ||
|
||
int32_t result = wasm::awaitChainedCall((uint32_t)callId); | ||
return result; | ||
} | ||
|
||
static NativeSymbol ns[] = { | ||
REG_NATIVE_FUNC(__faasm_write_output, "($i)"), | ||
REG_NATIVE_FUNC(__faasm_read_input, "($i)i"), | ||
REG_NATIVE_FUNC(__faasm_chain_ptr, "(i$i)i"), | ||
REG_NATIVE_FUNC(__faasm_await_call, "(i)i"), | ||
REG_NATIVE_FUNC(__faasm_chain_ptr, "(i$i)i"), | ||
REG_NATIVE_FUNC(__faasm_pull_state, "(*i)"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have had to add a couple state functions as well for the MPI tests to pass. |
||
REG_NATIVE_FUNC(__faasm_push_state, "(*)"), | ||
REG_NATIVE_FUNC(__faasm_read_input, "($i)i"), | ||
REG_NATIVE_FUNC(__faasm_write_output, "($i)"), | ||
}; | ||
|
||
uint32_t getFaasmFunctionsApi(NativeSymbol** nativeSymbols) | ||
|
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
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.
These two methods were just moved somewhere else in the file to preserve alphabetical order.