Skip to content

Commit 9d7be77

Browse files
committed
[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
1 parent 243cd0a commit 9d7be77

19 files changed

+51
-34
lines changed

mlir/lib/ExecutionEngine/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
set(LLVM_OPTIONAL_SOURCES
55
AsyncRuntime.cpp
66
CRunnerUtils.cpp
7+
CudaRuntimeWrappers.cpp
78
SparseUtils.cpp
89
ExecutionEngine.cpp
910
RunnerUtils.cpp
@@ -102,3 +103,34 @@ add_mlir_library(mlir_async_runtime
102103
set_property(TARGET mlir_async_runtime PROPERTY CXX_VISIBILITY_PRESET hidden)
103104
target_compile_definitions(mlir_async_runtime PRIVATE mlir_async_runtime_EXPORTS)
104105

106+
if(MLIR_CUDA_RUNNER_ENABLED)
107+
# Configure CUDA support. Using check_language first allows us to give a
108+
# custom error message.
109+
include(CheckLanguage)
110+
check_language(CUDA)
111+
if (CMAKE_CUDA_COMPILER)
112+
enable_language(CUDA)
113+
else()
114+
message(SEND_ERROR
115+
"Building the mlir cuda runner requires a working CUDA install")
116+
endif()
117+
118+
# We need the libcuda.so library.
119+
find_library(CUDA_RUNTIME_LIBRARY cuda)
120+
121+
add_mlir_library(mlir_cuda_runtime
122+
SHARED
123+
CudaRuntimeWrappers.cpp
124+
125+
EXCLUDE_FROM_LIBMLIR
126+
)
127+
set_property(TARGET mlir_cuda_runtime PROPERTY CXX_STANDARD 14)
128+
target_include_directories(mlir_cuda_runtime
129+
PRIVATE
130+
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
131+
)
132+
target_link_libraries(mlir_cuda_runtime
133+
PRIVATE
134+
${CUDA_RUNTIME_LIBRARY}
135+
)
136+
endif()

mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp renamed to mlir/lib/ExecutionEngine/CudaRuntimeWrappers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- cuda-runtime-wrappers.cpp - MLIR CUDA runner wrapper library -------===//
1+
//===- CudaRuntimeWrappers.cpp - MLIR CUDA API wrapper library ------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

mlir/test/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ set(MLIR_DIALECT_LINALG_INTEGRATION_TEST_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTOR
2121
set(MLIR_RUNNER_UTILS_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
2222

2323
# Passed to lit.site.cfg.py.in to set up the path where to find the libraries
24-
# for the mlir cuda / rocm / spirv / vulkan runner tests.
25-
set(MLIR_CUDA_WRAPPER_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
24+
# for the mlir rocm / spirv / vulkan runner tests.
2625
set(MLIR_ROCM_WRAPPER_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
2726
set(MLIR_SPIRV_WRAPPER_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
2827
set(MLIR_VULKAN_WRAPPER_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
@@ -70,6 +69,10 @@ set(MLIR_TEST_DEPENDS
7069
mlir_async_runtime
7170
)
7271

72+
if(MLIR_CUDA_RUNNER_ENABLED)
73+
list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime)
74+
endif()
75+
7376
list(APPEND MLIR_TEST_DEPENDS MLIRUnitTests)
7477

7578
if(LLVM_BUILD_EXAMPLES)

mlir/test/mlir-cuda-runner/all-reduce-and.mlir renamed to mlir/test/Integration/GPU/CUDA/all-reduce-and.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/all-reduce-max.mlir renamed to mlir/test/Integration/GPU/CUDA/all-reduce-max.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/all-reduce-min.mlir renamed to mlir/test/Integration/GPU/CUDA/all-reduce-min.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/all-reduce-op.mlir renamed to mlir/test/Integration/GPU/CUDA/all-reduce-op.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/all-reduce-or.mlir renamed to mlir/test/Integration/GPU/CUDA/all-reduce-or.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/all-reduce-region.mlir renamed to mlir/test/Integration/GPU/CUDA/all-reduce-region.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/all-reduce-xor.mlir renamed to mlir/test/Integration/GPU/CUDA/all-reduce-xor.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/async.mlir renamed to mlir/test/Integration/GPU/CUDA/async.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: -gpu-async-region -async-ref-counting \
44
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
55
// RUN: -async-to-async-runtime -convert-async-to-llvm -convert-std-to-llvm \
6-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
6+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
77
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_async_runtime%shlibext \
88
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
99
// RUN: --entry-point-result=void -O0 \

mlir/test/mlir-cuda-runner/gpu-to-cubin.mlir renamed to mlir/test/Integration/GPU/CUDA/gpu-to-cubin.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/multiple-all-reduce.mlir renamed to mlir/test/Integration/GPU/CUDA/multiple-all-reduce.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/shuffle.mlir renamed to mlir/test/Integration/GPU/CUDA/shuffle.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/mlir-cuda-runner/two-modules.mlir renamed to mlir/test/Integration/GPU/CUDA/two-modules.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: mlir-cuda-runner %s \
22
// RUN: -gpu-to-cubin="gpu-binary-annotation=nvvm.cubin" \
33
// RUN: -gpu-to-llvm="gpu-binary-annotation=nvvm.cubin" \
4-
// RUN: --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext \
4+
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \
55
// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
66
// RUN: --entry-point-result=void \
77
// RUN: | FileCheck %s

mlir/test/lit.cfg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
ToolSubst('toy-ch3', unresolved='ignore'),
7676
ToolSubst('toy-ch4', unresolved='ignore'),
7777
ToolSubst('toy-ch5', unresolved='ignore'),
78-
ToolSubst('%cuda_wrapper_library_dir', config.cuda_wrapper_library_dir, unresolved='ignore'),
7978
ToolSubst('%linalg_test_lib_dir', config.linalg_test_lib_dir, unresolved='ignore'),
8079
ToolSubst('%mlir_runner_utils_dir', config.mlir_runner_utils_dir, unresolved='ignore'),
8180
ToolSubst('%rocm_wrapper_library_dir', config.rocm_wrapper_library_dir, unresolved='ignore'),

mlir/test/lit.site.cfg.py.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ config.mlir_tools_dir = "@MLIR_TOOLS_DIR@"
3636
config.linalg_test_lib_dir = "@MLIR_DIALECT_LINALG_INTEGRATION_TEST_LIB_DIR@"
3737
config.build_examples = @LLVM_BUILD_EXAMPLES@
3838
config.run_cuda_tests = @MLIR_CUDA_CONVERSIONS_ENABLED@
39-
config.cuda_wrapper_library_dir = "@MLIR_CUDA_WRAPPER_LIBRARY_DIR@"
4039
config.enable_cuda_runner = @MLIR_CUDA_RUNNER_ENABLED@
4140
config.run_rocm_tests = @MLIR_ROCM_CONVERSIONS_ENABLED@
4241
config.rocm_wrapper_library_dir = "@MLIR_ROCM_WRAPPER_LIBRARY_DIR@"

mlir/tools/mlir-cuda-runner/CMakeLists.txt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
set(LLVM_OPTIONAL_SOURCES
2-
cuda-runtime-wrappers.cpp
32
mlir-cuda-runner.cpp
43
)
54
set(LLVM_LINK_COMPONENTS
@@ -27,21 +26,6 @@ if(MLIR_CUDA_RUNNER_ENABLED)
2726
# We need the libcuda.so library.
2827
find_library(CUDA_RUNTIME_LIBRARY cuda)
2928

30-
add_mlir_library(cuda-runtime-wrappers
31-
SHARED
32-
cuda-runtime-wrappers.cpp
33-
34-
EXCLUDE_FROM_LIBMLIR
35-
)
36-
target_include_directories(cuda-runtime-wrappers
37-
PRIVATE
38-
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
39-
)
40-
target_link_libraries(cuda-runtime-wrappers
41-
PRIVATE
42-
${CUDA_RUNTIME_LIBRARY}
43-
)
44-
4529
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
4630
set(LIBS
4731
${conversion_libs}
@@ -79,7 +63,7 @@ if(MLIR_CUDA_RUNNER_ENABLED)
7963
mlir-cuda-runner.cpp
8064

8165
DEPENDS
82-
cuda-runtime-wrappers
66+
mlir_cuda_runtime
8367
)
8468
target_include_directories(mlir-cuda-runner
8569
PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}

0 commit comments

Comments
 (0)