From 0f13269040594c5a3b14aa75df5740e568cdc77f Mon Sep 17 00:00:00 2001 From: NiccoloN Date: Tue, 21 Apr 2026 18:36:16 +0200 Subject: [PATCH] faster DCPAnalysis on partial graph --- src/PIM/Compiler/PimCompilerOptions.cpp | 6 + src/PIM/Compiler/PimCompilerOptions.hpp | 1 + .../DCPGraph/DCPAnalysis.cpp | 402 +++++++++++++++++- .../MergeComputeNodes/DCPGraph/Graph.cpp | 7 +- 4 files changed, 406 insertions(+), 10 deletions(-) diff --git a/src/PIM/Compiler/PimCompilerOptions.cpp b/src/PIM/Compiler/PimCompilerOptions.cpp index e13af09..7f4b18c 100644 --- a/src/PIM/Compiler/PimCompilerOptions.cpp +++ b/src/PIM/Compiler/PimCompilerOptions.cpp @@ -47,6 +47,12 @@ llvm::cl::opt coresCount("core-count", llvm::cl::desc("Number of cores in the chip. `-1` to use the minimum amount of cores."), llvm::cl::init(-1)); +llvm::cl::opt dcpCriticalWindowSize( + "dcp-critical-window-size", + llvm::cl::desc("Number of lowest-slack virtual nodes considered by each DCP coarsening iteration. " + "Use 0 to run the legacy full-graph DCP analysis."), + llvm::cl::init(1024)); + llvm::cl::opt ignoreConcatError("ignore-concat-error", llvm::cl::desc("Ignore ConcatOp corner case: do not assert and do a simplification"), diff --git a/src/PIM/Compiler/PimCompilerOptions.hpp b/src/PIM/Compiler/PimCompilerOptions.hpp index ab79c1f..e1f6c6a 100644 --- a/src/PIM/Compiler/PimCompilerOptions.hpp +++ b/src/PIM/Compiler/PimCompilerOptions.hpp @@ -29,6 +29,7 @@ extern llvm::cl::opt useExperimentalConvImpl; extern llvm::cl::opt crossbarSize; extern llvm::cl::opt crossbarCountInCore; extern llvm::cl::opt coresCount; +extern llvm::cl::opt dcpCriticalWindowSize; // This option, by default set to false, will ignore an error when resolving a // specific tiles of the operands of a concat. This specific case is when the diff --git a/src/PIM/Dialect/Spatial/Transforms/MergeComputeNodes/DCPGraph/DCPAnalysis.cpp b/src/PIM/Dialect/Spatial/Transforms/MergeComputeNodes/DCPGraph/DCPAnalysis.cpp index 0c0c5a7..bf03e56 100644 --- a/src/PIM/Dialect/Spatial/Transforms/MergeComputeNodes/DCPGraph/DCPAnalysis.cpp +++ b/src/PIM/Dialect/Spatial/Transforms/MergeComputeNodes/DCPGraph/DCPAnalysis.cpp @@ -6,10 +6,18 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Casting.h" +#include #include +#include +#include +#include +#include +#include +#include #include "DCPAnalysis.hpp" #include "Graph.hpp" +#include "src/Accelerators/PIM/Compiler/PimCompilerOptions.hpp" #include "src/Support/TypeUtilities.hpp" namespace onnx_mlir { @@ -17,6 +25,361 @@ namespace spatial { using namespace mlir; +namespace { + +struct VirtualNode { + llvm::SmallVector originalComputeIndices; + Weight weight = 0; + CrossbarUsage crossbarUsage = 0; +}; + +struct VirtualGraph { + std::vector nodes; + std::vector edges; +}; + +struct TimingInfo { + std::vector