-
Notifications
You must be signed in to change notification settings - Fork 76
Support running different allocation analyses #2605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
victor-eds
merged 6 commits into
intel:main
from
victor-eds:specialize-allocation-analysis
Nov 6, 2024
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
08786ac
[Triton][Analysis] Support running different allocation analyses
victor-eds 68bf33c
[TritonIntelGPUToLLVM] Implement `mlir::triton::intel::AllocationAnal…
victor-eds 96a2e78
Fix build error
victor-eds cbfdaf9
Drop intel from headers
victor-eds 16cd6c1
Merge branch 'main' into specialize-allocation-analysis
victor-eds e7c7a8d
Fix build errors
victor-eds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,9 @@ namespace mlir { | |
|
|
||
| namespace triton { | ||
| class AllocationAnalysis; | ||
| namespace intel { | ||
| class AllocationAnalysis; | ||
| } | ||
|
|
||
| // To convert a tensor from one layout to another, we need to allocate a | ||
| // temporary buffer (i.e., scratch buffer) in shared memory. The conversion may | ||
|
|
@@ -102,7 +105,7 @@ class Allocation { | |
| explicit Allocation(Operation *operation) : operation(operation) {} | ||
|
|
||
| /// Runs allocation analysis on the given top-level operation. | ||
| void run(FuncAllocMapT &funcAllocMap); | ||
| template <typename AllocationAnalysis> void run(FuncAllocMapT &funcAllocMap); | ||
|
|
||
| /// Returns the operation this analysis was constructed from. | ||
| Operation *getOperation() const { return operation; } | ||
|
|
@@ -238,8 +241,12 @@ class Allocation { | |
| size_t sharedMemorySize = 0; | ||
|
|
||
| friend class triton::AllocationAnalysis; | ||
| friend class triton::intel::AllocationAnalysis; | ||
| }; | ||
|
|
||
| template <> | ||
| void Allocation::run<triton::AllocationAnalysis>(FuncAllocMapT &funcAllocMap); | ||
|
|
||
| /// Static analysis that computes the allocation of shared memory buffers | ||
| /// of the entire call graph. | ||
| /// The allocation is performed in a post-order walk of the call graph. | ||
|
|
@@ -250,17 +257,19 @@ class ModuleAllocation : public CallGraph<Allocation> { | |
| public: | ||
| using FuncOffsetMapT = DenseMap<FunctionOpInterface, Value>; | ||
|
|
||
| explicit ModuleAllocation(ModuleOp moduleOp) | ||
| : CallGraph<Allocation>(moduleOp) { | ||
| walk<WalkOrder::PreOrder, WalkOrder::PostOrder>( | ||
| template <typename AllocationAnalysis = triton::AllocationAnalysis> | ||
| static ModuleAllocation get(ModuleOp moduleOp) { | ||
| ModuleAllocation res(moduleOp); | ||
| res.walk<WalkOrder::PreOrder, WalkOrder::PostOrder>( | ||
|
Comment on lines
-253
to
+261
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot have templated constructors like this, so this is a static member function now. |
||
| // Pre-order edge walk callback | ||
| [](CallOpInterface callOp, FunctionOpInterface funcOp) {}, | ||
| // Post-order node walk callback | ||
| [&](FunctionOpInterface funcOp) { | ||
| auto [iter, inserted] = funcMap.try_emplace(funcOp, funcOp); | ||
| auto [iter, inserted] = res.funcMap.try_emplace(funcOp, funcOp); | ||
| if (inserted) | ||
| iter->second.run(funcMap); | ||
| iter->second.template run<AllocationAnalysis>(res.funcMap); | ||
| }); | ||
| return res; | ||
| } | ||
|
|
||
| size_t getSharedMemorySize() { | ||
|
|
@@ -285,6 +294,9 @@ class ModuleAllocation : public CallGraph<Allocation> { | |
| } | ||
|
|
||
| private: | ||
| explicit ModuleAllocation(ModuleOp moduleOp) | ||
| : CallGraph<Allocation>(moduleOp) {} | ||
|
|
||
| FuncOffsetMapT sharedMemoryValue; | ||
| }; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #ifndef TRITON_INTEL_ANALYSIS_ALLOCATION_H | ||
| #define TRITON_INTEL_ANALYSIS_ALLOCATION_H | ||
|
|
||
| #include "triton/Analysis/Allocation.h" | ||
|
|
||
| namespace mlir { | ||
| template <> | ||
| void Allocation::run<triton::intel::AllocationAnalysis>( | ||
| FuncAllocMapT &funcAllocMap); | ||
| } // namespace mlir | ||
|
|
||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.