Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions enzyme/Enzyme/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1800,13 +1800,13 @@ llvm::Function *getOrInsertDifferentialMPI_Wait(llvm::Module &M,
Value *d_req = buff + 7;
d_req->setName("d_req");

auto isendfn = M.getFunction(getRenamedPerCallingConv(caller, "MPI_Isend"));
auto isendfn = M.getFunction(getMPIFunction(M, caller, "MPI_Isend"));
assert(isendfn);
// TODO: what if Isend not defined, but Irecv is?
FunctionType *FuT = isendfn->getFunctionType();

auto irecvfn = cast<Function>(
M.getOrInsertFunction(getRenamedPerCallingConv(caller, "MPI_Irecv"), FuT)
M.getOrInsertFunction(getMPIFunction(M, caller, "MPI_Irecv"), FuT)
.getCallee());
assert(irecvfn);

Expand Down
25 changes: 18 additions & 7 deletions enzyme/Enzyme/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2377,15 +2377,26 @@ static inline std::string getRenamedPerCallingConv(llvm::StringRef caller,
llvm::StringRef callee) {
if (startsWith(caller, "ejl")) {
auto &&[prefix, name, postfix] = tripleSplitDollar(caller);
return (prefix + "$" + getRenamedPerCallingConv(name, callee) + "$" +
postfix)
.str();
}
if (startsWith(caller, "PMPI_")) {
assert(startsWith(callee, "MPI"));
return ("P" + callee).str();
return (prefix + "$" + callee + "$" + postfix).str();
}
return callee.str();
}

static inline std::string getMPIFunction(llvm::Module &M,
llvm::StringRef caller,
llvm::StringRef callee) {
// The function could exist in two forms in the module - with PMPI_ or MPI_
// prefix. Check for both.
assert(startsWith(callee, "MPI"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no this is wrong, we should create the func decl if not exists

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only checks that the user side is passing in MPI_Gather. (Used to be in getRenamedPerCallingConv)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry comment applied to three lines later

auto mpi_name = getRenamedPerCallingConv(caller, callee);
if (M.getFunction(mpi_name))
return mpi_name;

// Now check for PMPI_ form.
auto pmpi_callee = ("P" + callee).str();
auto pmpi_name = getRenamedPerCallingConv(caller, pmpi_callee);
// TODO: Should we error if neither form exists?
return pmpi_name;
}

#endif // ENZYME_UTILS_H
Loading