[Mlir-commits] [mlir] [MLIR] Reuse the library directory (PR #108579)

Tulio Magno Quites Machado Filho llvmlistbot at llvm.org
Tue Sep 17 07:21:29 PDT 2024


https://github.com/tuliom updated https://github.com/llvm/llvm-project/pull/108579

>From 66fb60ca662b8933ba1e7f170c54c45c07504b12 Mon Sep 17 00:00:00 2001
From: Tulio Magno Quites Machado Filho <tuliom at redhat.com>
Date: Tue, 5 Sep 2023 10:35:37 -0300
Subject: [PATCH 1/2] [MLIR] Reuse the library directory

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.
---
 mlir/test/lit.cfg.py                 |  1 +
 mlir/test/python/execution_engine.py | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

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(

>From a6ab3e51e6d63bb0f9c5047125e621e11b54617f Mon Sep 17 00:00:00 2001
From: Tulio Magno Quites Machado Filho <tuliom at redhat.com>
Date: Tue, 17 Sep 2024 11:20:57 -0300
Subject: [PATCH 2/2] fixup! [MLIR] Reuse the library directory

---
 mlir/test/lit.cfg.py                 |  1 -
 mlir/test/python/execution_engine.py | 10 +++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py
index a194dbd72d1eb7..f0d4f35ba3e229 100644
--- a/mlir/test/lit.cfg.py
+++ b/mlir/test/lit.cfg.py
@@ -168,7 +168,6 @@ 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 eb075054c9f239..df32bf7394f013 100644
--- a/mlir/test/python/execution_engine.py
+++ b/mlir/test/python/execution_engine.py
@@ -1,4 +1,4 @@
-# RUN: env LLVM_SHLIB_DIR=%llvm_shlib_dir %PYTHON %s 2>&1 | FileCheck %s
+# RUN: env MLIR_RUNNER_UTILS=%mlir_runner_utils MLIR_C_RUNNER_UTILS=%mlir_c_runner_utils %PYTHON %s 2>&1 | FileCheck %s
 # REQUIRES: host-supports-jit
 import gc, sys, os, tempfile
 from mlir.ir import *
@@ -7,8 +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)
+MLIR_RUNNER_UTILS = os.getenv("MLIR_RUNNER_UTILS", "../../../../lib/libmlir_runner_utils.so")
+MLIR_C_RUNNER_UTILS = os.getenv("MLIR_C_RUNNER_UTILS", "../../../../lib/libmlir_c_runner_utils.so")
 
 # Log everything to stderr and flush so that we have a unified stream to match
 # errors/info emitted by MLIR to stderr.
@@ -702,8 +702,8 @@ def testSharedLibLoad():
             ]
         else:
             shared_libs = [
-                LIB_DIR + "/libmlir_runner_utils.so",
-                LIB_DIR + "/libmlir_c_runner_utils.so",
+                MLIR_RUNNER_UTILS,
+                MLIR_C_RUNNER_UTILS,
             ]
 
         execution_engine = ExecutionEngine(



More information about the Mlir-commits mailing list