-
Notifications
You must be signed in to change notification settings - Fork 17
[GPU] Register initial GPU pipeline that uses IMEX #329
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
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
32a2986
[GPU] Register initial GPU pipeline that uses IMEX
dchigarev 289aae1
fix formatting
dchigarev 05631d5
make 'mlp' tests usu 'gpu-pipeline'
dchigarev a891ec3
Make the shapes bigger in tests
dchigarev 50a1349
Update IMEX to the new branch
dchigarev 004b484
Merge remote-tracking branch 'origin/main' into xegpu_pip
dchigarev 0ed3406
fix imex version
dchigarev ce177b5
Merge remote-tracking branch 'origin/main' into xegpu_pip
dchigarev 4a0018c
Fix pipeline for new tests
dchigarev 85c29df
Merge remote-tracking branch 'origin/main' into HEAD
dchigarev 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
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 |
---|---|---|
|
@@ -1405,6 +1405,17 @@ LogicalResult createMemoryFillKernel(linalg::LinalgOp linalgOp, | |
auto outputType = cast<ShapedType>(output.getType()); | ||
auto outputShape = outputType.getShape(); | ||
|
||
if (outputShape.size() != 2) { | ||
return rewriter.notifyMatchFailure( | ||
linalgOp, "Memory fill operation expects 2D output"); | ||
} | ||
|
||
// Otherwise 'xegpu-to-vc' pass will fail to convert it to VC | ||
if (outputShape[0] * outputShape[1] < 16) { | ||
Comment on lines
+1413
to
+1414
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.
|
||
return rewriter.notifyMatchFailure( | ||
linalgOp, "Memory fill operation is to small to be converted to xegpu"); | ||
} | ||
|
||
// Extract SIMD sized sub-tiles | ||
int maxSizeSIMD = 256; | ||
int64_t subTileCols = outputShape[1]; | ||
|
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,120 @@ | ||
//===- Pipeline.cpp - Graph Compiler GPU pipeline ---------------*- C++ -*-===// | ||
// | ||
// This file is licensed 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Conversion/Passes.h" | ||
#include "mlir/Dialect/Arith/Transforms/Passes.h" | ||
#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h" | ||
#include "mlir/Dialect/Bufferization/Transforms/Passes.h" | ||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h" | ||
#include "mlir/Dialect/LLVMIR/Transforms/Passes.h" | ||
#include "mlir/Dialect/Linalg/Passes.h" | ||
#include "mlir/Dialect/Math/Transforms/Passes.h" | ||
#include "mlir/Dialect/MemRef/IR/MemRef.h" | ||
#include "mlir/Dialect/MemRef/Transforms/Passes.h" | ||
#include "mlir/Dialect/SCF/IR/SCF.h" | ||
#include "mlir/Dialect/Tensor/IR/Tensor.h" | ||
#include "mlir/IR/DialectRegistry.h" | ||
#include "mlir/InitAllPasses.h" | ||
#include "mlir/Pass/PassManager.h" | ||
#include "mlir/Support/LogicalResult.h" | ||
#include "mlir/Transforms/Passes.h" | ||
#include <iostream> | ||
|
||
#include "mlir/Dialect/GPU/IR/GPUDialect.h" | ||
#include "mlir/Dialect/GPU/Transforms/Passes.h" | ||
#include "mlir/Dialect/SPIRV/Transforms/Passes.h" | ||
|
||
#include <imex/Conversion/Passes.h> | ||
#include <imex/Transforms/Passes.h> | ||
|
||
#include <string> | ||
|
||
#include "gc/Transforms/Passes.h" | ||
|
||
namespace mlir::gc { | ||
|
||
void populateGPUPipeline(mlir::OpPassManager &pm) { | ||
pm.addNestedPass<func::FuncOp>(createIterativeTilingAndFusion()); | ||
|
||
pm.addPass(bufferization::createEmptyTensorEliminationPass()); | ||
pm.addPass(bufferization::createEmptyTensorToAllocTensorPass()); | ||
|
||
bufferization::OneShotBufferizationOptions options; | ||
options.bufferizeFunctionBoundaries = true; | ||
options.setFunctionBoundaryTypeConversion( | ||
bufferization::LayoutMapOption::IdentityLayoutMap); | ||
pm.addPass(bufferization::createOneShotBufferizePass(options)); | ||
|
||
pm.addPass(bufferization::createDropEquivalentBufferResultsPass()); | ||
pm.addNestedPass<func::FuncOp>( | ||
bufferization::createFinalizingBufferizePass()); | ||
pm.addPass(createCanonicalizerPass()); | ||
pm.addPass(createCSEPass()); | ||
pm.addPass(bufferization::createDropEquivalentBufferResultsPass()); | ||
pm.addPass(memref::createExpandReallocPass()); | ||
pm.addPass(createCanonicalizerPass()); | ||
pm.addPass(bufferization::createOwnershipBasedBufferDeallocationPass()); | ||
pm.addPass(createCanonicalizerPass()); | ||
pm.addPass(bufferization::createBufferDeallocationSimplificationPass()); | ||
pm.addPass(bufferization::createLowerDeallocationsPass()); | ||
pm.addPass(createCSEPass()); | ||
pm.addPass(createCanonicalizerPass()); | ||
pm.addPass(createBufferizationToMemRefPass()); | ||
|
||
pm.addNestedPass<func::FuncOp>(createForallToParallelLoopPass()); | ||
pm.addNestedPass<func::FuncOp>(createLinalgToXeGPU( | ||
{/*kTile=*/16, /*stages=*/1, /*dpasTiles=*/{8, 16, 16}})); | ||
|
||
pm.addNestedPass<func::FuncOp>(createConvertLinalgToLoopsPass()); | ||
pm.addPass(xegpu::createXeGPUFoldAliasOps()); | ||
pm.addPass(memref::createFoldMemRefAliasOpsPass()); | ||
pm.addNestedPass<func::FuncOp>(createGpuMapParallelLoopsPass()); | ||
pm.addNestedPass<func::FuncOp>(createParallelLoopToGpuPass()); | ||
|
||
pm.addNestedPass<func::FuncOp>(imex::createInsertGPUAllocsPass("opencl")); | ||
pm.addPass(createGpuKernelOutliningPass()); | ||
pm.addPass(createCanonicalizerPass()); | ||
pm.addPass(imex::createSetSPIRVCapabilitiesPass()); | ||
pm.addNestedPass<gpu::GPUModuleOp>( | ||
imex::createSetSPIRVAbiAttributePass("opencl")); | ||
pm.addPass(createLowerAffinePass()); | ||
pm.addPass(imex::createVectorLinearizePass()); | ||
pm.addNestedPass<gpu::GPUModuleOp>(imex::createConvertXeGPUToVCPass()); | ||
pm.addPass(createReconcileUnrealizedCastsPass()); | ||
pm.addPass(imex::createBF16ToGPUPass()); | ||
pm.addNestedPass<gpu::GPUModuleOp>(createConvertFuncToSPIRVPass()); | ||
pm.addNestedPass<gpu::GPUModuleOp>(createConvertVectorToSPIRVPass()); | ||
pm.addPass(imex::createConvertGPUXToSPIRVPass()); | ||
pm.addNestedPass<spirv::ModuleOp>(spirv::createSPIRVLowerABIAttributesPass()); | ||
pm.addNestedPass<spirv::ModuleOp>(spirv::createSPIRVUpdateVCEPass()); | ||
pm.addNestedPass<func::FuncOp>(LLVM::createRequestCWrappersPass()); | ||
pm.addPass(imex::createSerializeSPIRVPass()); | ||
pm.addPass(createConvertVectorToSCFPass()); | ||
pm.addPass(imex::createConvertGPUToGPUXPass()); | ||
pm.addPass(createConvertSCFToCFPass()); | ||
pm.addPass(createConvertControlFlowToLLVMPass()); | ||
pm.addPass(createConvertVectorToLLVMPass()); | ||
pm.addPass(createConvertIndexToLLVMPass()); | ||
pm.addPass(createArithToLLVMConversionPass()); | ||
pm.addPass(createConvertFuncToLLVMPass()); | ||
pm.addPass(createConvertMathToLLVMPass()); | ||
pm.addPass(imex::createConvertGPUXToLLVMPass()); | ||
pm.addPass(createConvertIndexToLLVMPass()); | ||
pm.addPass(memref::createExpandStridedMetadataPass()); | ||
pm.addPass(createLowerAffinePass()); | ||
pm.addPass(createFinalizeMemRefToLLVMConversionPass()); | ||
pm.addPass(createReconcileUnrealizedCastsPass()); | ||
} | ||
|
||
void registerGPUPipeline() { | ||
PassPipelineRegistration<>("gc-gpu-pipeline", | ||
"The GPU pipeline for Graph Compiler with IMEX", | ||
populateGPUPipeline); | ||
} | ||
|
||
} // namespace mlir::gc |
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
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.