[Mlir-commits] [mlir] [mlir] [memref] Compile-time memref.alloc Scheduling/Merging optimization (PR #95882)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Jun 20 23:09:19 PDT 2024


================
@@ -0,0 +1,179 @@
+//===- MergeAllocTickBased.h - Tick-based merge alloc interfaces *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_DIALECT_MEMREF_MERGEALLOCTICKBASED_H
+#define MLIR_DIALECT_MEMREF_MERGEALLOCTICKBASED_H
+
+#include "mlir/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.h"
+#include "mlir/Dialect/MemRef/Transforms/Passes.h"
+#include "mlir/Dialect/MemRef/Transforms/StaticMemoryPlanning.h"
+#include "mlir/IR/Builders.h"
+#include "mlir/IR/Operation.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include <memory>
+
+namespace mlir {
+class BufferViewFlowAnalysis;
+class ViewLikeOpInterface;
+namespace memref {
+
+/// Usually ticks should be non-negative numbers. There are two special ticks
+/// defined here.
+namespace special_ticks {
----------------
Menooker wrote:

We are recording a `[begin, end]` tick range for each allocations. The ticks are integers, indicating the "time" when a buffer is first used and last used. It is not side-effects (though side-effects are considered when recording the ticks).

A normal tick range of an allocation is usually non-negative. The "special-ticks" marks some special cases of a buffer: 1) the buffer is never used 2) the buffer has complex lifetime which cannot be inferred at compile-time.

And since ticks are integers, the "special-ticks" should be integers too. That's why I am using `namespace` instead of `enum class`. I also prefer `namespace` over C-style `enum` because it does not have naming-pollution.

https://github.com/llvm/llvm-project/pull/95882


More information about the Mlir-commits mailing list