-
Notifications
You must be signed in to change notification settings - Fork 119
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
Extend mpi support #1292
base: main
Are you sure you want to change the base?
Extend mpi support #1292
Conversation
…lreduce (for MPI_MAX op)
…when used with min/max ops
…rap replacement of primal code in op check
888445a
to
ddb792d
Compare
@@ -136,7 +136,7 @@ const StringSet<> InactiveGlobals = { | |||
"_ZTVN10__cxxabiv121__vmi_class_type_infoE" | |||
}; | |||
|
|||
const llvm::StringMap<size_t> MPIInactiveCommAllocators = { | |||
const llvm::StringMap<size_t> MPIInactiveAllocators = { |
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.
I've changed the name because I've added some non-comm allocator routines.
@@ -147,7 +147,8 @@ class AdjointGenerator | |||
} | |||
|
|||
llvm::Value *MPI_TYPE_SIZE(llvm::Value *DT, llvm::IRBuilder<> &B, | |||
llvm::Type *intType) { | |||
llvm::Type *intType, | |||
llvm::BasicBlock *allocBlock = nullptr) { |
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.
When handling MPI_Allreduce using min/max op, I replace the call in the primal code with an MPI_Allreduce using the minloc/maxloc (+ some loops for copying data, and mallocs for temporary arrays). I'm not sure if it is the best strategy, but I construct this replacement code inside a function, similar to getOInsertCheckedFree
. Because I'm constructing the replacement code in a function I added the extra parameter allocaBlock
to MPI_TYPE_SIZE etc so that I could use them in this case.
BuilderZ.setFastMathFlags(getFast()); | ||
|
||
enum class MPI_Op_Kind { SUM, MIN, MAX, MINLOC, MAXLOC, UNKNOWN }; |
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.
I've added a few helper functions and maps at the start of handleMPI that I extracted from MPI_Allreduce handling, and extended.
// op in the primal code | ||
CallInst *newNewCall; | ||
Value *recvlocbuf; | ||
if (opKind == MPI_Op_Kind::MIN || opKind == MPI_Op_Kind::MAX) { |
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.
This is the block where I construct the replacement code for MPI_Allreduce when the op is min/max, and then replace the primal call. The replacement code is constructed in a function (I took a similar approach as getOrInsertCheckedFree. Is this the best approach? Or is it better to generate the code in-place?
BuilderZ.CreateCall(mpi_allreduce_comploc_fp->getFunctionType(), | ||
mpi_allreduce_comploc_fp, args); | ||
|
||
gutils->replaceAWithB(newCall, newNewCall); |
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.
Is this the best way to replace the primal code?
6616fbb
to
8bc9729
Compare
* Support complex knownops * Update Project.toml
No description provided.