summaryrefslogtreecommitdiff
path: root/mlir/include
diff options
context:
space:
mode:
authorAart Bik <ajcbik@google.com>2023-05-12 12:43:35 -0700
committerAart Bik <ajcbik@google.com>2023-05-15 08:49:38 -0700
commitee42e23614c789088a1528d41926d47c94e8ccdf (patch)
treeb69c5a1b39976063fa528714f3400f9e41f0b9f1 /mlir/include
parent9715af434579022b5ef31781be40b722d7e63bee (diff)
downloadllvm-ee42e23614c789088a1528d41926d47c94e8ccdf.tar.gz
[mlir][sparse][gpu] first implementation of the GPU libgen approach
The sparse compiler now has two prototype strategies for GPU acceleration: * CUDA codegen: this converts sparsified code to CUDA threads * CUDA libgen: this converts pre-sparsified code to cuSPARSE library calls This revision introduces the first steps required for the second approach. Reviewed By: ThomasRaoux Differential Revision: https://reviews.llvm.org/D150170
Diffstat (limited to 'mlir/include')
-rw-r--r--mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h9
-rw-r--r--mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h14
-rw-r--r--mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td8
3 files changed, 26 insertions, 5 deletions
diff --git a/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h b/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h
index 8da020c09c1e..febb0113cf99 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h
+++ b/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h
@@ -130,9 +130,16 @@ struct SparseCompilerOptions
PassOptions::Option<std::string> gpuFeatures{*this, "gpu-features",
desc("GPU target features")};
+ /// This option is used to enable GPU library generation.
+ PassOptions::Option<bool> enableGPULibgen{
+ *this, "enable-gpu-libgen",
+ desc("Enables GPU acceleration by means of direct library calls (like "
+ "cuSPARSE)")};
+
/// Projects out the options for `createSparsificationPass`.
SparsificationOptions sparsificationOptions() const {
- return SparsificationOptions(parallelization, enableIndexReduction);
+ return SparsificationOptions(parallelization, enableIndexReduction,
+ enableGPULibgen, enableRuntimeLibrary);
}
/// Projects out the options for `createSparseTensorConversionPass`.
diff --git a/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h b/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h
index c69dfb77f6cb..c2942cf7be0b 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h
@@ -49,12 +49,17 @@ enum class SparseParallelizationStrategy {
/// Options for the Sparsification pass.
struct SparsificationOptions {
- SparsificationOptions(SparseParallelizationStrategy p, bool idxReduc)
- : parallelizationStrategy(p), enableIndexReduction(idxReduc) {}
+ SparsificationOptions(SparseParallelizationStrategy p, bool idxReduc,
+ bool gpuLibgen, bool enableRT)
+ : parallelizationStrategy(p), enableIndexReduction(idxReduc),
+ enableGPULibgen(gpuLibgen), enableRuntimeLibrary(enableRT) {}
SparsificationOptions()
- : SparsificationOptions(SparseParallelizationStrategy::kNone, false) {}
+ : SparsificationOptions(SparseParallelizationStrategy::kNone, false,
+ false, true) {}
SparseParallelizationStrategy parallelizationStrategy;
bool enableIndexReduction;
+ bool enableGPULibgen;
+ bool enableRuntimeLibrary;
};
/// Sets up sparsification rewriting rules with the given options.
@@ -206,6 +211,9 @@ std::unique_ptr<Pass> createSparseVectorizationPass(unsigned vectorLength,
void populateSparseGPUCodegenPatterns(RewritePatternSet &patterns,
unsigned numThreads);
+void populateSparseGPULibgenPatterns(RewritePatternSet &patterns,
+ bool enableRT);
+
std::unique_ptr<Pass> createSparseGPUCodegenPass();
std::unique_ptr<Pass> createSparseGPUCodegenPass(unsigned numThreads);
diff --git a/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td b/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td
index 3ea68f9da670..962399931d93 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td
@@ -73,6 +73,7 @@ def SparsificationPass : Pass<"sparsification", "ModuleOp"> {
"affine::AffineDialect",
"arith::ArithDialect",
"bufferization::BufferizationDialect",
+ "gpu::GPUDialect",
"LLVM::LLVMDialect",
"linalg::LinalgDialect",
"memref::MemRefDialect",
@@ -100,7 +101,12 @@ def SparsificationPass : Pass<"sparsification", "ModuleOp"> {
"Enable dense parallelization for any loop."),
clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageAnyLoop,
"any-storage-any-loop",
- "Enable sparse parallelization for any storage and loop."))}]>
+ "Enable sparse parallelization for any storage and loop."))}]>,
+ Option<"enableGPULibgen", "enable-gpu-libgen", "bool",
+ "false",
+ "Enable GPU acceleration by means of direct library calls (like cuSPARSE)">,
+ Option<"enableRuntimeLibrary", "enable-runtime-library", "bool",
+ "true", "Enable runtime library for manipulating sparse tensors">,
];
}