Skip to content
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
9 changes: 3 additions & 6 deletions mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugLog.h"

namespace mlir {
#define GEN_PASS_DEF_CONVERTMATHTOFUNCS
Expand All @@ -32,7 +32,6 @@ namespace mlir {
using namespace mlir;

#define DEBUG_TYPE "math-to-funcs"
#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "]: ")

namespace {
// Pattern to convert vector operations to scalar operations.
Expand Down Expand Up @@ -653,10 +652,8 @@ FPowIOpLowering::matchAndRewrite(math::FPowIOp op,
/// }
static func::FuncOp createCtlzFunc(ModuleOp *module, Type elementType) {
if (!isa<IntegerType>(elementType)) {
LLVM_DEBUG({
DBGS() << "non-integer element type for CtlzFunc; type was: ";
elementType.print(llvm::dbgs());
});
LDBG() << "non-integer element type for CtlzFunc; type was: "
<< elementType;
llvm_unreachable("non-integer element type");
}
int64_t bitWidth = elementType.getIntOrFloatBitWidth();
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Conversion/MathToROCDL/MathToROCDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "mlir/Conversion/MathToROCDL/MathToROCDL.h"
#include "mlir/Conversion/GPUCommon/GPUCommonPass.h"
#include "mlir/Conversion/LLVMCommon/LoweringOptions.h"
#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
Expand All @@ -21,7 +22,6 @@

#include "../GPUCommon/GPUOpsLowering.h"
#include "../GPUCommon/OpToFuncCallLowering.h"
#include "mlir/Conversion/GPUCommon/GPUCommonPass.h"

namespace mlir {
#define GEN_PASS_DEF_CONVERTMATHTOROCDL
Expand All @@ -31,7 +31,6 @@ namespace mlir {
using namespace mlir;

#define DEBUG_TYPE "math-to-rocdl"
#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "]: ")

template <typename OpTy>
static void populateOpPatterns(const LLVMTypeConverter &converter,
Expand Down
11 changes: 6 additions & 5 deletions mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/Pass/Pass.h"
#include "llvm/Support/DebugLog.h"
#include "llvm/Support/MathExtras.h"

#include <optional>

#define DEBUG_TYPE "memref-to-llvm"
#define DBGS() llvm::dbgs() << "[" DEBUG_TYPE "] "

namespace mlir {
#define GEN_PASS_DEF_FINALIZEMEMREFTOLLVMCONVERSIONPASS
Expand Down Expand Up @@ -1848,8 +1849,8 @@ matchSimpleAtomicOp(memref::AtomicRMWOp atomicOp) {
return LLVM::AtomicBinOp::xchg;
case arith::AtomicRMWKind::maximumf:
// TODO: remove this by end of 2025.
LLVM_DEBUG(DBGS() << "the lowering of memref.atomicrmw maximumf changed "
"from fmax to fmaximum, expect more NaNs");
LDBG() << "the lowering of memref.atomicrmw maximumf changed "
"from fmax to fmaximum, expect more NaNs";
return LLVM::AtomicBinOp::fmaximum;
case arith::AtomicRMWKind::maxnumf:
return LLVM::AtomicBinOp::fmax;
Expand All @@ -1859,8 +1860,8 @@ matchSimpleAtomicOp(memref::AtomicRMWOp atomicOp) {
return LLVM::AtomicBinOp::umax;
case arith::AtomicRMWKind::minimumf:
// TODO: remove this by end of 2025.
LLVM_DEBUG(DBGS() << "the lowering of memref.atomicrmw minimum changed "
"from fmin to fminimum, expect more NaNs");
LDBG() << "the lowering of memref.atomicrmw minimum changed "
"from fmin to fminimum, expect more NaNs";
return LLVM::AtomicBinOp::fminimum;
case arith::AtomicRMWKind::minnumf:
return LLVM::AtomicBinOp::fmin;
Expand Down
1 change: 0 additions & 1 deletion mlir/lib/Conversion/ShardToMPI/ShardToMPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"

#define DEBUG_TYPE "shard-to-mpi"
#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "]: ")

namespace mlir {
#define GEN_PASS_DEF_CONVERTSHARDTOMPIPASS
Expand Down
61 changes: 29 additions & 32 deletions mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/DebugLog.h"

#define DEBUG_TYPE "vector-to-gpu"
#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "]: ")
#define DBGSNL() (llvm::dbgs() << "\n")

namespace mlir {
#define GEN_PASS_DEF_CONVERTVECTORTOGPU
Expand Down Expand Up @@ -366,7 +365,7 @@ static SetVector<Operation *> getOpToConvert(mlir::Operation *op,
// by all operations.
if (llvm::any_of(dependentOps, [useNvGpu](Operation *op) {
if (!supportsMMaMatrixType(op, useNvGpu)) {
LLVM_DEBUG(DBGS() << "cannot convert op: " << *op << "\n");
LDBG() << "cannot convert op: " << *op;
return true;
}
return false;
Expand Down Expand Up @@ -548,7 +547,7 @@ convertTransferReadOp(RewriterBase &rewriter, vector::TransferReadOp op,
std::optional<int64_t> stride =
getStaticallyKnownRowStride(op.getShapedType());
if (!stride.has_value()) {
LLVM_DEBUG(DBGS() << "no stride\n");
LDBG() << "no stride";
return rewriter.notifyMatchFailure(op, "no stride");
}

Expand Down Expand Up @@ -583,7 +582,7 @@ convertTransferReadOp(RewriterBase &rewriter, vector::TransferReadOp op,
isTranspose ? rewriter.getUnitAttr() : UnitAttr());
valueMapping[mappingResult] = load;

LLVM_DEBUG(DBGS() << "transfer read to: " << load << "\n");
LDBG() << "transfer read to: " << load;
return success();
}

Expand All @@ -597,13 +596,13 @@ convertTransferWriteOp(RewriterBase &rewriter, vector::TransferWriteOp op,
std::optional<int64_t> stride =
getStaticallyKnownRowStride(op.getShapedType());
if (!stride.has_value()) {
LLVM_DEBUG(DBGS() << "no stride\n");
LDBG() << "no stride";
return rewriter.notifyMatchFailure(op, "no stride");
}

auto it = valueMapping.find(op.getVector());
if (it == valueMapping.end()) {
LLVM_DEBUG(DBGS() << "no mapping\n");
LDBG() << "no mapping";
return rewriter.notifyMatchFailure(op, "no mapping");
}

Expand All @@ -613,9 +612,9 @@ convertTransferWriteOp(RewriterBase &rewriter, vector::TransferWriteOp op,
rewriter.getIndexAttr(*stride), /*transpose=*/UnitAttr());
(void)store;

LLVM_DEBUG(DBGS() << "transfer write to: " << store << "\n");
LDBG() << "transfer write to: " << store;

LLVM_DEBUG(DBGS() << "erase: " << op << "\n");
LDBG() << "erase: " << op;
rewriter.eraseOp(op);
return success();
}
Expand All @@ -641,21 +640,21 @@ convertConstantOpMmaSync(RewriterBase &rewriter, arith::ConstantOp op,
FailureOr<nvgpu::WarpMatrixInfo> warpMatrixInfo =
nvgpu::getWarpMatrixInfo(op);
if (failed(warpMatrixInfo)) {
LLVM_DEBUG(DBGS() << "no warpMatrixInfo\n");
LDBG() << "no warpMatrixInfo";
return rewriter.notifyMatchFailure(op, "no warpMatrixInfo");
}

FailureOr<nvgpu::FragmentElementInfo> regInfo =
nvgpu::getMmaSyncRegisterType(*warpMatrixInfo);
if (failed(regInfo)) {
LLVM_DEBUG(DBGS() << "not mma sync reg info\n");
LDBG() << "not mma sync reg info";
return rewriter.notifyMatchFailure(op, "not mma sync reg info");
}

VectorType vectorType = getMmaSyncVectorOperandType(*regInfo);
auto dense = dyn_cast<SplatElementsAttr>(op.getValue());
if (!dense) {
LLVM_DEBUG(DBGS() << "not a splat\n");
LDBG() << "not a splat";
return rewriter.notifyMatchFailure(op, "not a splat");
}

Expand All @@ -677,8 +676,8 @@ static FailureOr<bool> isTransposed(vector::TransferReadOp op) {
mlir::AffineMap map = op.getPermutationMap();

if (map.getNumResults() != 2) {
LLVM_DEBUG(DBGS() << "Failed because the result of `vector.transfer_read` "
"is not a 2d operand\n");
LDBG() << "Failed because the result of `vector.transfer_read` "
"is not a 2d operand";
return failure();
}

Expand All @@ -691,8 +690,8 @@ static FailureOr<bool> isTransposed(vector::TransferReadOp op) {
auto exprN = dyn_cast<AffineDimExpr>(dN);

if (!exprM || !exprN) {
LLVM_DEBUG(DBGS() << "Failed because expressions are not affine dim "
"expressions, then transpose cannot be determined.\n");
LDBG() << "Failed because expressions are not affine dim "
"expressions, then transpose cannot be determined.";
return failure();
}

Expand All @@ -709,20 +708,20 @@ creatLdMatrixCompatibleLoads(RewriterBase &rewriter, vector::TransferReadOp op,
FailureOr<nvgpu::WarpMatrixInfo> warpMatrixInfo =
nvgpu::getWarpMatrixInfo(op);
if (failed(warpMatrixInfo)) {
LLVM_DEBUG(DBGS() << "no warpMatrixInfo\n");
LDBG() << "no warpMatrixInfo";
return rewriter.notifyMatchFailure(op, "no warpMatrixInfo");
}

FailureOr<nvgpu::FragmentElementInfo> regInfo =
nvgpu::getMmaSyncRegisterType(*warpMatrixInfo);
if (failed(regInfo)) {
LLVM_DEBUG(DBGS() << "not mma sync reg info\n");
LDBG() << "not mma sync reg info";
return rewriter.notifyMatchFailure(op, "not mma sync reg info");
}

FailureOr<bool> transpose = isTransposed(op);
if (failed(transpose)) {
LLVM_DEBUG(DBGS() << "failed to determine the transpose\n");
LDBG() << "failed to determine the transpose";
return rewriter.notifyMatchFailure(
op, "Op should likely not be converted to a nvgpu.ldmatrix call.");
}
Expand All @@ -731,10 +730,8 @@ creatLdMatrixCompatibleLoads(RewriterBase &rewriter, vector::TransferReadOp op,
nvgpu::getLdMatrixParams(*warpMatrixInfo, *transpose);

if (failed(params)) {
LLVM_DEBUG(
DBGS()
<< "failed to convert vector.transfer_read to ldmatrix. "
<< "Op should likely not be converted to a nvgpu.ldmatrix call.\n");
LDBG() << "failed to convert vector.transfer_read to ldmatrix. "
<< "Op should likely not be converted to a nvgpu.ldmatrix call.";
return rewriter.notifyMatchFailure(
op, "failed to convert vector.transfer_read to ldmatrix; this op "
"likely should not be converted to a nvgpu.ldmatrix call.");
Expand All @@ -745,7 +742,7 @@ creatLdMatrixCompatibleLoads(RewriterBase &rewriter, vector::TransferReadOp op,
FailureOr<AffineMap> offsets =
nvgpu::getLaneIdToLdMatrixMatrixCoord(rewriter, loc, *params);
if (failed(offsets)) {
LLVM_DEBUG(DBGS() << "no offsets\n");
LDBG() << "no offsets";
return rewriter.notifyMatchFailure(op, "no offsets");
}

Expand Down Expand Up @@ -934,7 +931,7 @@ convertTransferWriteToStores(RewriterBase &rewriter, vector::TransferWriteOp op,
vector::StoreOp::create(rewriter, loc, el, op.getBase(), newIndices);
}

LLVM_DEBUG(DBGS() << "erase: " << op << "\n");
LDBG() << "erase: " << op;
rewriter.eraseOp(op);
return success();
}
Expand Down Expand Up @@ -1132,9 +1129,9 @@ static scf::ForOp replaceForOpWithNewSignature(RewriterBase &rewriter,
loop.getNumResults())))
rewriter.replaceAllUsesWith(std::get<0>(it), std::get<1>(it));

LLVM_DEBUG(DBGS() << "newLoop now: " << newLoop << "\n");
LLVM_DEBUG(DBGS() << "stripped scf.for: " << loop << "\n");
LLVM_DEBUG(DBGS() << "erase: " << loop);
LDBG() << "newLoop now: " << newLoop;
LDBG() << "stripped scf.for: " << loop;
LDBG() << "erase: " << loop;

rewriter.eraseOp(loop);
return newLoop;
Expand All @@ -1150,7 +1147,7 @@ static LogicalResult convertForOp(RewriterBase &rewriter, scf::ForOp op,
for (const auto &operand : llvm::enumerate(op.getInitArgs())) {
auto it = valueMapping.find(operand.value());
if (it == valueMapping.end()) {
LLVM_DEBUG(DBGS() << "no value mapping for: " << operand.value() << "\n");
LDBG() << "no value mapping for: " << operand.value();
continue;
}
argMapping.push_back(std::make_pair(
Expand All @@ -1168,7 +1165,7 @@ static LogicalResult convertForOp(RewriterBase &rewriter, scf::ForOp op,
loopBody.getArgument(mapping.second + newForOp.getNumInductionVars());
}

LLVM_DEBUG(DBGS() << "scf.for to: " << newForOp << "\n");
LDBG() << "scf.for to: " << newForOp;
return success();
}

Expand All @@ -1191,7 +1188,7 @@ convertYieldOp(RewriterBase &rewriter, scf::YieldOp op,
}
scf::YieldOp::create(rewriter, op.getLoc(), yieldOperands);

LLVM_DEBUG(DBGS() << "erase: " << op << "\n");
LDBG() << "erase: " << op;
rewriter.eraseOp(op);
return success();
}
Expand Down Expand Up @@ -1244,7 +1241,7 @@ LogicalResult mlir::convertVectorToMMAOps(RewriterBase &rewriter,

auto globalRes = LogicalResult::success();
for (Operation *op : ops) {
LLVM_DEBUG(DBGS() << "Process op: " << *op << "\n");
LDBG() << "Process op: " << *op;
// Apparently callers do not want to early exit on failure here.
auto res = LogicalResult::success();
if (auto transferRead = dyn_cast<vector::TransferReadOp>(op)) {
Expand Down
8 changes: 2 additions & 6 deletions mlir/lib/Dialect/Affine/IR/AffineOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallVectorExtras.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugLog.h"
#include "llvm/Support/LogicalResult.h"
#include "llvm/Support/MathExtras.h"
#include <numeric>
Expand All @@ -40,7 +40,6 @@ using llvm::divideFloorSigned;
using llvm::mod;

#define DEBUG_TYPE "affine-ops"
#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE << "]: ")

#include "mlir/Dialect/Affine/IR/AffineOpsDialect.cpp.inc"

Expand Down Expand Up @@ -1062,12 +1061,9 @@ static LogicalResult replaceAffineMinBoundingBoxExpression(AffineMinOp minOp,
AffineMap *map,
ValueRange dims,
ValueRange syms) {
LDBG() << "replaceAffineMinBoundingBoxExpression: `" << minOp << "`";
AffineMap affineMinMap = minOp.getAffineMap();

LLVM_DEBUG({
DBGS() << "replaceAffineMinBoundingBoxExpression: `" << minOp << "`\n";
});

// Check the value is positive.
for (unsigned i = 0, e = affineMinMap.getNumResults(); i < e; ++i) {
// Compare each expression in the minimum against 0.
Expand Down
1 change: 0 additions & 1 deletion mlir/lib/Dialect/Shard/IR/ShardOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <utility>

#define DEBUG_TYPE "shard-ops"
#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE << "]: ")

using namespace mlir;
using namespace mlir::shard;
Expand Down
Loading