Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 9d48f0a

Browse files
tc_code_cuda_no_sdk library
This changeset splits the cross_compilation behavior in an independent library that can be used with or without a GPU
1 parent 275c46d commit 9d48f0a

File tree

6 files changed

+97
-32
lines changed

6 files changed

+97
-32
lines changed

src/autotuner/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (WITH_CUDA)
1313
utils/utils.cc)
1414

1515
target_include_directories(tc_autotuner PUBLIC ${PROJECT_SOURCE_DIR}/include)
16-
target_link_libraries(tc_autotuner PUBLIC ${ATEN_LIBRARIES} tc_core tc_proto)
16+
target_link_libraries(tc_autotuner PUBLIC ${ATEN_LIBRARIES} tc_cuda tc_proto)
1717

1818
install(TARGETS tc_autotuner DESTINATION lib)
1919
endif()

src/c2/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ target_link_libraries(
1515
${PROTOBUF_LIBRARIES}
1616
${CAFFE2_CPU_LIBRARIES}
1717
${CAFFE2_GPU_LIBRARIES}
18-
tc_core
19-
tc_lang
18+
19+
tc_cuda
2020
)
2121

2222
install(

src/core/CMakeLists.txt

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
################################################################################
2+
# tc_core
3+
#
4+
# Core CPU library with cross-compilation capabilities linked from
5+
# tc_core_cuda
6+
################################################################################
17
add_library(
28
tc_core
39

@@ -26,15 +32,6 @@ add_library(
2632
polyhedral/scop.cc
2733
polyhedral/separation.cc
2834
polyhedral/unroll.cc
29-
30-
# Builds and runs without the CUDA SDK and used in cross-compilation tests
31-
cuda/cuda_mapping_options.cc
32-
cuda/cuda_mapping_options_cpp_printer.cc
33-
polyhedral/cuda/codegen.cc
34-
polyhedral/cuda/mapped_scop.cc
35-
polyhedral/cuda/mapping_types.cc
36-
polyhedral/cuda/memory_promotion_heuristic.cc
37-
polyhedral/cuda/tighten_launch_bounds.cc
3835
)
3936
target_include_directories(tc_core PUBLIC ${PROJECT_SOURCE_DIR}/include ${LLVM_INCLUDE_DIRS})
4037
target_link_libraries(
@@ -55,6 +52,11 @@ install(
5552
DESTINATION lib
5653
)
5754

55+
################################################################################
56+
# tc_core_cpu
57+
#
58+
# Core CPU library for compiling to LLVMIR and running on CPUs
59+
################################################################################
5860
add_library(
5961
tc_core_cpu
6062

@@ -76,6 +78,7 @@ target_link_libraries(
7678
tc_lang
7779
tc_version
7880
tc_proto
81+
tc_core
7982
)
8083
install(
8184
TARGETS
@@ -84,24 +87,79 @@ install(
8487
DESTINATION lib
8588
)
8689

90+
set(TC_CUDA_CROSS_COMPILE_FILES
91+
cuda/cuda_mapping_options.cc
92+
cuda/cuda_mapping_options_cpp_printer.cc
93+
polyhedral/cuda/codegen.cc
94+
polyhedral/cuda/mapped_scop.cc
95+
polyhedral/cuda/mapping_types.cc
96+
polyhedral/cuda/memory_promotion_heuristic.cc
97+
polyhedral/cuda/tighten_launch_bounds.cc
98+
)
99+
100+
################################################################################
101+
# tc_core_cuda_no_sdk
102+
#
103+
# Core CUDA cross-compilation library for compiling to CUDA and not running
104+
# Builds **without** the CUDA SDK and used in cross-compilation tests
105+
################################################################################
106+
add_library(
107+
tc_core_cuda_no_sdk
108+
109+
SHARED
110+
111+
${TC_CUDA_CROSS_COMPILE_FILES}
112+
)
113+
# Unsets CUDA_HOME to compile without SDK
114+
set_target_properties(tc_core_cuda_no_sdk
115+
PROPERTIES COMPILE_FLAGS
116+
"${CMAKE_CXX_FLAGS} -UCUDA_HOME -Wl,--no-undefined")
117+
target_include_directories(tc_core_cuda_no_sdk PUBLIC ${PROJECT_SOURCE_DIR}/include ${LLVM_INCLUDE_DIRS})
118+
target_link_libraries(
119+
tc_core_cuda_no_sdk
120+
121+
${HALIDE_LIBRARIES}
122+
${ISL_LIBRARIES}
123+
-lLLVM
124+
125+
tc_lang
126+
tc_version
127+
tc_proto
128+
tc_core
129+
)
130+
install(
131+
TARGETS
132+
tc_core_cuda_no_sdk
133+
134+
DESTINATION lib
135+
)
136+
137+
################################################################################
138+
# tc_cuda
139+
#
140+
# Core CUDA library for compiling to PTX and running on actual GPUs
141+
################################################################################
87142
if (WITH_CUDA)
88143
find_library(CUDA_NVRTC_LIBRARIES nvrtc
89144
PATHS ${CUDA_TOOLKIT_ROOT_DIR}
90145
PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs)
91146

92147
add_library(
93-
tc_core_cuda
148+
tc_cuda
94149

95150
SHARED
96151

152+
${TC_CUDA_CROSS_COMPILE_FILES}
153+
154+
# Files needed for execution
97155
cuda/cuda.cc
98156
cuda/cuda_compilation_cache.cc
99157
cuda/cuda_rtc.cc
100158
cuda/cuda_tc_executor.cc
101159
)
102-
target_include_directories(tc_core_cuda PUBLIC ${PROJECT_SOURCE_DIR}/include ${LLVM_INCLUDE_DIRS})
160+
target_include_directories(tc_cuda PUBLIC ${PROJECT_SOURCE_DIR}/include ${LLVM_INCLUDE_DIRS})
103161
target_link_libraries(
104-
tc_core_cuda
162+
tc_cuda
105163

106164
${CUDA_CUDA_LIBRARIES}
107165
${CUDA_curand_LIBRARY}
@@ -112,11 +170,11 @@ if (WITH_CUDA)
112170
tc_lang
113171
tc_version
114172
tc_proto
173+
tc_core
115174
)
116-
target_link_libraries(tc_core tc_core_cuda)
117175
install(
118176
TARGETS
119-
tc_core_cuda
177+
tc_cuda
120178

121179
DESTINATION lib
122180
)

tensor_comprehensions/pybinds/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ target_link_libraries(
1414
tc
1515

1616
tc_autotuner
17-
tc_core
1817

1918
${PYTHON_LIBRARIES}
2019
${GFLAGS_LIBRARIES}
@@ -24,7 +23,7 @@ add_library(mapping_options MODULE pybind_options.cc)
2423
target_link_libraries(
2524
mapping_options
2625

27-
tc_core
26+
tc_core_cuda_no_sdk
2827

2928
${PYTHON_LIBRARIES}
3029
${GFLAGS_LIBRARIES}
@@ -47,7 +46,6 @@ if (WITH_CUDA)
4746
target_link_libraries(
4847
autotuner
4948

50-
tc_core
5149
tc_autotuner
5250

5351
${PYTHON_LIBRARIES}

test/CMakeLists.txt

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ target_link_libraries(tc_test INTERFACE ${GOOGLE_LIBS})
2323
################################################################################
2424
# Basic tests of external functionalities we rely upon
2525
################################################################################
26-
if (WITH_CUDA)
27-
add_executable(test_basic test_basic.cc)
28-
add_test(test_basic test_basic)
29-
target_link_libraries(test_basic ${GOOGLE_LIBS} ${ISL_LIBRARIES} ${ATEN_LIBRARIES})
26+
add_executable(test_basic test_basic.cc)
27+
add_test(test_basic test_basic)
28+
target_link_libraries(test_basic ${GOOGLE_LIBS} ${ISL_LIBRARIES} ${ATEN_LIBRARIES})
3029

30+
if (WITH_CUDA)
3131
add_executable(test_basic_gpu test_basic_gpu.cc)
32+
set_target_properties(test_basic_gpu PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_CUDA_SDK}" )
3233
add_test(test_basic_gpu test_basic_gpu)
3334
target_link_libraries(test_basic_gpu ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARIES} ${CUDA_NVRTC_LIBRARIES} ${GOOGLE_LIBS} )
3435
endif()
@@ -55,7 +56,7 @@ endforeach()
5556
if (WITH_CUDA)
5657
add_executable(test_autotuner_utility test_autotuner_utility.cc)
5758
add_test(test_autotuner_utility test_autotuner_utility)
58-
target_link_libraries(test_autotuner_utility ${GOOGLE_LIBS} ${ATEN_LIBRARIES} tc_autotuner tc_core)
59+
target_link_libraries(test_autotuner_utility ${GOOGLE_LIBS} ${ATEN_LIBRARIES} tc_cuda tc_autotuner)
5960
endif()
6061

6162

@@ -80,7 +81,7 @@ if (WITH_CUDA)
8081
${i}
8182

8283
${GOOGLE_LIBS}
83-
${ATEN_LIBRARIES}
84+
${ATEN_LIBRARIES}
8485
tc_autotuner)
8586
endforeach()
8687
endif()
@@ -91,17 +92,25 @@ endif()
9192
set(CORE_TEST_FILES
9293
test_mapper_memory_promotion
9394
test_mapper
94-
test_mapper_llvm
9595
)
9696

9797
foreach(i ${CORE_TEST_FILES})
9898
add_executable(${i} ${i}.cc)
9999
add_test(${i} ${i})
100-
target_link_libraries(${i} ${GOOGLE_LIBS} tc_core tc_core_cpu tc_lang)
101-
# target_compile_options(${i} PUBLIC -fsanitize=address)
102-
# set(CMAKE_EXE_LINKER_FLAGS -fsanitize=address)
100+
target_link_libraries(${i} ${GOOGLE_LIBS} tc_core_cuda_no_sdk)
103101
endforeach()
104-
target_link_libraries(test_mapper_llvm ${ATEN_LIBRARIES} -lLLVM)
102+
103+
104+
add_executable(test_mapper_llvm test_mapper_llvm.cc)
105+
add_test(test_mapper_llvm test_mapper_llvm)
106+
target_link_libraries(
107+
test_mapper_llvm
108+
109+
${GOOGLE_LIBS}
110+
${ATEN_LIBRARIES}
111+
-lLLVM
112+
113+
tc_core_cpu tc_lang)
105114

106115
################################################################################
107116
# TensorComprehensions tests

test/test_mapper_llvm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
#include "tc/aten/utils.h"
2424
#include "tc/core/cpu/cpu_tc_executor.h"
25-
#include "tc/core/cuda/cuda_mapping_options.h"
2625
#include "tc/core/execution_engine.h"
26+
#include "tc/core/mapping_options.h"
2727
#include "tc/core/polyhedral/codegen_llvm.h"
2828
#include "tc/core/polyhedral/llvm_jit.h"
2929
#include "tc/core/polyhedral/scop.h"

0 commit comments

Comments
 (0)