-
Notifications
You must be signed in to change notification settings - Fork 147
Support persistent MPI #2535
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
Draft
vchuravy
wants to merge
1
commit into
main
Choose a base branch
from
vc/persistent_mpi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+83
−14
Draft
Support persistent MPI #2535
Changes from all commits
Commits
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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -44,8 +44,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called, | |
| BuilderZ.setFastMathFlags(getFast()); | ||
|
|
||
| // MPI send / recv can only send float/integers | ||
| if (funcName == "PMPI_Isend" || funcName == "MPI_Isend" || | ||
| funcName == "PMPI_Irecv" || funcName == "MPI_Irecv") { | ||
| if (funcName == "PMPI_Isend" || funcName == "MPI_Isend" || funcName == "PMPI_Send_init" || funcName == "MPI_Send_init" || | ||
| funcName == "PMPI_Irecv" || funcName == "MPI_Irecv" || funcName == "PMPI_Recv_init" || funcName == "MPI_Recv_init") { | ||
| if (!gutils->isConstantInstruction(&call)) { | ||
| if (Mode == DerivativeMode::ReverseModePrimal || | ||
| Mode == DerivativeMode::ReverseModeCombined) { | ||
|
|
@@ -73,7 +73,8 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called, | |
| getMPIMemberPtr<MPI_Elem::Old>(BuilderZ, impialloc, impi)); | ||
| BuilderZ.CreateStore(impialloc, d_req); | ||
|
|
||
| if (funcName == "MPI_Isend" || funcName == "PMPI_Isend") { | ||
| if (funcName == "MPI_Isend" || funcName == "PMPI_Isend" || | ||
| funcName == "MPI_Send_init" || funcName == "PMPI_Send_init") { | ||
| Value *tysize = | ||
| MPI_TYPE_SIZE(gutils->getNewFromOriginal(call.getOperand(2)), | ||
| BuilderZ, call.getType(), called); | ||
|
|
@@ -134,12 +135,22 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called, | |
| BuilderZ.CreatePointerCast(comm, getInt8PtrTy(call.getContext())), | ||
| getMPIMemberPtr<MPI_Elem::Comm>(BuilderZ, impialloc, impi)); | ||
|
|
||
| MPI_CallType callType; | ||
| if (funcName == "MPI_Isend" || funcName == "PMPI_Isend") | ||
| callType = MPI_CallType::ISEND; | ||
| else if (funcName == "MPI_Irecv" || funcName == "PMPI_Irecv") | ||
| callType = MPI_CallType::IRECV; | ||
| else if (funcName == "MPI_Send_init" || funcName == "PMPI_Send_init") | ||
| callType = MPI_CallType::SEND_INIT; | ||
| else if (funcName == "MPI_Recv_init" || funcName == "PMPI_Recv_init") | ||
| callType = MPI_CallType::RECV_INIT; | ||
| else | ||
| assert(0 && "illegal mpi"); | ||
|
|
||
| BuilderZ.CreateStore( | ||
| ConstantInt::get( | ||
| Type::getInt8Ty(impialloc->getContext()), | ||
| (funcName == "MPI_Isend" || funcName == "PMPI_Isend") | ||
| ? (int)MPI_CallType::ISEND | ||
| : (int)MPI_CallType::IRECV), | ||
| (int)callType), | ||
| getMPIMemberPtr<MPI_Elem::Call>(BuilderZ, impialloc, impi)); | ||
| // TODO old | ||
| } | ||
|
|
@@ -2178,6 +2189,23 @@ void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called, | |
| return; | ||
| } | ||
|
|
||
| // Adjoint of MPI_Send is to place a MPI_send at the corresponding | ||
| // location in the reverse. | ||
| if (func == "MPI_Send" || func == "PMPI_Send") { | ||
| if (Mode == DerivativeMode::ReverseModeGradient || | ||
| Mode == DerivativeMode::ReverseModeCombined) { | ||
| IRBuilder<> Builder2(&call); | ||
| getReverseBuilder(Builder2); | ||
| auto callval = call.getCalledOperand(); | ||
| Value *args[] = { | ||
| lookup(gutils->getNewFromOriginal(call.getOperand(0)), Builder2)}; | ||
| Builder2.CreateCall(call.getFunctionType(), callval, args); | ||
|
Member
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. doesn't cover fwd mode, so we shouldn't return in that case |
||
| } | ||
| if (Mode == DerivativeMode::ReverseModeGradient) | ||
| eraseIfUnused(call, /*erase*/ true, /*check*/ false); | ||
| return; | ||
| } | ||
|
|
||
| // Remove free's in forward pass so the comm can be used in the reverse | ||
| // pass | ||
| if (funcName == "MPI_Comm_free" || funcName == "MPI_Comm_disconnect") { | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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.
did we miss this from earlier??
if so we should add a test
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.
Sorry this was a brain fart on my side this ought to be
MPI_Startnot MPI_Send