[mlir] Move cuda tests

Move test inputs to test/Integration directory.
Move runtime wrappers to ExecutionEngine.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D97463
This commit is contained in:
Christian Sigg 2021-03-03 11:24:38 +01:00
parent 243cd0afad
commit 9d7be77bf9
19 changed files with 51 additions and 34 deletions

View File

@ -4,6 +4,7 @@
set(LLVM_OPTIONAL_SOURCES
AsyncRuntime.cpp
CRunnerUtils.cpp
CudaRuntimeWrappers.cpp
SparseUtils.cpp
ExecutionEngine.cpp
RunnerUtils.cpp
@ -102,3 +103,34 @@ add_mlir_library(mlir_async_runtime
set_property(TARGET mlir_async_runtime PROPERTY CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(mlir_async_runtime PRIVATE mlir_async_runtime_EXPORTS)
if(MLIR_CUDA_RUNNER_ENABLED)
# Configure CUDA support. Using check_language first allows us to give a
# custom error message.
include(CheckLanguage)
check_language(CUDA)
if (CMAKE_CUDA_COMPILER)
enable_language(CUDA)
else()
message(SEND_ERROR
"Building the mlir cuda runner requires a working CUDA install")
endif()
# We need the libcuda.so library.
find_library(CUDA_RUNTIME_LIBRARY cuda)
add_mlir_library(mlir_cuda_runtime
SHARED
CudaRuntimeWrappers.cpp
EXCLUDE_FROM_LIBMLIR
)
set_property(TARGET mlir_cuda_runtime PROPERTY CXX_STANDARD 14)
target_include_directories(mlir_cuda_runtime
PRIVATE
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
target_link_libraries(mlir_cuda_runtime
PRIVATE
${CUDA_RUNTIME_LIBRARY}
)
endif()

View File

@ -1,4 +1,4 @@
//===- cuda-runtime-wrappers.cpp - MLIR CUDA runner wrapper library -------===//
//===- CudaRuntimeWrappers.cpp - MLIR CUDA API wrapper library ------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.

View File

@ -21,8 +21,7 @@ set(MLIR_DIALECT_LINALG_INTEGRATION_TEST_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTOR
set(MLIR_RUNNER_UTILS_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
# Passed to lit.site.cfg.py.in to set up the path where to find the libraries
# for the mlir cuda / rocm / spirv / vulkan runner tests.
set(MLIR_CUDA_WRAPPER_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
# for the mlir rocm / spirv / vulkan runner tests.
set(MLIR_ROCM_WRAPPER_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(MLIR_SPIRV_WRAPPER_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(MLIR_VULKAN_WRAPPER_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
@ -70,6 +69,10 @@ set(MLIR_TEST_DEPENDS
mlir_async_runtime
)
if(MLIR_CUDA_RUNNER_ENABLED)
list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime)
endif()
list(APPEND MLIR_TEST_DEPENDS MLIRUnitTests)
if(LLVM_BUILD_EXAMPLES)

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -3,7 +3,7 @@
// RUN: -gpu-async-region -async-ref-counting \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: -async-to-async-runtime -convert-async-to-llvm -convert-std-to-llvm \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_async_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void -O0 \

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -1,7 +1,7 @@
// RUN: mlir-cuda-runner %s \
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
// RUN: --entry-point-result=void \
// RUN: | FileCheck %s

View File

@ -75,7 +75,6 @@ tools.extend([
ToolSubst('toy-ch3', unresolved='ignore'),
ToolSubst('toy-ch4', unresolved='ignore'),
ToolSubst('toy-ch5', unresolved='ignore'),
ToolSubst('%cuda_wrapper_library_dir', config.cuda_wrapper_library_dir, unresolved='ignore'),
ToolSubst('%linalg_test_lib_dir', config.linalg_test_lib_dir, unresolved='ignore'),
ToolSubst('%mlir_runner_utils_dir', config.mlir_runner_utils_dir, unresolved='ignore'),
ToolSubst('%rocm_wrapper_library_dir', config.rocm_wrapper_library_dir, unresolved='ignore'),

View File

@ -36,7 +36,6 @@ config.mlir_tools_dir = "@MLIR_TOOLS_DIR@"
config.linalg_test_lib_dir = "@MLIR_DIALECT_LINALG_INTEGRATION_TEST_LIB_DIR@"
config.build_examples = @LLVM_BUILD_EXAMPLES@
config.run_cuda_tests = @MLIR_CUDA_CONVERSIONS_ENABLED@
config.cuda_wrapper_library_dir = "@MLIR_CUDA_WRAPPER_LIBRARY_DIR@"
config.enable_cuda_runner = @MLIR_CUDA_RUNNER_ENABLED@
config.run_rocm_tests = @MLIR_ROCM_CONVERSIONS_ENABLED@
config.rocm_wrapper_library_dir = "@MLIR_ROCM_WRAPPER_LIBRARY_DIR@"

View File

@ -1,5 +1,4 @@
set(LLVM_OPTIONAL_SOURCES
cuda-runtime-wrappers.cpp
mlir-cuda-runner.cpp
)
set(LLVM_LINK_COMPONENTS
@ -27,21 +26,6 @@ if(MLIR_CUDA_RUNNER_ENABLED)
# We need the libcuda.so library.
find_library(CUDA_RUNTIME_LIBRARY cuda)
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}
)
target_link_libraries(cuda-runtime-wrappers
PRIVATE
${CUDA_RUNTIME_LIBRARY}
)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
set(LIBS
${conversion_libs}
@ -79,7 +63,7 @@ if(MLIR_CUDA_RUNNER_ENABLED)
mlir-cuda-runner.cpp
DEPENDS
cuda-runtime-wrappers
mlir_cuda_runtime
)
target_include_directories(mlir-cuda-runner
PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}