Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeStyle][CINN] fix cinn codestyle cmake-lint #54975

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions cmake/cinn/core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function(cinn_cc_library TARGET_NAME)
${CMAKE_CURRENT_SOURCE_DIR}/${source}.h)
endif()
endforeach()
else(cinn_cc_library_SRCS)
else()
if(cinn_cc_library_DEPS)
cinn_merge_static_libs(${TARGET_NAME} ${cinn_cc_library_DEPS})
else()
Expand All @@ -41,7 +41,7 @@ function(cinn_cc_library TARGET_NAME)
"Please specify source files or libraries in cinn_cc_library(${TARGET_NAME} ...)."
)
endif()
endif(cinn_cc_library_SRCS)
endif()

if((NOT ("${TARGET_NAME}" STREQUAL "cinn_gtest_main"))
AND (NOT ("${TARGET_NAME}" STREQUAL "utils"))
Expand All @@ -52,7 +52,7 @@ function(cinn_cc_library TARGET_NAME)
(NOT ("${TARGET_NAME}" STREQUAL "cinn_gtest_main"))
AND (NOT ("${TARGET_NAME}" STREQUAL "utils"))
AND (NOT ("${TARGET_NAME}" STREQUAL "lib")))
endfunction(cinn_cc_library)
endfunction()

list(APPEND CMAKE_CTEST_ARGUMENTS)

Expand Down Expand Up @@ -116,17 +116,17 @@ function(cinn_nv_library TARGET_NAME)
${CMAKE_CURRENT_SOURCE_DIR}/${source}.h)
endif()
endforeach()
else(cinn_nv_library_SRCS)
else()
if(cinn_nv_library_DEPS)
cinn_merge_static_libs(${TARGET_NAME} ${cinn_nv_library_DEPS})
else()
message(FATAL
"Please specify source file or library in cinn_nv_library.")
endif()
endif(cinn_nv_library_SRCS)
endif()
target_link_libraries(${TARGET_NAME} Threads::Threads)
endif()
endfunction(cinn_nv_library)
endfunction()

function(cinn_nv_binary TARGET_NAME)
if(WITH_GPU)
Expand All @@ -142,16 +142,19 @@ function(cinn_nv_binary TARGET_NAME)
common_link(${TARGET_NAME})
endif()
endif()
endfunction(cinn_nv_binary)
endfunction()

function(cinn_nv_test TARGET_NAME)
if(WITH_GPU AND WITH_TESTING AND CINN_ONLY)
if(WITH_GPU
AND WITH_TESTING
AND CINN_ONLY)
set(options SERIAL)
set(oneValueArgs "")
set(multiValueArgs SRCS DEPS ARGS)
cmake_parse_arguments(cinn_nv_test "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})
cuda_add_executable(${TARGET_NAME} ${cinn_nv_test_SRCS} OPTIONS "-std=c++${CMAKE_CUDA_STANDARD}")
cuda_add_executable(${TARGET_NAME} ${cinn_nv_test_SRCS} OPTIONS
"-std=c++${CMAKE_CUDA_STANDARD}")
get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES)
target_link_libraries(
${TARGET_NAME}
Expand Down Expand Up @@ -181,7 +184,7 @@ function(cinn_nv_test TARGET_NAME)
endif()
remove_gflags(${TARGET_NAME})
endif()
endfunction(cinn_nv_test)
endfunction()

# Add dependency that TARGET will depend on test result of DEP, this function executes the DEP during make.
function(add_run_test_dependency TARGET_NAME DEP_NAME)
Expand All @@ -195,8 +198,8 @@ function(add_run_test_dependency TARGET_NAME DEP_NAME)
COMMAND cd ${CMAKE_BINARY_DIR}
DEPENDS ${DEP_NAME})
add_dependencies(${TARGET_NAME} ${DEP_NAME} ${custom_target_name})
endif(WITH_TESTING AND CINN_ONLY)
endfunction(add_run_test_dependency)
endif()
endfunction()

# find all third_party modules is used for paddle static library
# for reduce the dependency when building the inference libs.
Expand All @@ -211,7 +214,7 @@ function(find_fluid_thirdparties TARGET_NAME)
set(fluid_third_partys ${fluid_third_partys} ${TARGET_NAME})
set_property(GLOBAL PROPERTY FLUID_THIRD_PARTY "${fluid_third_partys}")
endif()
endfunction(find_fluid_thirdparties)
endfunction()

function(cinn_merge_static_libs TARGET_NAME)
set(libs ${ARGN})
Expand Down Expand Up @@ -255,7 +258,7 @@ function(cinn_merge_static_libs TARGET_NAME)
COMMAND rm "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET_NAME}.a"
COMMAND /usr/bin/libtool -static -o
"${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET_NAME}.a" ${libfiles})
endif(APPLE)
endif()
if(LINUX
)# general UNIX: use "ar" to extract objects and re-add to a common lib
set(target_DIR ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.dir)
Expand Down Expand Up @@ -303,7 +306,7 @@ function(cinn_merge_static_libs TARGET_NAME)
COMMAND ${CMAKE_AR} crs ${target_LIBNAME} `find ${target_DIR} -name '*.o'`
COMMAND ${CMAKE_RANLIB} ${target_LIBNAME}
WORKING_DIRECTORY ${target_DIR})
endif(LINUX)
endif()
if(WIN32)

# windows do not support gcc/nvcc combined compiling. Use msvc lib.exe to merge libs.
Expand Down Expand Up @@ -336,8 +339,8 @@ function(cinn_merge_static_libs TARGET_NAME)
lib
/OUT:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${TARGET_NAME}.lib
${libfiles})
endif(WIN32)
endfunction(cinn_merge_static_libs)
endif()
endfunction()

# Modification of standard 'protobuf_generate_cpp()' with protobuf-lite support
# Usage:
Expand Down
15 changes: 10 additions & 5 deletions paddle/cinn/auto_schedule/post_schedule_rule/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
core_gather_headers()

gather_srcs(cinnapi_src SRCS
cooperative_process.cc
)
gather_srcs(cinnapi_src SRCS cooperative_process.cc)

if (WITH_CUDA)
cinn_nv_test(test_cooperative_process SRCS cooperative_process_test.cc DEPS cinncore auto_gen_rule_test_helper test_program_builder)
if(WITH_CUDA)
cinn_nv_test(
test_cooperative_process
SRCS
cooperative_process_test.cc
DEPS
cinncore
auto_gen_rule_test_helper
test_program_builder)
endif()
57 changes: 43 additions & 14 deletions paddle/cinn/auto_schedule/search_space/auto_gen_rule/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,51 @@
core_gather_headers()

gather_srcs(cinnapi_src SRCS
auto_gen_rule.cc
auto_inline.cc
auto_unroll.cc
multi_level_tiling.cc
skip_rule.cc
auto_bind.cc
)
gather_srcs(
cinnapi_src
SRCS
auto_gen_rule.cc
auto_inline.cc
auto_unroll.cc
multi_level_tiling.cc
skip_rule.cc
auto_bind.cc)

if (WITH_TESTING)
cinn_cc_library(auto_gen_rule_test_helper SRCS test_helper.cc DEPS glog gtest cinncore)
if(WITH_TESTING)
cinn_cc_library(
auto_gen_rule_test_helper
SRCS
test_helper.cc
DEPS
glog
gtest
cinncore)
endif()

if (WITH_CUDA)
cinn_nv_test(test_mix_rules SRCS mix_rules_test.cc DEPS cinncore auto_gen_rule_test_helper test_program_builder)
cinn_nv_test(test_auto_bind SRCS auto_bind_test.cc DEPS cinncore auto_gen_rule_test_helper test_program_builder)
cinn_nv_test(test_multi_level_tiling SRCS multi_level_tiling_test.cc DEPS cinncore auto_gen_rule_test_helper test_program_builder)
if(WITH_CUDA)
cinn_nv_test(
test_mix_rules
SRCS
mix_rules_test.cc
DEPS
cinncore
auto_gen_rule_test_helper
test_program_builder)
cinn_nv_test(
test_auto_bind
SRCS
auto_bind_test.cc
DEPS
cinncore
auto_gen_rule_test_helper
test_program_builder)
cinn_nv_test(
test_multi_level_tiling
SRCS
multi_level_tiling_test.cc
DEPS
cinncore
auto_gen_rule_test_helper
test_program_builder)
endif()

#cinn_cc_test(test_auto_inline SRCS auto_inline_test.cc DEPS cinncore auto_gen_rule_test_helper)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
core_gather_headers()

gather_srcs(cinnapi_src SRCS
mutate_rule.cc
mutate_tile_size.cc
)
gather_srcs(cinnapi_src SRCS mutate_rule.cc mutate_tile_size.cc)

cinn_cc_test(test_mutate_tile_size SRCS mutate_tile_size_test.cc DEPS cinncore)