Skip to content

[mlir][test] Shard the Test Dialect (NFC) #89628

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 2 commits into from
Apr 24, 2024
Merged

[mlir][test] Shard the Test Dialect (NFC) #89628

merged 2 commits into from
Apr 24, 2024

Conversation

Mogball
Copy link
Contributor

@Mogball Mogball commented Apr 22, 2024

Stacked PRs:


[mlir][test] Shard the Test Dialect (NFC)

This PR uses the new op sharding mechanism in tablegen to shard the test
dialect's op definitions. This breaks the definition of ops into
multiple source files, speeding up compile time of the test dialect
dramatically. This improves developer cycle times when iterating on the
test dialect.

@Mogball Mogball requested a review from rupprecht as a code owner April 22, 2024 16:48
Mogball pushed a commit that referenced this pull request Apr 22, 2024
This PR uses the new op sharding mechanism in tablegen to shard the test
dialect's op definitions. This breaks the definition of ops into
multiple source files, speeding up compile time of the test dialect
dramatically. This improves developer cycle times when iterating on the
test dialect.

stack-info: PR: #89628, branch: users/Mogball/stack/1
@Mogball Mogball force-pushed the users/Mogball/stack/1 branch from 498ea49 to 478b4e8 Compare April 22, 2024 16:48
@llvmbot llvmbot added mlir bazel "Peripheral" support tier build system: utils/bazel labels Apr 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 22, 2024

@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-clang-codegen
@llvm/pr-subscribers-backend-spir-v
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-hlsl
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-mlir

Author: Jeff Niu (Mogball)

Changes

Stacked PRs:

  • ->#89628
  • #89424
  • #89423

[mlir][test] Shard the Test Dialect (NFC)

This PR uses the new op sharding mechanism in tablegen to shard the test
dialect's op definitions. This breaks the definition of ops into
multiple source files, speeding up compile time of the test dialect
dramatically. This improves developer cycle times when iterating on the
test dialect.


Full diff: https://github.com/llvm/llvm-project/pull/89628.diff

4 Files Affected:

  • (modified) mlir/test/lib/Dialect/Test/CMakeLists.txt (+4-2)
  • (modified) mlir/test/lib/Dialect/Test/TestDialect.cpp (+1-4)
  • (modified) mlir/test/lib/Dialect/Test/TestOps.cpp (-1)
  • (modified) utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel (+15-10)
diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt
index f63e4d330e6ac1..fab89378093326 100644
--- a/mlir/test/lib/Dialect/Test/CMakeLists.txt
+++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt
@@ -31,8 +31,6 @@ mlir_tablegen(TestOpEnums.cpp.inc -gen-enum-defs)
 add_public_tablegen_target(MLIRTestEnumDefIncGen)
 
 set(LLVM_TARGET_DEFINITIONS TestOps.td)
-mlir_tablegen(TestOps.h.inc -gen-op-decls)
-mlir_tablegen(TestOps.cpp.inc -gen-op-defs)
 mlir_tablegen(TestOpsDialect.h.inc -gen-dialect-decls -dialect=test)
 mlir_tablegen(TestOpsDialect.cpp.inc -gen-dialect-defs -dialect=test)
 mlir_tablegen(TestPatterns.inc -gen-rewriters)
@@ -43,6 +41,8 @@ mlir_tablegen(TestOpsSyntax.h.inc -gen-op-decls)
 mlir_tablegen(TestOpsSyntax.cpp.inc -gen-op-defs)
 add_public_tablegen_target(MLIRTestOpsSyntaxIncGen)
 
+add_sharded_ops(TestOps 20)
+
 # Exclude tests from libMLIR.so
 add_mlir_library(MLIRTestDialect
   TestAttributes.cpp
@@ -56,6 +56,7 @@ add_mlir_library(MLIRTestDialect
   TestTypes.cpp
   TestOpsSyntax.cpp
   TestDialectInterfaces.cpp
+  ${SHARDED_SRCS}
 
   EXCLUDE_FROM_LIBMLIR
 
@@ -66,6 +67,7 @@ add_mlir_library(MLIRTestDialect
   MLIRTestTypeDefIncGen
   MLIRTestOpsIncGen
   MLIRTestOpsSyntaxIncGen
+  MLIRTestOpsShardGen
 
   LINK_LIBS PUBLIC
   MLIRControlFlowInterfaces
diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp
index 77fd7e61bd3a06..bfb9592e638288 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.cpp
+++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp
@@ -326,12 +326,9 @@ struct TestOpEffectInterfaceFallback
 void TestDialect::initialize() {
   registerAttributes();
   registerTypes();
-  addOperations<
-#define GET_OP_LIST
-#include "TestOps.cpp.inc"
-      >();
   registerOpsSyntax();
   addOperations<ManualCppOpWithFold>();
+  registerTestDialectOperations(this);
   registerDynamicOp(getDynamicGenericOp(this));
   registerDynamicOp(getDynamicOneOperandTwoResultsOp(this));
   registerDynamicOp(getDynamicCustomParserPrinterOp(this));
diff --git a/mlir/test/lib/Dialect/Test/TestOps.cpp b/mlir/test/lib/Dialect/Test/TestOps.cpp
index ce7e476be74e65..47d5b1b19121ef 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.cpp
+++ b/mlir/test/lib/Dialect/Test/TestOps.cpp
@@ -14,5 +14,4 @@
 using namespace mlir;
 using namespace test;
 
-#define GET_OP_CLASSES
 #include "TestOps.cpp.inc"
diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel
index dc5f4047c286db..b98f7eb5613af4 100644
--- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel
@@ -4,7 +4,7 @@
 
 load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
 load("//llvm:lit_test.bzl", "package_path")
-load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")
+load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library", "gentbl_sharded_ops", "td_library")
 
 package(
     default_visibility = ["//visibility:public"],
@@ -151,14 +151,6 @@ gentbl_cc_library(
     name = "TestOpsIncGen",
     strip_include_prefix = "lib/Dialect/Test",
     tbl_outs = [
-        (
-            ["-gen-op-decls"],
-            "lib/Dialect/Test/TestOps.h.inc",
-        ),
-        (
-            ["-gen-op-defs"],
-            "lib/Dialect/Test/TestOps.cpp.inc",
-        ),
         (
             [
                 "-gen-dialect-decls",
@@ -370,12 +362,25 @@ cc_library(
     ],
 )
 
+gentbl_sharded_ops(
+    name = "TestDialectOpSrcs",
+    hdr_out = "lib/Dialect/Test/TestOps.h.inc",
+    shard_count = 20,
+    sharder = "//mlir:mlir-src-sharder",
+    src_file = "lib/Dialect/Test/TestOps.cpp",
+    src_out = "lib/Dialect/Test/TestOps.cpp.inc",
+    tblgen = "//mlir:mlir-tblgen",
+    td_file = "lib/Dialect/Test/TestOps.td",
+    test = True,
+    deps = [":TestOpTdFiles"],
+)
+
 cc_library(
     name = "TestDialect",
     srcs = glob(
         ["lib/Dialect/Test/*.cpp"],
         exclude = ["lib/Dialect/Test/TestToLLVMIRTranslation.cpp"],
-    ),
+    ) + [":TestDialectOpSrcs"],
     hdrs = glob(["lib/Dialect/Test/*.h"]),
     includes = [
         "lib/Dialect/Test",

@Mogball Mogball requested review from joker-eph and jpienaar April 22, 2024 16:49
@Mogball Mogball force-pushed the users/Mogball/stack/1 branch 2 times, most recently from 5bfaf90 to 75068fa Compare April 22, 2024 17:02
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:X86 clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen IR generation bugs: mangling, exceptions, etc. mlir:core MLIR Core Infrastructure vectorizers HLSL HLSL Language Support backend:SPIR-V llvm:ir llvm:transforms labels Apr 22, 2024
@Mogball Mogball force-pushed the users/Mogball/stack/1 branch from 75068fa to 478b4e8 Compare April 22, 2024 17:04
@Mogball Mogball removed backend:X86 clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen IR generation bugs: mangling, exceptions, etc. backend:SPIR-V bazel "Peripheral" support tier build system: utils/bazel labels Apr 22, 2024
@llvmbot llvmbot added the bazel "Peripheral" support tier build system: utils/bazel label Apr 22, 2024
@Mogball Mogball removed the clang Clang issues not falling into any other category label Apr 22, 2024
@Mogball Mogball changed the base branch from main to users/mogball/pr_1 April 22, 2024 20:42
Base automatically changed from users/mogball/pr_1 to main April 24, 2024 21:58
@Mogball Mogball merged commit ae22ac9 into main Apr 24, 2024
@Mogball Mogball deleted the users/Mogball/stack/1 branch April 24, 2024 21:59
Zentrik added a commit to Zentrik/llvm-project that referenced this pull request Aug 30, 2024
Zentrik added a commit to Zentrik/Yggdrasil that referenced this pull request Sep 1, 2024
giordano added a commit to JuliaPackaging/Yggdrasil that referenced this pull request Oct 12, 2024
* [LLVM] Add LLVM_full, LLVM_full_assert 19 recipes

* Update patch

* Test fixes

* Test another fix

* Try less targeted fix

* Remove assert bundled

* Add assert bundled

* Adapt to llvm/llvm-project#89628

* Workaround llvm/llvm-project#106899

* Include less patches to llvm

* Fix `DMLIR_SRC_SHARDER_TABLEGEN`

* Just set `LLVM_NATIVE_TOOL_DIR` instead

* Trigger rebuilds

* Build off of Julia Fork

* Fix tag

* Set correct version

* Set correct version

* Update L/LLVM/common.jl

* Update L/LLVM/common.jl

* [LLVM] Upgrade to v19.1.1

* Bump LLVM version

* Apply suggestions from code review

* Bump LLVM

Co-authored-by: Mosè Giordano <[email protected]>

* rebuild

* rebuild

---------

Co-authored-by: Zentrik <[email protected]>
Co-authored-by: Mosè Giordano <[email protected]>
Co-authored-by: Mosè Giordano <[email protected]>
avik-pal pushed a commit to avik-pal/Yggdrasil that referenced this pull request Oct 25, 2024
* [LLVM] Add LLVM_full, LLVM_full_assert 19 recipes

* Update patch

* Test fixes

* Test another fix

* Try less targeted fix

* Remove assert bundled

* Add assert bundled

* Adapt to llvm/llvm-project#89628

* Workaround llvm/llvm-project#106899

* Include less patches to llvm

* Fix `DMLIR_SRC_SHARDER_TABLEGEN`

* Just set `LLVM_NATIVE_TOOL_DIR` instead

* Trigger rebuilds

* Build off of Julia Fork

* Fix tag

* Set correct version

* Set correct version

* Update L/LLVM/common.jl

* Update L/LLVM/common.jl

* [LLVM] Upgrade to v19.1.1

* Bump LLVM version

* Apply suggestions from code review

* Bump LLVM

Co-authored-by: Mosè Giordano <[email protected]>

* rebuild

* rebuild

---------

Co-authored-by: Zentrik <[email protected]>
Co-authored-by: Mosè Giordano <[email protected]>
Co-authored-by: Mosè Giordano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants