Skip to content

[MLIR] Reuse the path to runner_utils libraries #108579

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 4 commits into from
Sep 18, 2024
Merged

Conversation

tuliom
Copy link
Contributor

@tuliom tuliom commented Sep 13, 2024

Prefer to get the path to libmlir_runner_utils and libmlir_c_runner_utils via %mlir_runner_utils and %mlir_c_runner_utils. Fallback to the previous paths only if they aren't defined.

This ensures the test will pass regardless of the build configuration used downstream.

Prefer to get the path to the shared libraries from config.llvm_shlib_dir.
Fallback to the previous path only if config.llvm_shlib_dir is not
defined.

This ensures the test will pass regardless of the build configuration
used downstream.
@llvmbot
Copy link
Member

llvmbot commented Sep 13, 2024

@llvm/pr-subscribers-mlir

Author: Tulio Magno Quites Machado Filho (tuliom)

Changes

Prefer to get the path to the shared libraries from config.llvm_shlib_dir. Fallback to the previous path only if config.llvm_shlib_dir is not defined.

This ensures the test will pass regardless of the build configuration used downstream.


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

2 Files Affected:

  • (modified) mlir/test/lit.cfg.py (+1)
  • (modified) mlir/test/python/execution_engine.py (+7-5)
diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py
index f0d4f35ba3e229..a194dbd72d1eb7 100644
--- a/mlir/test/lit.cfg.py
+++ b/mlir/test/lit.cfg.py
@@ -168,6 +168,7 @@ def add_runtime(name):
         ToolSubst("transform-opt-ch3", unresolved="ignore"),
         ToolSubst("transform-opt-ch4", unresolved="ignore"),
         ToolSubst("mlir-transform-opt", unresolved="ignore"),
+        ToolSubst("%llvm_shlib_dir", config.llvm_shlib_dir, unresolved="ignore"),
         ToolSubst("%mlir_lib_dir", config.mlir_lib_dir, unresolved="ignore"),
         ToolSubst("%mlir_src_dir", config.mlir_src_root, unresolved="ignore"),
     ]
diff --git a/mlir/test/python/execution_engine.py b/mlir/test/python/execution_engine.py
index 1cdda63eefe300..eb075054c9f239 100644
--- a/mlir/test/python/execution_engine.py
+++ b/mlir/test/python/execution_engine.py
@@ -1,4 +1,4 @@
-# RUN: %PYTHON %s 2>&1 | FileCheck %s
+# RUN: env LLVM_SHLIB_DIR=%llvm_shlib_dir %PYTHON %s 2>&1 | FileCheck %s
 # REQUIRES: host-supports-jit
 import gc, sys, os, tempfile
 from mlir.ir import *
@@ -7,6 +7,8 @@
 from mlir.runtime import *
 from ml_dtypes import bfloat16, float8_e5m2
 
+_DEFAULT_LIB_DIR = "../../../../lib"
+LIB_DIR = os.getenv("LLVM_SHLIB_DIR", _DEFAULT_LIB_DIR)
 
 # Log everything to stderr and flush so that we have a unified stream to match
 # errors/info emitted by MLIR to stderr.
@@ -700,8 +702,8 @@ def testSharedLibLoad():
             ]
         else:
             shared_libs = [
-                "../../../../lib/libmlir_runner_utils.so",
-                "../../../../lib/libmlir_c_runner_utils.so",
+                LIB_DIR + "/libmlir_runner_utils.so",
+                LIB_DIR + "/libmlir_c_runner_utils.so",
             ]
 
         execution_engine = ExecutionEngine(
@@ -743,8 +745,8 @@ def testNanoTime():
             ]
         else:
             shared_libs = [
-                "../../../../lib/libmlir_runner_utils.so",
-                "../../../../lib/libmlir_c_runner_utils.so",
+                LIB_DIR + "/libmlir_runner_utils.so",
+                LIB_DIR + "/libmlir_c_runner_utils.so",
             ]
 
         execution_engine = ExecutionEngine(

@tuliom tuliom changed the title [MLIR] Reuse the library directory [MLIR] Reuse the path to runner_utils libraries Sep 17, 2024
Copy link

github-actions bot commented Sep 17, 2024

✅ With the latest revision this PR passed the Python code formatter.

@tuliom
Copy link
Contributor Author

tuliom commented Sep 17, 2024

I updated this PR based on the comments from @makslevental . Subject and description have been updated in order to reflect these changes.

Copy link
Contributor

@makslevental makslevental left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks (sorry this was a disruption...)

@makslevental
Copy link
Contributor

Let me know if you need me to merge

@tuliom
Copy link
Contributor Author

tuliom commented Sep 18, 2024

I can merge it. Thanks!

@tuliom tuliom merged commit 4eee0cf into llvm:main Sep 18, 2024
8 checks passed
tmsri pushed a commit to tmsri/llvm-project that referenced this pull request Sep 19, 2024
Prefer to get the path to libmlir_runner_utils and
libmlir_c_runner_utils via %mlir_runner_utils and %mlir_c_runner_utils.
Fallback to the previous paths only if they aren't defined.

This ensures the test will pass regardless of the build configuration
used downstream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants