From: Christian Sigg Date: Thu, 28 Jan 2021 14:29:27 +0000 (+0100) Subject: [mlir] Make cuda/rocm-runtime-wrappers not depend on LLVMSupport. X-Git-Tag: llvmorg-14-init~16682 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5bdc771fc97ed752af42562c33a18c3ea28b098e;p=platform%2Fupstream%2Fllvm.git [mlir] Make cuda/rocm-runtime-wrappers not depend on LLVMSupport. Depending on the headers only is fine, but we do not want to use any symbols from LLVMSupport. If we do, static registration of cl options is linked in as well, and loading multiple such libraries in the cuda/rocm-runner fails because the same cl options are registered multiple times. The cuda/rocm-runners also depend on LLVMSupport, so one could think that already loading a single such library would fail. It does not because the map of cl options is not shared between the runner and the loaded libraries (but it is shared across all loaded libraries, presumably because it has external linkage, in contrast to the static registration which has internal linkage). This change is a preparation step for dynamically loading the mlir_async_runtime.so and cuda-runtime-wrappers.so in the same test. The async runtime depends on LLVMSupport in a more fundamental way (llvm::ThreadPool), and as explained above there can only be one. This change also switches to add_mlir_library to make it consistent with the other runner_utils libraries. Reviewed By: herhut Differential Revision: https://reviews.llvm.org/D95613 --- diff --git a/mlir/tools/mlir-cuda-runner/CMakeLists.txt b/mlir/tools/mlir-cuda-runner/CMakeLists.txt index 8a99418..f9c5bc0 100644 --- a/mlir/tools/mlir-cuda-runner/CMakeLists.txt +++ b/mlir/tools/mlir-cuda-runner/CMakeLists.txt @@ -27,16 +27,18 @@ if(MLIR_CUDA_RUNNER_ENABLED) # We need the libcuda.so library. find_library(CUDA_RUNTIME_LIBRARY cuda) - add_llvm_library(cuda-runtime-wrappers SHARED + add_mlir_library(cuda-runtime-wrappers + SHARED cuda-runtime-wrappers.cpp + + EXCLUDE_FROM_LIBMLIR ) target_include_directories(cuda-runtime-wrappers - PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} - LLVMSupport + PRIVATE + ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ) target_link_libraries(cuda-runtime-wrappers - PUBLIC - LLVMSupport + PRIVATE ${CUDA_RUNTIME_LIBRARY} ) diff --git a/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp b/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp index 306ca51..d4360de 100644 --- a/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp +++ b/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp @@ -17,7 +17,6 @@ #include "mlir/ExecutionEngine/CRunnerUtils.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/Support/raw_ostream.h" #include "cuda.h" @@ -29,7 +28,7 @@ cuGetErrorName(result, &name); \ if (!name) \ name = ""; \ - llvm::errs() << "'" << #expr << "' failed with '" << name << "'\n"; \ + fprintf(stderr, "'%s' failed with '%s'\n", #expr, name); \ }(expr) // Static reference to CUDA primary context for device ordinal 0. diff --git a/mlir/tools/mlir-rocm-runner/CMakeLists.txt b/mlir/tools/mlir-rocm-runner/CMakeLists.txt index a4da496..effcbaf 100644 --- a/mlir/tools/mlir-rocm-runner/CMakeLists.txt +++ b/mlir/tools/mlir-rocm-runner/CMakeLists.txt @@ -49,18 +49,19 @@ if(MLIR_ROCM_RUNNER_ENABLED) # Set HIP compile-time flags. add_definitions(-D__HIP_PLATFORM_HCC__) - add_llvm_library(rocm-runtime-wrappers SHARED + add_mlir_library(rocm-runtime-wrappers + SHARED rocm-runtime-wrappers.cpp + + EXCLUDE_FROM_LIBMLIR ) target_include_directories(rocm-runtime-wrappers PRIVATE "${HIP_PATH}/../include" "${HIP_PATH}/include" - LLVMSupport ) target_link_libraries(rocm-runtime-wrappers - PUBLIC - LLVMSupport + PRIVATE ${ROCM_RUNTIME_LIBRARY} ) diff --git a/mlir/tools/mlir-rocm-runner/rocm-runtime-wrappers.cpp b/mlir/tools/mlir-rocm-runner/rocm-runtime-wrappers.cpp index 5f693c3..cf3c757 100644 --- a/mlir/tools/mlir-rocm-runner/rocm-runtime-wrappers.cpp +++ b/mlir/tools/mlir-rocm-runner/rocm-runtime-wrappers.cpp @@ -17,7 +17,6 @@ #include "mlir/ExecutionEngine/CRunnerUtils.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/Support/raw_ostream.h" #include "hip/hip_runtime.h" @@ -28,7 +27,7 @@ const char *name = hipGetErrorName(result); \ if (!name) \ name = ""; \ - llvm::errs() << "'" << #expr << "' failed with '" << name << "'\n"; \ + fprintf(stderr, "'%s' failed with '%s'\n", #expr, name); \ }(expr) // Static reference to HIP primary context for device ordinal 0.