From: Tim Shen Date: Wed, 26 Feb 2020 04:16:08 +0000 (-0800) Subject: [MLIR] Guard DMA-specific logic with DMA option X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ced0dd8e5104eff47cefdf3701d4980546d9afc5;p=platform%2Fupstream%2Fllvm.git [MLIR] Guard DMA-specific logic with DMA option Differential Revision: https://reviews.llvm.org/D75963 --- diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index c2cd233..1c9ac5e 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -1411,22 +1411,24 @@ static LogicalResult generateCopy( auto numElementsSSA = top.create(loc, numElements.getValue()); - SmallVector strideInfos; - getMultiLevelStrides(region, fastBufferShape, &strideInfos); - - // TODO(bondhugula): use all stride levels once DmaStartOp is extended for - // multi-level strides. - if (strideInfos.size() > 1) { - LLVM_DEBUG(llvm::dbgs() << "Only up to one level of stride supported\n"); - return failure(); - } + Value dmaStride = nullptr; + Value numEltPerDmaStride = nullptr; + if (copyOptions.generateDma) { + SmallVector dmaStrideInfos; + getMultiLevelStrides(region, fastBufferShape, &dmaStrideInfos); + + // TODO(bondhugula): use all stride levels once DmaStartOp is extended for + // multi-level strides. + if (dmaStrideInfos.size() > 1) { + LLVM_DEBUG(llvm::dbgs() << "Only up to one level of stride supported\n"); + return failure(); + } - Value stride = nullptr; - Value numEltPerStride = nullptr; - if (!strideInfos.empty()) { - stride = top.create(loc, strideInfos[0].stride); - numEltPerStride = - top.create(loc, strideInfos[0].numEltPerStride); + if (!dmaStrideInfos.empty()) { + dmaStride = top.create(loc, dmaStrideInfos[0].stride); + numEltPerDmaStride = + top.create(loc, dmaStrideInfos[0].numEltPerStride); + } } // Record the last operation where we want the memref replacement to end. We @@ -1469,13 +1471,13 @@ static LogicalResult generateCopy( b.create(loc, memref, memAffineMap, memIndices, fastMemRef, bufAffineMap, bufIndices, tagMemRef, tagAffineMap, tagIndices, - numElementsSSA, stride, numEltPerStride); + numElementsSSA, dmaStride, numEltPerDmaStride); } else { // DMA non-blocking write from fast buffer to the original memref. auto op = b.create( loc, fastMemRef, bufAffineMap, bufIndices, memref, memAffineMap, memIndices, tagMemRef, tagAffineMap, tagIndices, numElementsSSA, - stride, numEltPerStride); + dmaStride, numEltPerDmaStride); // Since new ops may be appended at 'end' (for outgoing DMAs), adjust the // end to mark end of block range being processed. if (isCopyOutAtEndOfBlock)