Skip to content
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

[mlir][nvvm] Fix circular dependency in #68934

Merged
merged 1 commit into from
Oct 12, 2023
Merged

[mlir][nvvm] Fix circular dependency in #68934

merged 1 commit into from
Oct 12, 2023

Conversation

grypp
Copy link
Member

@grypp grypp commented Oct 12, 2023

BasicPtxBuilder includes NVVMDialect and vice versa. Cmake appereantly forgives that, but this causes bazel build fails. This PR aims to fix that

BasicPtxBuilder includes NVVMDialect and vice versa. Cmake appereantly forgives that, but this causes bazel build fails. This PR aims to fix that
@llvmbot
Copy link
Member

llvmbot commented Oct 12, 2023

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-llvm

Author: Guray Ozen (grypp)

Changes

BasicPtxBuilder includes NVVMDialect and vice versa. Cmake appereantly forgives that, but this causes bazel build fails. This PR aims to fix that


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

1 Files Affected:

  • (modified) mlir/lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp (+3-2)
diff --git a/mlir/lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp b/mlir/lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp
index eeedccf3ba3fcbc..121504fc20c018f 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp
@@ -12,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.h"
-#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
 #include "mlir/Support/LogicalResult.h"
 
 #define DEBUG_TYPE "ptx-builder"
@@ -28,6 +27,8 @@
 using namespace mlir;
 using namespace NVVM;
 
+static constexpr int64_t kSharedMemorySpace = 3;
+
 static char getRegisterType(Type type) {
   if (type.isInteger(1))
     return 'b';
@@ -43,7 +44,7 @@ static char getRegisterType(Type type) {
     return 'd';
   if (auto ptr = type.dyn_cast<LLVM::LLVMPointerType>()) {
     // Shared address spaces is addressed with 32-bit pointers.
-    if (ptr.getAddressSpace() == NVVM::kSharedMemorySpace) {
+    if (ptr.getAddressSpace() == kSharedMemorySpace) {
       return 'r';
     }
     return 'l';

@grypp grypp merged commit 282ea28 into llvm:main Oct 12, 2023
@joker-eph
Copy link
Collaborator

I don't think there is a circular dependencies here actually: the header includes are safe. This is something fairly common that in general is worked around in Basel build files instead of duplicating the information in MLIR to work around Bazel.

@grypp
Copy link
Member Author

grypp commented Oct 13, 2023

You might be right. Thanks for the heads-up. I'm not too familiar with Bazel, but I got complaints about my PR breaking the build. They said the header was the issue, so I removed it, and it worked 🚀.

I'm not a fan of this PR because of duplicate static int. I'll dig into it more tomorrow or next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants