Code Monkey home page Code Monkey logo

Comments (8)

giuseros avatar giuseros commented on September 24, 2024

Hi @hanhanW ,
Yes, after rebasing I am having the same issues. I am trying to investigate a bit more, but if you have any hint, please let me know.

Thanks,
Giuseppe

from iree-llvm-sandbox.

giuseros avatar giuseros commented on September 24, 2024

Actually, what I found is that some memref.alloca() instructions creep in during LowerVector transformation. If you set ulimit -s unlimited it should be fine, but I am wondering if this was intentional.

from iree-llvm-sandbox.

giuseros avatar giuseros commented on September 24, 2024

And the winner is: https://reviews.llvm.org/D119743 :)

By adding AutomaticAllocationScope to scf::ForOp makes this always returning the scf:::ForOp instead of the FuncOp.

This means that there are a lot of alloca that now happens inside the loops, that cannot be hosted out (side effects and all), and that make the stack explode.

from iree-llvm-sandbox.

ftynse avatar ftynse commented on September 24, 2024

I suppose we can extend the function that finds the appropriate alloca insertion point to something like "find the farthest allocation scope that is not isolated from above".

We also discussed with the author of D119743 the idea of having an "alloca hoisting" pass that would hoist allocas from nested scopes. They originally wanted it to be a canonicalization pattern, but this may have unintended consequences as the allocation lifetime is being extended and fake dependencies being introduced across different loop iterations. If you are willing to contribute such a transformation upstream, it would be very helpful.

from iree-llvm-sandbox.

ftynse avatar ftynse commented on September 24, 2024

This trivial fix lets the search step over loops. @hanhanW, please check if this helps with your issue.

--- a/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp
@@ -439,8 +439,14 @@ static void createFullPartialVectorTrans
 
 // TODO: Parallelism and threadlocal considerations with a ParallelScope trait.
 static Operation *getAutomaticAllocationScope(Operation *op) {
-  Operation *scope =
-      op->getParentWithTrait<OpTrait::AutomaticAllocationScope>();
+  Operation *scope = nullptr;
+  for (Operation *parent = op->getParentOp(); parent != nullptr;
+       parent = parent->getParentOp()) {
+    if (parent->hasTrait<OpTrait::AutomaticAllocationScope>())
+      scope = parent;
+    if (!isa<scf::ForOp>(parent))
+      break;
+  }
   assert(scope && "Expected op to be inside automatic allocation scope");
   return scope;
 }

from iree-llvm-sandbox.

hanhanW avatar hanhanW commented on September 24, 2024

Yes, it helps the issue. I'm able to run these benchmarks with the change.

from iree-llvm-sandbox.

ftynse avatar ftynse commented on September 24, 2024

Fix applied in llvm/llvm-project@4c807f2

from iree-llvm-sandbox.

hanhanW avatar hanhanW commented on September 24, 2024

Thanks for the fix!

from iree-llvm-sandbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.