Skip to content
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

BLAS: fix blas fptype for complex #2167

Merged
merged 1 commit into from
Nov 16, 2024
Merged
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
6 changes: 5 additions & 1 deletion enzyme/Enzyme/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,18 @@ void ErrorIfRuntimeInactive(llvm::IRBuilder<> &B, llvm::Value *primal,
call->setDebugLoc(loc);
}

Type *BlasInfo::fpType(LLVMContext &ctx) const {
Type *BlasInfo::fpType(LLVMContext &ctx, bool to_scalar) const {
if (floatType == "d" || floatType == "D") {
return Type::getDoubleTy(ctx);
} else if (floatType == "s" || floatType == "S") {
return Type::getFloatTy(ctx);
} else if (floatType == "c" || floatType == "C") {
if (to_scalar)
return Type::getFloatTy(ctx);
return VectorType::get(Type::getFloatTy(ctx), 2, false);
} else if (floatType == "z" || floatType == "Z") {
if (to_scalar)
return Type::getDoubleTy(ctx);
return VectorType::get(Type::getDoubleTy(ctx), 2, false);
} else {
assert(false && "Unreachable");
Expand Down
2 changes: 1 addition & 1 deletion enzyme/Enzyme/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ struct BlasInfo {
std::string function;
bool is64;

llvm::Type *fpType(llvm::LLVMContext &ctx) const;
llvm::Type *fpType(llvm::LLVMContext &ctx, bool to_scalar = false) const;
llvm::IntegerType *intType(llvm::LLVMContext &ctx) const;
};

Expand Down
2 changes: 1 addition & 1 deletion enzyme/tools/enzyme-tblgen/blasTAUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ inline void emit_BLASTypes(raw_ostream &os) {
"\"cublas\" && StringRef(blas.suffix).contains(\"v2\");\n";

os << "TypeTree ttFloat;\n"
<< "llvm::Type *floatType = blas.fpType(call.getContext()); \n"
<< "llvm::Type *floatType = blas.fpType(call.getContext(), true); \n"
<< "if (byRefFloat) {\n"
<< " ttFloat.insert({-1},BaseType::Pointer);\n"
<< " ttFloat.insert({-1,0},floatType);\n"
Expand Down
Loading