diff options
author | Michael Kruse <llvm-project@meinersbur.de> | 2021-04-21 00:40:47 -0500 |
---|---|---|
committer | Michael Kruse <llvm-project@meinersbur.de> | 2021-04-21 01:08:01 -0500 |
commit | 6048d1d19c55a107f67cd617d6ed386831b5adee (patch) | |
tree | 6050c5aae337312bff040fb726c642be3ffbdfd8 /polly | |
parent | 90e5ce0b0d6b0e72fdc034cbb612f67d67de0fdd (diff) | |
download | llvm-6048d1d19c55a107f67cd617d6ed386831b5adee.zip llvm-6048d1d19c55a107f67cd617d6ed386831b5adee.tar.gz llvm-6048d1d19c55a107f67cd617d6ed386831b5adee.tar.bz2 |
[PollyACC] Configure PollyPPCG only if needed.
The PollyPPCG library is only needed when POLLY_ENABLE_GPGPU_CODEGEN=ON.
If disabled, the library target is still created, but not linked against
anything.
This change does not add create the PollyPPCG build target if not
needed.
Motivated by llvm.org/PR50021
Diffstat (limited to 'polly')
-rw-r--r-- | polly/lib/External/CMakeLists.txt | 176 |
1 files changed, 100 insertions, 76 deletions
diff --git a/polly/lib/External/CMakeLists.txt b/polly/lib/External/CMakeLists.txt index 8991094..e3a5683 100644 --- a/polly/lib/External/CMakeLists.txt +++ b/polly/lib/External/CMakeLists.txt @@ -1,3 +1,18 @@ +# Disable warnings for upstream projects. +if (MSVC) + set(DISABLE_WARNING_FLAGS + -wd4018 # 'expression' : signed/unsigned mismatch + -wd4090 # 'operation' : different 'modifier' qualifiers + -wd4200 # nonstandard extension used: zero-sized array in struct/union + -wd4201 # nonstandard extension used: nameless struct/union + -wd4334 # 'operator': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) + -wd4221 # nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable + ) +else () + set(DISABLE_WARNING_FLAGS "-w") +endif () + + # External: Integer Set Library if (POLLY_BUNDLED_ISL) set(ISL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/isl") @@ -293,86 +308,95 @@ if (POLLY_BUNDLED_ISL) # ISL requires at least C99 to compile. gcc < 5.0 use -std=gnu89 as default. set_property(TARGET PollyISL polly-isl-test PROPERTY C_STANDARD 99) + + target_compile_options(PollyISL PRIVATE ${DISABLE_WARNING_FLAGS}) + target_compile_options(polly-isl-test PRIVATE ${DISABLE_WARNING_FLAGS}) endif (POLLY_BUNDLED_ISL) -set(PET_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pet") -set(PPCG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ppcg") -set(PPCG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppcg") - -# Determine version of ppcg -if (EXISTS "${PPCG_SOURCE_DIR}/GIT_HEAD_ID") - # The source comes from a 'make dist' archive - file(READ "${PPCG_SOURCE_DIR}/GIT_HEAD_ID" PPCG_GIT_HEAD_ID) - string(STRIP "${PPCG_GIT_HEAD_ID}" PPCG_GIT_HEAD_ID) -elseif (EXISTS "${PPCG_SOURCE_DIR}/gitversion.h") - # The source directory is preconfigured - file(READ "${PPCG_SOURCE_DIR}/gitversion.h" GITVERSION_H) - string(REGEX REPLACE ".*\\\"([^\\\"]*)\\\".*" "\\1" PPCG_GIT_HEAD_ID "${GITVERSION_H}") -elseif () - # Unknown revision - # TODO: We could look for a .git and get the revision from HEAD - set(PPCG_GIT_HEAD_ID "UNKNOWN") -endif () -message(STATUS "PPCG version: ${PPCG_GIT_HEAD_ID}") - -set (PPCG_FILES - ppcg/cuda.c - ppcg/cuda_common.c - ppcg/external.c - ppcg/gpu_array_tile.c - ppcg/gpu.c - ppcg/gpu_array_tile.c - ppcg/gpu_group.c - ppcg/gpu_hybrid.c - ppcg/gpu_print.c - ppcg/gpu_tree.c - ppcg/grouping.c - ppcg/hybrid.c - ppcg/ppcg.c - ppcg/ppcg_options.c - ppcg/print.c - ppcg/schedule.c - ppcg/util.c - ) - -include_directories(BEFORE - ${PPCG_BINARY_DIR} - ${PPCG_SOURCE_DIR}/imath - ${PPCG_SOURCE_DIR}/include - ${PET_SOURCE_DIR}/include -) - -add_polly_library(PollyPPCG - ${PPCG_FILES} -) - -target_link_libraries(PollyPPCG PUBLIC ${ISL_TARGET}) +# External: Polyhedral Parallel Code Generator +if (GPU_CODEGEN) + set(PET_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pet") + set(PPCG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ppcg") + set(PPCG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppcg") -# Disable warnings for upstream projects. -if (MSVC) - set(DISABLE_WARNING_FLAGS - -wd4018 # 'expression' : signed/unsigned mismatch - -wd4090 # 'operation' : different 'modifier' qualifiers - -wd4200 # nonstandard extension used: zero-sized array in struct/union - -wd4201 # nonstandard extension used: nameless struct/union - -wd4334 # 'operator': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) - -wd4221 # nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable + # Determine version of ppcg + if (EXISTS "${PPCG_SOURCE_DIR}/GIT_HEAD_ID") + # The source comes from a 'make dist' archive + file(READ "${PPCG_SOURCE_DIR}/GIT_HEAD_ID" PPCG_GIT_HEAD_ID) + string(STRIP "${PPCG_GIT_HEAD_ID}" PPCG_GIT_HEAD_ID) + elseif (EXISTS "${PPCG_SOURCE_DIR}/gitversion.h") + # The source directory is preconfigured + file(READ "${PPCG_SOURCE_DIR}/gitversion.h" GITVERSION_H) + string(REGEX REPLACE ".*\\\"([^\\\"]*)\\\".*" "\\1" PPCG_GIT_HEAD_ID "${GITVERSION_H}") + elseif () + # Unknown revision + # TODO: We could look for a .git and get the revision from HEAD + set(PPCG_GIT_HEAD_ID "UNKNOWN") + endif () + + message(STATUS "PPCG version: ${PPCG_GIT_HEAD_ID}") + + set (PPCG_FILES + ppcg/cuda.c + ppcg/cuda_common.c + ppcg/external.c + ppcg/gpu_array_tile.c + ppcg/gpu.c + ppcg/gpu_array_tile.c + ppcg/gpu_group.c + ppcg/gpu_hybrid.c + ppcg/gpu_print.c + ppcg/gpu_tree.c + ppcg/grouping.c + ppcg/hybrid.c + ppcg/ppcg.c + ppcg/ppcg_options.c + ppcg/print.c + ppcg/schedule.c + ppcg/util.c + ) + + include_directories(BEFORE + ${PPCG_BINARY_DIR} + ${PPCG_SOURCE_DIR}/imath + ${PPCG_SOURCE_DIR}/include + ${PET_SOURCE_DIR}/include + ) + + add_polly_library(PollyPPCG + ${PPCG_FILES} ) - if (POLLY_BUNDLED_ISL) - target_compile_options(PollyISL PRIVATE ${DISABLE_WARNING_FLAGS}) - target_compile_options(polly-isl-test PRIVATE ${DISABLE_WARNING_FLAGS}) - endif (POLLY_BUNDLED_ISL) - target_compile_options(PollyPPCG PRIVATE ${DISABLE_WARNING_FLAGS}) -else () - if (POLLY_BUNDLED_ISL) - set_target_properties(PollyISL polly-isl-test PROPERTIES COMPILE_FLAGS "-w") - endif (POLLY_BUNDLED_ISL) - set_target_properties(PollyPPCG PROPERTIES COMPILE_FLAGS "-w") -endif () -if(MSVC) - # In the Windows API (with some exceptions), the maximum length for a path is - # MAX_PATH, which is defined as 260 characters. - target_compile_definitions(PollyPPCG PRIVATE "-DPATH_MAX=260") + target_link_libraries(PollyPPCG PUBLIC ${ISL_TARGET}) + + # Disable warnings for upstream projects. + if (MSVC) + set(DISABLE_WARNING_FLAGS + -wd4018 # 'expression' : signed/unsigned mismatch + -wd4090 # 'operation' : different 'modifier' qualifiers + -wd4200 # nonstandard extension used: zero-sized array in struct/union + -wd4201 # nonstandard extension used: nameless struct/union + -wd4334 # 'operator': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) + -wd4221 # nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable + ) + if (POLLY_BUNDLED_ISL) + target_compile_options(PollyISL PRIVATE ${DISABLE_WARNING_FLAGS}) + target_compile_options(polly-isl-test PRIVATE ${DISABLE_WARNING_FLAGS}) + endif (POLLY_BUNDLED_ISL) + target_compile_options(PollyPPCG PRIVATE ${DISABLE_WARNING_FLAGS}) + else () + if (POLLY_BUNDLED_ISL) + set_target_properties(PollyISL polly-isl-test PROPERTIES COMPILE_FLAGS "-w") + endif (POLLY_BUNDLED_ISL) + set_target_properties(PollyPPCG PROPERTIES COMPILE_FLAGS "-w") + endif () + + if(MSVC) + # In the Windows API (with some exceptions), the maximum length for a path is + # MAX_PATH, which is defined as 260 characters. + target_compile_definitions(PollyPPCG PRIVATE "-DPATH_MAX=260") + endif () + + target_compile_options(PollyPPCG PRIVATE ${DISABLE_WARNING_FLAGS}) endif () |