Skip to content

Commit 7dd025a

Browse files
authored
[CINN] Fix bug of complie with cinn in gcc12+cuda12.8 (#72353)
* fix bug of complie with cinn in cuda12.8 * fix bug * fix bug * fix complie * fix op register bug
1 parent 4dcf2dc commit 7dd025a

File tree

16 files changed

+68
-241
lines changed

16 files changed

+68
-241
lines changed

cmake/cinn.cmake

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -139,30 +139,13 @@ set(LINK_FLAGS
139139
set(global_test_args
140140
"--cinn_x86_builtin_code_root=${CMAKE_SOURCE_DIR}/paddle/cinn/backends")
141141

142-
set(Python_VIRTUALENV FIRST)
143-
144-
if(NOT PYTHON_EXECUTABLE)
145-
find_package(PythonInterp ${PY_VERSION} REQUIRED)
146-
endif()
147-
148-
if(NOT PYTHON_LIBRARIES)
149-
find_package(PythonLibs ${PY_VERSION} REQUIRED)
150-
endif()
151-
152-
message(STATUS "PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}")
153-
message(STATUS "PYTHON_INCLUDE_DIR: ${PYTHON_INCLUDE_DIR}")
154-
155-
include_directories(${PYTHON_INCLUDE_DIR})
156-
157142
set(core_deps CACHE INTERNAL "" FORCE)
158143
set(hlir_src CACHE INTERNAL "" FORCE)
159144

160145
# TODO(chenweihang): The logic later depends adding cinn subdirectory here,
161146
# but better to move to paddle/CMakeLists.txt
162147
add_subdirectory(paddle/cinn)
163148

164-
set(core_src "${cinnapi_src}")
165-
166149
cinn_cc_library(
167150
cinnapi
168151
SHARED
@@ -186,7 +169,6 @@ add_dependencies(cinnapi GEN_LLVM_RUNTIME_IR_HEADER ${core_deps})
186169
target_link_libraries(cinnapi op_dialect pir phi)
187170
add_dependencies(cinnapi op_dialect pir phi)
188171

189-
add_dependencies(cinnapi python)
190172
if(WITH_MKL)
191173
target_link_libraries(cinnapi cinn_mklml)
192174
add_dependencies(cinnapi cinn_mklml)
@@ -216,6 +198,8 @@ if(WITH_CUTLASS)
216198
add_dependencies(cinnapi cutlass)
217199
endif()
218200

201+
set(core_src "${cinnapi_src}")
202+
219203
function(gen_cinncore LINKTYPE)
220204
set(CINNCORE_TARGET cinncore)
221205
if(${LINKTYPE} STREQUAL "STATIC")
@@ -235,7 +219,6 @@ function(gen_cinncore LINKTYPE)
235219
absl
236220
isl
237221
ginac
238-
pybind
239222
op_fusion
240223
cinn_op_dialect
241224
${jitify_deps})
@@ -244,9 +227,6 @@ function(gen_cinncore LINKTYPE)
244227
target_link_libraries(${CINNCORE_TARGET} op_dialect pir phi)
245228
add_dependencies(${CINNCORE_TARGET} op_dialect pir phi)
246229

247-
# add_dependencies(${CINNCORE_TARGET} pybind)
248-
target_link_libraries(${CINNCORE_TARGET} ${PYTHON_LIBRARIES})
249-
250230
if(WITH_MKL)
251231
target_link_libraries(${CINNCORE_TARGET} cinn_mklml)
252232
add_dependencies(${CINNCORE_TARGET} cinn_mklml)

cmake/cinn/core.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ function(cinn_cc_library TARGET_NAME)
1919
endif()
2020

2121
if(cinn_cc_library_DEPS)
22-
if("${cinn_cc_library_DEPS};" MATCHES "python;")
23-
list(REMOVE_ITEM cinn_cc_library_DEPS python)
24-
add_dependencies(${TARGET_NAME} python)
25-
endif()
2622
target_link_libraries(${TARGET_NAME} ${cinn_cc_library_DEPS})
2723
add_dependencies(${TARGET_NAME} ${cinn_cc_library_DEPS})
2824
endif()

paddle/cinn/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ add_subdirectory(backends)
1414
add_subdirectory(lang)
1515
add_subdirectory(optim)
1616
add_subdirectory(hlir)
17-
add_subdirectory(pybind)
17+
# add_subdirectory(pybind)
1818
add_subdirectory(operator_fusion)
1919

2020
# Download a model

paddle/cinn/common/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ gather_srcs(
1818
test_helper.cc
1919
# cuda_test_helper.cc
2020
union_find.cc
21-
python_interpreter_guard.cc
2221
nvgpu_dev_info.cc
2322
integer_set.cc
2423
dim_expr_converter.cc

paddle/cinn/common/python_interpreter_guard.cc

Lines changed: 0 additions & 36 deletions
This file was deleted.

paddle/cinn/common/python_interpreter_guard.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

paddle/cinn/hlir/framework/pir/compilation_task.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "paddle/cinn/hlir/framework/op_lowering.h"
2323
#include "paddle/cinn/hlir/framework/pir/op_lowering_group.h"
2424
#include "paddle/cinn/hlir/framework/pir/utils.h"
25+
#include "paddle/cinn/hlir/op/use_ops.h"
2526
#include "paddle/cinn/ir/utils/stmt_converter.h"
2627
#include "paddle/common/enforce.h"
2728
namespace cinn {

paddle/cinn/pybind/CMakeLists.txt

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
set(srcs
2-
runtime.cc
3-
common.cc
4-
lang.cc
5-
ir/ir.cc
6-
ir/ir_api.cc
7-
ir/ir_context.cc
8-
poly.cc
9-
backends.cc
10-
bind.cc
11-
optim.cc
12-
pe.cc
13-
framework.cc
14-
utils.cc
15-
schedule.cc)
1+
# set(srcs
2+
# runtime.cc
3+
# common.cc
4+
# lang.cc
5+
# ir/ir.cc
6+
# ir/ir_api.cc
7+
# ir/ir_context.cc
8+
# poly.cc
9+
# backends.cc
10+
# bind.cc
11+
# optim.cc
12+
# pe.cc
13+
# framework.cc
14+
# utils.cc
15+
# schedule.cc)
1616

17-
gather_srcs(cinnapi_src SRCS ${srcs})
17+
# gather_srcs(cinnapi_src SRCS ${srcs})
1818

19-
if(WITH_CUDA)
20-
message(STATUS "Compile core_api with CUDA support")
21-
cinn_nv_library(
22-
core_api
23-
SHARED
24-
SRCS
25-
${srcs}
26-
DEPS
27-
cinncore_static
28-
cinn_runtime
29-
pybind
30-
common)
31-
message("cuda_nvrtc: ${CUDA_NVRTC}")
32-
target_link_libraries(core_api ${CUDA_NVRTC_LIB} ${CUDA_LIBRARIES} cuda cudnn)
33-
if(NVTX_FOUND)
34-
target_link_libraries(core_api ${CUDA_NVTX_LIB})
35-
endif()
36-
else()
37-
message(STATUS "Compile core_api without CUDA support")
38-
cinn_cc_library(
39-
core_api
40-
SHARED
41-
SRCS
42-
${srcs}
43-
DEPS
44-
cinncore_static
45-
cinn_runtime
46-
pybind
47-
${llvm_libs})
48-
endif()
19+
# if(WITH_CUDA)
20+
# message(STATUS "Compile core_api with CUDA support")
21+
# cinn_nv_library(
22+
# core_api
23+
# SHARED
24+
# SRCS
25+
# ${srcs}
26+
# DEPS
27+
# cinncore_static
28+
# cinn_runtime
29+
# pybind
30+
# common)
31+
# message("cuda_nvrtc: ${CUDA_NVRTC}")
32+
# target_link_libraries(core_api ${CUDA_NVRTC_LIB} ${CUDA_LIBRARIES} cuda cudnn)
33+
# if(NVTX_FOUND)
34+
# target_link_libraries(core_api ${CUDA_NVTX_LIB})
35+
# endif()
36+
# else()
37+
# message(STATUS "Compile core_api without CUDA support")
38+
# cinn_cc_library(
39+
# core_api
40+
# SHARED
41+
# SRCS
42+
# ${srcs}
43+
# DEPS
44+
# cinncore_static
45+
# cinn_runtime
46+
# pybind
47+
# ${llvm_libs})
48+
# endif()
4949

50-
target_link_libraries(core_api ${MKLML_LIB} isl ginac common)
51-
if(USE_OPENMP STREQUAL "gnu")
52-
target_link_libraries(core_api ${OpenMP_CXX_LIBRARIES})
53-
message(STATUS "OpenMP lib: ${OpenMP_CXX_LIBRARIES}")
54-
elseif(USE_OPENMP STREQUAL "intel")
55-
target_link_libraries(core_api ${MKLML_IOMP_LIB})
56-
message(STATUS "OpenMP lib: ${MKLML_IOMP_LIB}")
57-
endif()
50+
# target_link_libraries(core_api ${MKLML_LIB} isl ginac common)
51+
# if(USE_OPENMP STREQUAL "gnu")
52+
# target_link_libraries(core_api ${OpenMP_CXX_LIBRARIES})
53+
# message(STATUS "OpenMP lib: ${OpenMP_CXX_LIBRARIES}")
54+
# elseif(USE_OPENMP STREQUAL "intel")
55+
# target_link_libraries(core_api ${MKLML_IOMP_LIB})
56+
# message(STATUS "OpenMP lib: ${MKLML_IOMP_LIB}")
57+
# endif()
5858

59-
set_target_properties(core_api PROPERTIES PREFIX "")
59+
# set_target_properties(core_api PROPERTIES PREFIX "")

paddle/cinn/pybind/runtime.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,6 @@ void BindCinnRuntime(py::module *m) {
368368
.def("cinn_pod_value_to_void_p", &cinn_pod_value_to_void_p)
369369
.def("cinn_pod_value_to_buffer_p", &cinn_pod_value_to_buffer_p);
370370

371-
m->def("set_cinn_cudnn_deterministic",
372-
&cinn::runtime::SetCinnCudnnDeterministic,
373-
py::arg("state") = true);
374371
m->def("seed", &cinn::runtime::RandomSeed::GetOrSet, py::arg("seed") = 0);
375372
m->def("clear_seed", &cinn::runtime::RandomSeed::Clear);
376373
}

paddle/cinn/runtime/cuda/cuda_util.cc

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -898,10 +898,6 @@ void cinn_call_cudnn_conv2d_forward(void *v_args,
898898
conv_algo_map.InsertAlgo(hash_key, static_cast<int>(algo_perf.algo));
899899
}
900900

901-
if (GetCinnCudnnDeterministic()) {
902-
algo = static_cast<cudnnConvolutionFwdAlgo_t>(1);
903-
}
904-
905901
size_t workspace_size = 0;
906902
CUDNN_CALL(cudnnGetConvolutionForwardWorkspaceSize(
907903
handle, x_desc, w_desc, conv_desc, y_desc, algo, &workspace_size));
@@ -1055,10 +1051,6 @@ void cinn_call_cudnn_conv2d_backward_data(void *v_args,
10551051
conv_algo_map.InsertAlgo(hash_key, static_cast<int>(algo_perf.algo));
10561052
}
10571053

1058-
if (GetCinnCudnnDeterministic()) {
1059-
algo = CUDNN_CONVOLUTION_BWD_DATA_ALGO_1;
1060-
}
1061-
10621054
size_t workspace_size = 0;
10631055
CUDNN_CALL(cudnnGetConvolutionBackwardDataWorkspaceSize(
10641056
handle, w_desc, y_desc, conv_desc, x_desc, algo, &workspace_size));
@@ -1213,10 +1205,6 @@ void cinn_call_cudnn_conv2d_backward_filter(void *v_args,
12131205
algo_map.InsertAlgo(hash_key, static_cast<int>(algo_perf.algo));
12141206
}
12151207

1216-
if (GetCinnCudnnDeterministic()) {
1217-
algo = CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1;
1218-
}
1219-
12201208
size_t workspace_size = 0;
12211209
CUDNN_CALL(cudnnGetConvolutionBackwardFilterWorkspaceSize(
12221210
handle, x_desc, y_desc, conv_desc, w_desc, algo, &workspace_size));
@@ -1298,10 +1286,6 @@ void cinn_call_cudnn_pool2d_forward(void *v_args,
12981286
cudnnTensorFormat_t tensor_format = static_cast<cudnnTensorFormat_t>(format);
12991287
cudnnDataType_t data_type = convert_to_cudnn_dtype(v_args, num_args);
13001288

1301-
if (GetCinnCudnnDeterministic() && pool_mode == CUDNN_POOLING_MAX) {
1302-
pool_mode = CUDNN_POOLING_MAX_DETERMINISTIC;
1303-
}
1304-
13051289
std::string hash_key =
13061290
"pool2d forward, layout=" + debug_cudnn_tensor_format(tensor_format) +
13071291
", pool_type=" + debug_cudnn_pool_mode(pool_mode) +
@@ -1398,10 +1382,6 @@ void cinn_call_cudnn_pool2d_backward(void *v_args,
13981382
cudnnTensorFormat_t tensor_format = static_cast<cudnnTensorFormat_t>(format);
13991383
cudnnDataType_t data_type = convert_to_cudnn_dtype(v_args, num_args);
14001384

1401-
if (GetCinnCudnnDeterministic() && pool_mode == CUDNN_POOLING_MAX) {
1402-
pool_mode = CUDNN_POOLING_MAX_DETERMINISTIC;
1403-
}
1404-
14051385
std::string hash_key =
14061386
"pool2d backward, layout=" + debug_cudnn_tensor_format(tensor_format) +
14071387
", pool_type=" + debug_cudnn_pool_mode(pool_mode) +
@@ -2456,10 +2436,6 @@ void cinn_gpu_cudnn_conv2d(const absl::flat_hash_map<std::string, int> &attr,
24562436
conv_algo_map.InsertAlgo(hash_key, static_cast<int>(algo_perf.algo));
24572437
}
24582438

2459-
if (GetCinnCudnnDeterministic()) {
2460-
algo = static_cast<cudnnConvolutionFwdAlgo_t>(1);
2461-
}
2462-
24632439
size_t ws_size = 0;
24642440
CUDNN_CALL(cudnnGetConvolutionForwardWorkspaceSize(
24652441
handle, x_desc, w_desc, conv_desc, y_desc, algo, &ws_size));
@@ -2610,10 +2586,6 @@ void cinn_gpu_cudnn_conv2d_backward_data(
26102586
conv_algo_map.InsertAlgo(hash_key, static_cast<int>(algo_perf.algo));
26112587
}
26122588

2613-
if (GetCinnCudnnDeterministic()) {
2614-
algo = CUDNN_CONVOLUTION_BWD_DATA_ALGO_1;
2615-
}
2616-
26172589
size_t ws_size = 0;
26182590
CUDNN_CALL(cudnnGetConvolutionBackwardDataWorkspaceSize(
26192591
handle, w_desc, y_desc, conv_desc, x_desc, algo, &ws_size));
@@ -2764,10 +2736,6 @@ void cinn_gpu_cudnn_conv2d_backward_filter(
27642736
algo_map.InsertAlgo(hash_key, static_cast<int>(algo_perf.algo));
27652737
}
27662738

2767-
if (GetCinnCudnnDeterministic()) {
2768-
algo = CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1;
2769-
}
2770-
27712739
size_t ws_size = 0;
27722740
CUDNN_CALL(cudnnGetConvolutionBackwardFilterWorkspaceSize(
27732741
handle, x_desc, y_desc, conv_desc, w_desc, algo, &ws_size));

0 commit comments

Comments
 (0)