Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,9 @@
{
"repository.callsign" : "PLO",
"conduit_uri" : "https://reviews.llvm.org/",
"history.immutable" : true,
"load" : [
"utils/arcanist/LitTestEngine"
],
"unit.engine" : "LitTestEngine"
}

25
external/llvm-project/polly/.arclint vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"linters": {
"format": {
"include": "(include/polly/.+\\.h$|lib/.+\\.cpp$)",
"exclude": "(lib/External/JSON/.*)",
"type": "script-and-regex",
"script-and-regex.script": "sh -c './utils/check_format.sh \"$0\" 2> /dev/null || true'",
"script-and-regex.regex": "/^(OK:(?P<ignore>.+)|Error:) (?P<message>.+)$/m"
},
"chmod": {
"type": "chmod"
},
"filename": {
"exclude": "(www/experiments/.+|.*\\.jscop.*)",
"type": "filename"
},
"merge-conflict": {
"type": "merge-conflict"
},
"spelling": {
"exclude": "(configure|autoconf/.*)",
"type": "spelling"
}
}
}

View File

@@ -0,0 +1,4 @@
# Auto detect text files and perform LF normalization
* text eol=lf
*.png -text
*.pdf -text

View File

@@ -0,0 +1,3 @@
test/lit.site.cfg
lib/External/isl/doc/manual.pdf
00*

View File

@@ -0,0 +1,222 @@
# Check if this is a in tree build.
if (NOT DEFINED LLVM_MAIN_SRC_DIR)
project(Polly)
cmake_minimum_required(VERSION 3.4.3)
# Where is LLVM installed?
find_package(LLVM CONFIG REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
include(HandleLLVMOptions)
include(AddLLVM)
# Add the llvm header path.
include_directories(${LLVM_INCLUDE_DIRS})
# Sources available, too?
if (LLVM_BUILD_MAIN_SRC_DIR)
set(LLVM_SOURCE_ROOT ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH
"Path to LLVM source tree")
else()
execute_process(COMMAND "${LLVM_TOOLS_BINARY_DIR}/llvm-config" --src-root
OUTPUT_VARIABLE MAIN_SRC_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LLVM_SOURCE_ROOT ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
endif()
# Enable unit tests if available.
set(POLLY_GTEST_AVAIL 0)
set(UNITTEST_DIR ${LLVM_SOURCE_ROOT}/utils/unittest)
if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
# The build tree already exports the gtest target, which we can reuse
if (TARGET gtest)
# LLVM Doesn't export gtest's include directorys, so do that here
set_target_properties(gtest
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${UNITTEST_DIR}/googletest/include;${UNITTEST_DIR}/googlemock/include"
)
set(POLLY_GTEST_AVAIL 1)
else()
add_library(gtest
${UNITTEST_DIR}/googletest/src/gtest-all.cc
${UNITTEST_DIR}/googlemock/src/gmock-all.cc
)
target_include_directories(gtest
PUBLIC
"${UNITTEST_DIR}/googletest/include"
"${UNITTEST_DIR}/googlemock/include"
PRIVATE
"${UNITTEST_DIR}/googletest"
"${UNITTEST_DIR}/googlemock"
)
target_link_libraries(gtest -lpthread)
add_library(gtest_main ${UNITTEST_DIR}/UnitTestMain/TestMain.cpp)
target_link_libraries(gtest_main gtest)
set(POLLY_GTEST_AVAIL 1)
endif()
endif()
# Make sure the isl c files are built as fPIC
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
# Set directory for polly-isl-test.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
else ()
set(LLVM_SOURCE_ROOT "${LLVM_MAIN_SRC_DIR}")
set(POLLY_GTEST_AVAIL 1)
endif ()
set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(POLLY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
# Add path for custom modules
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
include("polly_macros")
# Add appropriate flags for GCC
if (CMAKE_COMPILER_IS_GNUCXX)
# FIXME: Turn off exceptions, RTTI:
# -fno-exceptions -fno-rtti
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -fno-exceptions -fno-rtti")
elseif (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-")
add_definitions("-D_HAS_EXCEPTIONS=0")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
endif ()
# Add path for custom modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${POLLY_SOURCE_DIR}/cmake")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
option(POLLY_ENABLE_GPGPU_CODEGEN "Enable GPGPU code generation feature" OFF)
if (POLLY_ENABLE_GPGPU_CODEGEN)
# Do not require CUDA/OpenCL, as GPU code generation test cases can be run
# without a CUDA/OpenCL library.
FIND_PACKAGE(CUDA)
FIND_PACKAGE(OpenCL)
set(GPU_CODEGEN TRUE)
else(POLLY_ENABLE_GPGPU_CODEGEN)
set(GPU_CODEGEN FALSE)
endif(POLLY_ENABLE_GPGPU_CODEGEN)
# Support GPGPU code generation if the library is available.
if (CUDA_FOUND)
add_definitions(-DHAS_LIBCUDART)
INCLUDE_DIRECTORIES( ${CUDA_INCLUDE_DIRS} )
endif(CUDA_FOUND)
if (OpenCL_FOUND)
add_definitions(-DHAS_LIBOPENCL)
INCLUDE_DIRECTORIES( ${OpenCL_INCLUDE_DIR} )
endif(OpenCL_FOUND)
option(POLLY_BUNDLED_ISL "Use the bundled version of libisl included in Polly" ON)
if (NOT POLLY_BUNDLED_ISL)
find_package(ISL MODULE REQUIRED)
message(STATUS "Using external libisl ${ISL_VERSION} in: ${ISL_PREFIX}")
set(ISL_TARGET ISL)
else()
set(ISL_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/lib/External/isl/include
${CMAKE_CURRENT_SOURCE_DIR}/lib/External/isl/include
)
set(ISL_TARGET PollyISL)
endif()
option(POLLY_BUNDLED_JSONCPP "Use the bundled version of jsoncpp included in Polly" ON)
if (POLLY_BUNDLED_JSONCPP)
set(JSONCPP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib/External/JSON/include")
set(JSONCPP_LIBRARIES)
set(POLLY_JSON_FILES
External/JSON/json_reader.cpp
External/JSON/json_value.cpp
External/JSON/json_writer.cpp
)
else ()
find_package(Jsoncpp REQUIRED)
set(POLLY_JSON_FILES)
endif ()
include_directories(
BEFORE
${CMAKE_CURRENT_SOURCE_DIR}/include
${ISL_INCLUDE_DIRS}
${JSONCPP_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/lib/External/pet/include
${CMAKE_CURRENT_SOURCE_DIR}/lib/External
${CMAKE_CURRENT_BINARY_DIR}/include
)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY ${POLLY_BINARY_DIR}/include/
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
PATTERN "CMakeFiles" EXCLUDE
PATTERN ".svn" EXCLUDE
)
endif()
add_definitions( -D_GNU_SOURCE )
add_subdirectory(docs)
add_subdirectory(lib)
add_subdirectory(test)
if (POLLY_GTEST_AVAIL)
add_subdirectory(unittests)
endif ()
add_subdirectory(tools)
add_subdirectory(cmake)
# TODO: docs.
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/polly/Config/config.h.cmake
${POLLY_BINARY_DIR}/include/polly/Config/config.h )
# Add target to check formatting of polly files
file( GLOB_RECURSE files *.h lib/*.cpp lib/*.c tools/*.cpp tools/*.c tools/*.h unittests/*.cpp)
file( GLOB_RECURSE external lib/External/*.h lib/External/*.c lib/External/*.cpp isl_config.h)
list( REMOVE_ITEM files ${external})
set(check_format_depends)
set(update_format_depends)
set(i 0)
foreach (file IN LISTS files)
add_custom_command(OUTPUT polly-check-format${i}
COMMAND clang-format -sort-includes -style=llvm ${file} | diff -u ${file} -
VERBATIM
COMMENT "Checking format of ${file}..."
)
list(APPEND check_format_depends "polly-check-format${i}")
add_custom_command(OUTPUT polly-update-format${i}
COMMAND clang-format -sort-includes -i -style=llvm ${file}
VERBATIM
COMMENT "Updating format of ${file}..."
)
list(APPEND update_format_depends "polly-update-format${i}")
math(EXPR i ${i}+1)
endforeach ()
add_custom_target(polly-check-format DEPENDS ${check_format_depends})
set_target_properties(polly-check-format PROPERTIES FOLDER "Polly")
add_custom_target(polly-update-format DEPENDS ${update_format_depends})
set_target_properties(polly-update-format PROPERTIES FOLDER "Polly")

42
external/llvm-project/polly/CREDITS.txt vendored Normal file
View File

@@ -0,0 +1,42 @@
This file is a partial list of people who have contributed to Polly.
If you have contributed a patch or made some other contribution to
Polly, please submit a patch to this file to add yourself, and it will be
done!
The list is sorted by surname and formatted to allow easy grepping and
beautification by scripts. The fields are: name (N), email (E), web-address
(W), PGP key ID and fingerprint (P), description (D), and snail-mail address
(S).
N: Raghesh Aloor
E: raghesh.a@gmail.com
D: OpenMP code generation
D: Google Summer of Code student 2011
N: Tobias Grosser
E: tobias@grosser.es
W: http://www.grosser.es
D: Co-founder, design of the overall architecture
N: Yabin Hu
E: yabin.hwu@gmail.com
D: GPGPU code generation
D: Google Summer of Code student 2012, 2014
N: Andreas Simbuerger
E: simbuerg@fim.uni-passau.de
W: http://www.infosun.fim.uni-passau.de/cl/staff/simbuerger/
D: Profiling infrastructure
N: Hongbin Zheng
E: etherzhhb@gmail.com
D: Co-founder
D: scop detection, automake/cmake infrastructure, scopinfo, scoppasses, ...
D: Google Summer of Code student 2010
N: Johannes Doerfert
E: doerfert@cs.uni-saarland.de
E: jdoerfert@codeaurora.org
W: http://www.cdl.uni-saarland.de/people/doerfert/
P: http://www.cdl.uni-saarland.de/people/doerfert/JohannesDoerfert.asc
D: reductions, general infrastructure

61
external/llvm-project/polly/LICENSE.txt vendored Normal file
View File

@@ -0,0 +1,61 @@
==============================================================================
Polly Release License
==============================================================================
University of Illinois/NCSA
Open Source License
Copyright (c) 2009-2016 Polly Team
All rights reserved.
Developed by:
Polly Team
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
* Neither the names of the Polly Team, copyright holders, nor the names of
its contributors may be used to endorse or promote products derived from
this Software without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
==============================================================================
Copyrights and Licenses for Third Party Software Distributed with LLVM:
==============================================================================
The Polly software contains code written by third parties. Such software will
have its own individual LICENSE.TXT file in the directory in which it appears.
This file will describe the copyrights, license, and restrictions which apply
to that code.
The disclaimer of warranty in the University of Illinois Open Source License
applies to all code in the Polly Distribution, and nothing in any of the other
licenses gives permission to use the names of the Polly Team or promote products
derived from this Software.
The following pieces of software have additional or alternate copyrights,
licenses, and/or restrictions:
Program Directory
------- ---------
jsoncpp lib/External/JSON

12
external/llvm-project/polly/README vendored Normal file
View File

@@ -0,0 +1,12 @@
Polly - Polyhedral optimizations for LLVM
-----------------------------------------
http://polly.llvm.org/
Polly uses a mathematical representation, the polyhedral model, to represent and
transform loops and other control flow structures. Using an abstract
representation it is possible to reason about transformations in a more general
way and to use highly optimized linear programming libraries to figure out the
optimal loop structure. These transformations can be used to do constant
propagation through arrays, remove dead loop iterations, optimize loops for
cache locality, optimize arrays, apply advanced automatic parallelization, drive
vectorization, or they can be used to do software pipelining.

View File

@@ -0,0 +1,133 @@
# Keep this in sync with llvm/cmake/CMakeLists.txt!
set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
if (CMAKE_CONFIGURATION_TYPES)
set(POLLY_EXPORTS_FILE_NAME "PollyExports-$<LOWER_CASE:$<CONFIG>>.cmake")
else()
# avoid conflicts in the build-tree when changing configuration
set(POLLY_EXPORTS_FILE_NAME "PollyExports-all.cmake")
endif()
set(POLLY_CONFIG_EXPORTED_TARGETS Polly ${ISL_TARGET})
if (NOT MSVC)
# LLVMPolly is a dummy target on Win
list(APPEND POLLY_CONFIG_EXPORTED_TARGETS LLVMPolly)
endif()
if (POLLY_ENABLE_GPGPU_CODEGEN)
list(APPEND POLLY_CONFIG_EXPORTED_TARGETS PollyPPCG)
endif()
# Get the target type for every exported target
foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
get_target_property(tgt_type ${tgt} TYPE)
string(REPLACE "_LIBRARY" "" tgt_type ${tgt_type})
set(POLLY_CONFIG_TARGET_${tgt}_TYPE ${tgt_type})
endforeach()
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
set(POLLY_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
# generate the import code for bundled/undbundled libisl versions
if (NOT POLLY_BUNDLED_ISL)
get_property(incl TARGET ISL PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(lib TARGET ISL PROPERTY INTERFACE_LINK_LIBRARIES)
get_property(opt TARGET ISL PROPERTY INTERFACE_COMPILE_OPTIONS)
set(ISL_CONFIG_CODE "
add_library(ISL INTERFACE IMPORTED)
set_property(TARGET ISL APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${incl})
set_property(TARGET ISL APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${lib})
set_property(TARGET ISL APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${opt})")
else()
set(ISL_CONFIG_CODE "
if (NOT TARGET PollyISL)
add_library(PollyISL ${POLLY_CONFIG_TARGET_PollyISL_TYPE} IMPORTED)
endif()")
endif()
# Generate PollyConfig.cmake for the build tree.
set(POLLY_CONFIG_CMAKE_DIR "${CMAKE_BINARY_DIR}/${POLLY_INSTALL_PACKAGE_DIR}")
set(POLLY_CONFIG_INCLUDE_DIRS
${POLLY_SOURCE_DIR}/include
${ISL_INCLUDE_DIRS}
${POLLY_BINARY_DIR}/include
)
set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_BINARY_DIR}/lib")
# set locations for imported targets
foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
get_target_property(tgt_type ${tgt} TYPE)
if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
set(POLLY_EXPORTS
"set_target_properties(${tgt} PROPERTIES
IMPORTED_LOCATION_$<UPPER_CASE:$<CONFIG>> $<TARGET_FILE:${tgt}>)
${POLLY_EXPORTS}")
endif()
endforeach(tgt)
# PollyConfig holds the target definitions and general settings, PollyExports
# the imported locations
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
@ONLY)
file(GENERATE
OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
CONTENT "${POLLY_EXPORTS}")
# Generate PollyConfig.cmake for the install tree.
unset(POLLY_EXPORTS)
set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
if (POLLY_BUNDLED_ISL)
set(POLLY_CONFIG_INCLUDE_DIRS
"${POLLY_INSTALL_PREFIX}/include"
"${POLLY_INSTALL_PREFIX}/include/polly"
)
else()
set(POLLY_CONFIG_INCLUDE_DIRS
"${POLLY_INSTALL_PREFIX}/include"
${ISL_INCLUDE_DIRS}
)
endif()
# set locations for imported targets. The path is constructed to be relative to
# the config file
foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
get_target_property(tgt_type ${tgt} TYPE)
if (tgt_type STREQUAL "EXECUTABLE")
set(tgt_prefix "bin/")
else()
set(tgt_prefix "lib/")
endif()
set(tgt_path "${CMAKE_INSTALL_PREFIX}/${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
file(RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path})
if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
set(POLLY_EXPORTS
"set_target_properties(${tgt} PROPERTIES
IMPORTED_LOCATION$<$<NOT:$<CONFIG:>>:_<UPPER_CASE:$<CONFIG>> \${CMAKE_CURRENT_LIST_DIR}/${tgt_path})
${POLLY_EXPORTS}")
endif()
endforeach(tgt)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake
@ONLY)
file(GENERATE OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}
CONTENT "${POLLY_EXPORTS}")
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")
endif ()

View File

@@ -0,0 +1,24 @@
find_package(PkgConfig REQUIRED)
pkg_search_module(ISL isl)
if (NOT ISL_FOUND EQUAL 1)
message(FATAL_ERROR "No libisl found on this system. Consider setting PKG_CONFIG_PATH.")
endif()
add_library(ISL INTERFACE IMPORTED)
foreach (incl IN LISTS ISL_INCLUDE_DIRS)
set_property(TARGET ISL APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${incl})
endforeach()
foreach (libname IN LISTS ISL_LIBRARIES)
if (ISL_LIBRARY_DIRS)
foreach (dir IN LISTS ISL_LIBRARY_DIRS)
list(APPEND hints ${dir})
endforeach()
endif()
find_library(lib NAMES ${libname} HINTS ${hints} NO_DEFAULT_PATH)
set_property(TARGET ISL APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${lib})
endforeach()
foreach (opt IN LISTS ISL_CFLAGS ISL_CFLAGS_OTHER)
set_property(TARGET ISL APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${opt})
endforeach()

View File

@@ -0,0 +1,57 @@
find_package(PkgConfig QUIET)
if (PkgConfig_FOUND)
pkg_search_module(JSONCPP jsoncpp QUIET)
# Get the libraries full paths, to be consistent with find_library().
set(fulllibs)
foreach (libname IN LISTS JSONCPP_LIBRARIES)
find_library(jsoncpp_lib${libname} NAMES ${libname}
HINTS ${JSONCPP_LIBDIR} ${JSONCPP_LIBRARY_DIRS}
)
if (jsoncpp_lib${libname})
list(APPEND fulllibs ${jsoncpp_lib${libname}})
else ()
list(APPEND fulllibs ${libname})
endif ()
endforeach ()
set(JSONCPP_LIBRARIES ${fulllibs})
set(JSONCPP_DEFINITIONS ${JSONCPP_CFLAGS})
else ()
set(JSONCPP_DEFINITIONS)
find_path(JSONCPP_INCLUDE_DIR json/json.h
PATHS ENV JSONCPP_INCLUDE ENV JSONCPP_DIR
PATH_SUFFIXES jsoncpp
NO_DEFAULT_PATH
)
find_path(JSONCPP_INCLUDE_DIR json/json.h
PATH_SUFFIXES jsoncpp
)
mark_as_advanced(JSONCPP_INCLUDE_DIR)
set(JSONCPP_INCLUDE_DIRS "${JSONCPP_INCLUDE_DIR}")
find_library(JSONCPP_LIBRARY NAMES jsoncpp
HINTS ENV JSONCPP_LIB ENV JSONCPP_DIR
NO_DEFAULT_PATH
)
find_library(JSONCPP_LIBRARY NAMES jsoncpp)
mark_as_advanced(JSONCPP_LIBRARY)
set(JSON_LIBRARIES ${JSON_LIBRARY})
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Jsoncpp DEFAULT_MSG JSONCPP_INCLUDE_DIRS JSONCPP_LIBRARIES JSONCPP_DEFINITIONS)
if (Jsoncpp_FOUND)
add_library(jsoncpp INTERFACE IMPORTED)
foreach (incl IN LISTS JSONCPP_INCLUDE_DIRS)
set_property(TARGET jsoncpp APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${incl})
endforeach ()
foreach (libname IN LISTS JSONCPP_LIBRARIES)
set_property(TARGET jsoncpp APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${libname})
endforeach ()
foreach (opt IN LISTS JSONCPP_DEFINITIONS)
set_property(TARGET jsoncpp APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${opt})
endforeach ()
endif ()

View File

@@ -0,0 +1,43 @@
# This file allows users to call find_package(Polly) and pick up our targets.
find_package(LLVM REQUIRED CONFIG
HINTS "@POLLY_CONFIG_LLVM_CMAKE_DIR@")
set(Polly_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
set(Polly_BUNDLED_ISL @POLLY_BUNDLED_ISL@)
set(Polly_BUNDLED_JSONCPP @POLLY_BUNDLED_JSONCPP@)
set(Polly_ENABLE_GPGPU_CODEGEN @POLLY_ENABLE_GPGPU_CODEGEN@)
set(Polly_DEFINITIONS ${LLVM_DEFINITIONS})
set(Polly_INCLUDE_DIRS @POLLY_CONFIG_INCLUDE_DIRS@ ${LLVM_INCLUDE_DIRS})
set(Polly_LIBRARY_DIRS @POLLY_CONFIG_LIBRARY_DIRS@)
set(Polly_EXPORTED_TARGETS @POLLY_CONFIG_EXPORTED_TARGETS@)
set(Polly_LIBRARIES ${LLVM_LIBRARIES} ${Polly_EXPORTED_TARGETS})
# Imported Targets:
@ISL_CONFIG_CODE@
if (Polly_ENABLE_GPGPU_CODEGEN AND NOT TARGET PollyPPCG)
add_library(PollyPPCG @POLLY_CONFIG_TARGET_PollyPPCG_TYPE@ IMPORTED)
set_property(TARGET PollyPPCG PROPERTY INTERFACE_LINK_LIBRARIES @ISL_TARGET@)
endif()
if (NOT TARGET Polly)
add_library(Polly @POLLY_CONFIG_TARGET_Polly_TYPE@ IMPORTED)
set_property(TARGET Polly PROPERTY INTERFACE_LINK_LIBRARIES @ISL_TARGET@)
if (Polly_ENABLE_GPGPU_CODEGEN)
set_property(TARGET Polly APPEND PROPERTY INTERFACE_LINK_LIBRARIES PollyPPCG)
endif()
set_property(TARGET Polly APPEND PROPERTY INTERFACE_LINK_LIBRARIES @JSONCPP_LIBRARIES@)
endif()
if (NOT TARGET LLVMPolly)
add_library(LLVMPolly @POLLY_CONFIG_TARGET_LLVMPolly_TYPE@ IMPORTED)
set_property(TARGET LLVMPolly PROPERTY INTERFACE_LINK_LIBRARIES Polly)
endif()
# Exported locations:
file(GLOB CONFIG_FILES "${Polly_CMAKE_DIR}/PollyExports-*.cmake")
foreach(f ${CONFIG_FILES})
include(${f})
endforeach()

View File

@@ -0,0 +1,88 @@
include(CMakeParseArguments)
macro(add_polly_library name)
cmake_parse_arguments(ARG "" "" "" ${ARGN})
set(srcs ${ARG_UNPARSED_ARGUMENTS})
if(MSVC_IDE OR XCODE)
file( GLOB_RECURSE headers *.h *.td *.def)
set(srcs ${srcs} ${headers})
string( REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
list( GET split_path -1 dir)
file( GLOB_RECURSE headers
../../include/polly${dir}/*.h)
set(srcs ${srcs} ${headers})
endif(MSVC_IDE OR XCODE)
if (MODULE)
set(libkind MODULE)
elseif (SHARED_LIBRARY)
set(libkind SHARED)
else()
set(libkind)
endif()
add_library( ${name} ${libkind} ${srcs} )
set_target_properties(${name} PROPERTIES FOLDER "Polly")
if( LLVM_COMMON_DEPENDS )
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
if( LLVM_USED_LIBS )
foreach(lib ${LLVM_USED_LIBS})
target_link_libraries( ${name} ${lib} )
endforeach(lib)
endif( LLVM_USED_LIBS )
if(POLLY_LINK_LIBS)
foreach(lib ${POLLY_LINK_LIBS})
target_link_libraries(${name} ${lib})
endforeach(lib)
endif(POLLY_LINK_LIBS)
if( LLVM_LINK_COMPONENTS )
llvm_config(${name} ${LLVM_LINK_COMPONENTS})
endif( LLVM_LINK_COMPONENTS )
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly")
install(TARGETS ${name}
EXPORT LLVMExports
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endmacro(add_polly_library)
macro(add_polly_loadable_module name)
set(srcs ${ARGN})
# klduge: pass different values for MODULE with multiple targets in same dir
# this allows building shared-lib and module in same dir
# there must be a cleaner way to achieve this....
if (MODULE)
else()
set(GLOBAL_NOT_MODULE TRUE)
endif()
set(MODULE TRUE)
add_polly_library(${name} ${srcs})
set_target_properties(${name} PROPERTIES FOLDER "Polly")
if (GLOBAL_NOT_MODULE)
unset (MODULE)
endif()
if (APPLE)
# Darwin-specific linker flags for loadable modules.
set_target_properties(${name} PROPERTIES
LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()
endmacro(add_polly_loadable_module)
# Use C99-compatible compile mode for all C source files of a target.
function(target_enable_c99 _target)
if(CMAKE_VERSION VERSION_GREATER "3.1")
set_target_properties("${_target}" PROPERTIES C_STANDARD 99)
elseif(CMAKE_COMPILER_IS_GNUCC)
get_target_property(_sources "${_target}" SOURCES)
foreach(_file IN LISTS _sources)
get_source_file_property(_lang "${_file}" LANGUAGE)
if(_lang STREQUAL "C")
set_source_files_properties(${_file} COMPILE_FLAGS "-std=gnu99")
endif()
endforeach()
endif()
endfunction()

View File

@@ -0,0 +1,93 @@
================
The Architecture
================
Polly is a loop optimizer for LLVM. Starting from LLVM-IR it detects and
extracts interesting loop kernels. For each kernel a mathematical model is
derived which precisely describes the individual computations and memory
accesses in the kernels. Within Polly a variety of analysis and code
transformations are performed on this mathematical model. After all
optimizations have been derived and applied, optimized LLVM-IR is regenerated
and inserted into the LLVM-IR module.
.. image:: images/architecture.png
:align: center
Polly in the LLVM pass pipeline
-------------------------------
The standard LLVM pass pipeline as it is used in -O1/-O2/-O3 mode of clang/opt
consists of a sequence of passes that can be grouped in different conceptual
phases. The first phase, we call it here **Canonicalization**, is a scalar
canonicalization phase that contains passes like -mem2reg, -instcombine,
-cfgsimplify, or early loop unrolling. It has the goal of removing and
simplifying the given IR as much as possible focusing mostly on scalar
optimizations. The second phase consists of three conceptual groups that are
executed in the so-called **Inliner cycle**, This is again a set of **Scalar
Simplification** passes, a set of **Simple Loop Optimizations**, and the
**Inliner** itself. Even though these passes make up the majority of the LLVM
pass pipeline, the primary goal of these passes is still canonicalization
without loosing semantic information that complicates later analysis. As part of
the inliner cycle, the LLVM inliner step-by-step tries to inline functions, runs
canonicalization passes to exploit newly exposed simplification opportunities,
and then tries to inline the further simplified functions. Some simple loop
optimizations are executed as part of the inliner cycle. Even though they
perform some optimizations, their primary goal is still the simplification of
the program code. Loop invariant code motion is one such optimization that
besides being beneficial for program performance also allows us to move
computation out of loops and in the best case enables us to eliminate certain
loops completely. Only after the inliner cycle has been finished, a last
**Target Specialization** phase is run, where IR complexity is deliberately
increased to take advantage of target specific features that maximize the
execution performance on the device we target. One of the principal
optimizations in this phase is vectorization, but also target specific loop
unrolling, or some loop transformations (e.g., distribution) that expose more
vectorization opportunities.
.. image:: images/LLVM-Passes-only.png
:align: center
Polly can conceptually be run at three different positions in the pass pipeline.
As an early optimizer before the standard LLVM pass pipeline, as a later
optimizer as part of the target specialization sequence, and theoretically also
with the loop optimizations in the inliner cycle. We only discuss the first two
options, as running Polly in the inline loop, is likely to disturb the inliner
and is consequently not a good idea.
.. image:: images/LLVM-Passes-all.png
:align: center
Running Polly early before the standard pass pipeline has the benefit that the
LLVM-IR processed by Polly is still very close to the original input code.
Hence, it is less likely that transformations applied by LLVM change the IR in
ways not easily understandable for the programmer. As a result, user feedback is
likely better and it is less likely that kernels that in C seem a perfect fit
for Polly have been transformed such that Polly can not handle them any
more. On the other hand, codes that require inlining to be optimized won't
benefit if Polly is scheduled at this position. The additional set of
canonicalization passes required will result in a small, but general compile
time increase and some random run-time performance changes due to slightly
different IR being passed through the optimizers. To force Polly to run early in
the pass pipleline use the option *-polly-position=early* (default today).
.. image:: images/LLVM-Passes-early.png
:align: center
Running Polly right before the vectorizer has the benefit that the full inlining
cycle has been run and as a result even heavily templated C++ code could
theoretically benefit from Polly (more work is necessary to make Polly here
really effective). As the IR that is passed to Polly has already been
canonicalized, there is also no need to run additional canonicalization passes.
General compile time is almost not affected by Polly, as detection of loop
kernels is generally very fast and the actual optimization and cleanup passes
are only run on functions which contain loop kernels that are worth optimizing.
However, due to the many optimizations that LLVM runs before Polly the IR that
reaches Polly often has additional scalar dependences that make Polly a lot less
efficient. To force Polly to run before the vectorizer in the pass pipleline use
the option *-polly-position=before-vectorizer*. This position is not yet the
default for Polly, but work is on its way to be effective even in presence of
scalar dependences. After this work has been completed, Polly will likely use
this position by default.
.. image:: images/LLVM-Passes-late.png
:align: center

View File

@@ -0,0 +1,103 @@
if (DOXYGEN_FOUND)
if (LLVM_ENABLE_DOXYGEN)
set(abs_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
set(abs_builddir ${CMAKE_CURRENT_BINARY_DIR})
if (HAVE_DOT)
set(DOT ${LLVM_PATH_DOT})
endif()
if (LLVM_DOXYGEN_EXTERNAL_SEARCH)
set(enable_searchengine "YES")
set(searchengine_url "${LLVM_DOXYGEN_SEARCHENGINE_URL}")
set(enable_server_based_search "YES")
set(enable_external_search "YES")
set(extra_search_mappings "${LLVM_DOXYGEN_SEARCH_MAPPINGS}")
else()
set(enable_searchengine "NO")
set(searchengine_url "")
set(enable_server_based_search "NO")
set(enable_external_search "NO")
set(extra_search_mappings "")
endif()
# If asked, configure doxygen for the creation of a Qt Compressed Help file.
if (LLVM_ENABLE_DOXYGEN_QT_HELP)
set(POLLY_DOXYGEN_QCH_FILENAME "org.llvm.polly.qch" CACHE STRING
"Filename of the Qt Compressed help file")
set(POLLY_DOXYGEN_QHP_NAMESPACE "org.llvm.polly" CACHE STRING
"Namespace under which the intermediate Qt Help Project file lives")
set(POLLY_DOXYGEN_QHP_CUST_FILTER_NAME "Clang ${POLLY_VERSION}" CACHE STRING
"See http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-filters")
set(POLLY_DOXYGEN_QHP_CUST_FILTER_ATTRS "Clang,${POLLY_VERSION}" CACHE STRING
"See http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes")
set(polly_doxygen_generate_qhp "YES")
set(polly_doxygen_qch_filename "${POLLY_DOXYGEN_QCH_FILENAME}")
set(polly_doxygen_qhp_namespace "${POLLY_DOXYGEN_QHP_NAMESPACE}")
set(polly_doxygen_qhelpgenerator_path "${LLVM_DOXYGEN_QHELPGENERATOR_PATH}")
set(polly_doxygen_qhp_cust_filter_name "${POLLY_DOXYGEN_QHP_CUST_FILTER_NAME}")
set(polly_doxygen_qhp_cust_filter_attrs "${POLLY_DOXYGEN_QHP_CUST_FILTER_ATTRS}")
else()
set(polly_doxygen_generate_qhp "NO")
set(polly_doxygen_qch_filename "")
set(polly_doxygen_qhp_namespace "")
set(polly_doxygen_qhelpgenerator_path "")
set(polly_doxygen_qhp_cust_filter_name "")
set(polly_doxygen_qhp_cust_filter_attrs "")
endif()
option(LLVM_DOXYGEN_SVG
"Use svg instead of png files for doxygen graphs." OFF)
if (LLVM_DOXYGEN_SVG)
set(DOT_IMAGE_FORMAT "svg")
else()
set(DOT_IMAGE_FORMAT "png")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg @ONLY)
set(abs_top_srcdir)
set(abs_top_builddir)
set(DOT)
set(enable_searchengine)
set(searchengine_url)
set(enable_server_based_search)
set(enable_external_search)
set(extra_search_mappings)
set(polly_doxygen_generate_qhp)
set(polly_doxygen_qch_filename)
set(polly_doxygen_qhp_namespace)
set(polly_doxygen_qhelpgenerator_path)
set(polly_doxygen_qhp_cust_filter_name)
set(polly_doxygen_qhp_cust_filter_attrs)
set(DOT_IMAGE_FORMAT)
add_custom_target(doxygen-polly
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating polly doxygen documentation." VERBATIM)
if (LLVM_BUILD_DOCS)
add_dependencies(doxygen doxygen-polly)
endif()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html
DESTINATION docs/html)
endif()
endif()
endif()
if (LLVM_ENABLE_SPHINX)
include(AddSphinxTarget)
if (SPHINX_FOUND)
if (${SPHINX_OUTPUT_HTML})
add_sphinx_target(html polly)
endif()
if (${SPHINX_OUTPUT_MAN})
add_sphinx_target(man polly)
endif()
endif()
endif()

View File

@@ -0,0 +1,475 @@
==================================================
How to manually use the Individual pieces of Polly
==================================================
Execute the individual Polly passes manually
============================================
.. sectionauthor:: Singapuram Sanjay Srivallabh
This example presents the individual passes that are involved when optimizing
code with Polly. We show how to execute them individually and explain for
each which analysis is performed or what transformation is applied. In this
example the polyhedral transformation is user-provided to show how much
performance improvement can be expected by an optimal automatic optimizer.
1. **Create LLVM-IR from the C code**
-------------------------------------
Polly works on LLVM-IR. Hence it is necessary to translate the source
files into LLVM-IR. If more than one file should be optimized the
files can be combined into a single file with llvm-link.
.. code-block:: console
clang -S -emit-llvm matmul.c -o matmul.s
2. **Prepare the LLVM-IR for Polly**
------------------------------------
Polly is only able to work with code that matches a canonical form.
To translate the LLVM-IR into this form we use a set of
canonicalication passes. They are scheduled by using
'-polly-canonicalize'.
.. code-block:: console
opt -S -polly-canonicalize matmul.s > matmul.preopt.ll
3. **Show the SCoPs detected by Polly (optional)**
--------------------------------------------------
To understand if Polly was able to detect SCoPs, we print the structure
of the detected SCoPs. In our example two SCoPs are detected. One in
'init_array' the other in 'main'.
.. code-block:: console
$ opt -polly-ast -analyze -q matmul.preopt.ll -polly-process-unprofitable
.. code-block:: guess
:: isl ast :: init_array :: %for.cond1.preheader---%for.end19
if (1)
for (int c0 = 0; c0 <= 1535; c0 += 1)
for (int c1 = 0; c1 <= 1535; c1 += 1)
Stmt_for_body3(c0, c1);
else
{ /* original code */ }
:: isl ast :: main :: %for.cond1.preheader---%for.end30
if (1)
for (int c0 = 0; c0 <= 1535; c0 += 1)
for (int c1 = 0; c1 <= 1535; c1 += 1) {
Stmt_for_body3(c0, c1);
for (int c2 = 0; c2 <= 1535; c2 += 1)
Stmt_for_body8(c0, c1, c2);
}
else
{ /* original code */ }
4. **Highlight the detected SCoPs in the CFGs of the program (requires graphviz/dotty)**
----------------------------------------------------------------------------------------
Polly can use graphviz to graphically show a CFG in which the detected
SCoPs are highlighted. It can also create '.dot' files that can be
translated by the 'dot' utility into various graphic formats.
.. code-block:: console
$ opt -view-scops -disable-output matmul.preopt.ll
$ opt -view-scops-only -disable-output matmul.preopt.ll
The output for the different functions:
- view-scops : main_, init_array_, print_array_
- view-scops-only : main-scopsonly_, init_array-scopsonly_, print_array-scopsonly_
.. _main: http://polly.llvm.org/experiments/matmul/scops.main.dot.png
.. _init_array: http://polly.llvm.org/experiments/matmul/scops.init_array.dot.png
.. _print_array: http://polly.llvm.org/experiments/matmul/scops.print_array.dot.png
.. _main-scopsonly: http://polly.llvm.org/experiments/matmul/scopsonly.main.dot.png
.. _init_array-scopsonly: http://polly.llvm.org/experiments/matmul/scopsonly.init_array.dot.png
.. _print_array-scopsonly: http://polly.llvm.org/experiments/matmul/scopsonly.print_array.dot.png
5. **View the polyhedral representation of the SCoPs**
------------------------------------------------------
.. code-block:: console
$ opt -polly-scops -analyze matmul.preopt.ll -polly-process-unprofitable
.. code-block:: guess
[...]Printing analysis 'Polly - Create polyhedral description of Scops' for region: 'for.cond1.preheader => for.end19' in function 'init_array':
Function: init_array
Region: %for.cond1.preheader---%for.end19
Max Loop Depth: 2
Invariant Accesses: {
}
Context:
{ : }
Assumed Context:
{ : }
Invalid Context:
{ : 1 = 0 }
Arrays {
float MemRef_A[*][1536]; // Element size 4
float MemRef_B[*][1536]; // Element size 4
}
Arrays (Bounds as pw_affs) {
float MemRef_A[*][ { [] -> [(1536)] } ]; // Element size 4
float MemRef_B[*][ { [] -> [(1536)] } ]; // Element size 4
}
Alias Groups (0):
n/a
Statements {
Stmt_for_body3
Domain :=
{ Stmt_for_body3[i0, i1] : 0 <= i0 <= 1535 and 0 <= i1 <= 1535 };
Schedule :=
{ Stmt_for_body3[i0, i1] -> [i0, i1] };
MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
{ Stmt_for_body3[i0, i1] -> MemRef_A[i0, i1] };
MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
{ Stmt_for_body3[i0, i1] -> MemRef_B[i0, i1] };
}
[...]Printing analysis 'Polly - Create polyhedral description of Scops' for region: 'for.cond1.preheader => for.end30' in function 'main':
Function: main
Region: %for.cond1.preheader---%for.end30
Max Loop Depth: 3
Invariant Accesses: {
}
Context:
{ : }
Assumed Context:
{ : }
Invalid Context:
{ : 1 = 0 }
Arrays {
float MemRef_C[*][1536]; // Element size 4
float MemRef_A[*][1536]; // Element size 4
float MemRef_B[*][1536]; // Element size 4
}
Arrays (Bounds as pw_affs) {
float MemRef_C[*][ { [] -> [(1536)] } ]; // Element size 4
float MemRef_A[*][ { [] -> [(1536)] } ]; // Element size 4
float MemRef_B[*][ { [] -> [(1536)] } ]; // Element size 4
}
Alias Groups (0):
n/a
Statements {
Stmt_for_body3
Domain :=
{ Stmt_for_body3[i0, i1] : 0 <= i0 <= 1535 and 0 <= i1 <= 1535 };
Schedule :=
{ Stmt_for_body3[i0, i1] -> [i0, i1, 0, 0] };
MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
{ Stmt_for_body3[i0, i1] -> MemRef_C[i0, i1] };
Stmt_for_body8
Domain :=
{ Stmt_for_body8[i0, i1, i2] : 0 <= i0 <= 1535 and 0 <= i1 <= 1535 and 0 <= i2 <= 1535 };
Schedule :=
{ Stmt_for_body8[i0, i1, i2] -> [i0, i1, 1, i2] };
ReadAccess := [Reduction Type: NONE] [Scalar: 0]
{ Stmt_for_body8[i0, i1, i2] -> MemRef_C[i0, i1] };
ReadAccess := [Reduction Type: NONE] [Scalar: 0]
{ Stmt_for_body8[i0, i1, i2] -> MemRef_A[i0, i2] };
ReadAccess := [Reduction Type: NONE] [Scalar: 0]
{ Stmt_for_body8[i0, i1, i2] -> MemRef_B[i2, i1] };
MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
{ Stmt_for_body8[i0, i1, i2] -> MemRef_C[i0, i1] };
}
6. **Show the dependences for the SCoPs**
-----------------------------------------
.. code-block:: console
$ opt -polly-dependences -analyze matmul.preopt.ll -polly-process-unprofitable
.. code-block:: guess
[...]Printing analysis 'Polly - Calculate dependences' for region: 'for.cond1.preheader => for.end19' in function 'init_array':
RAW dependences:
{ }
WAR dependences:
{ }
WAW dependences:
{ }
Reduction dependences:
n/a
Transitive closure of reduction dependences:
{ }
[...]Printing analysis 'Polly - Calculate dependences' for region: 'for.cond1.preheader => for.end30' in function 'main':
RAW dependences:
{ Stmt_for_body3[i0, i1] -> Stmt_for_body8[i0, i1, 0] : 0 <= i0 <= 1535 and 0 <= i1 <= 1535; Stmt_for_body8[i0, i1, i2] -> Stmt_for_body8[i0, i1, 1 + i2] : 0 <= i0 <= 1535 and 0 <= i1 <= 1535 and 0 <= i2 <= 1534 }
WAR dependences:
{ }
WAW dependences:
{ Stmt_for_body3[i0, i1] -> Stmt_for_body8[i0, i1, 0] : 0 <= i0 <= 1535 and 0 <= i1 <= 1535; Stmt_for_body8[i0, i1, i2] -> Stmt_for_body8[i0, i1, 1 + i2] : 0 <= i0 <= 1535 and 0 <= i1 <= 1535 and 0 <= i2 <= 1534 }
Reduction dependences:
n/a
Transitive closure of reduction dependences:
{ }
7. **Export jscop files**
-------------------------
.. code-block:: console
$ opt -polly-export-jscop matmul.preopt.ll -polly-process-unprofitable
.. code-block:: guess
[...]Writing JScop '%for.cond1.preheader---%for.end19' in function 'init_array' to './init_array___%for.cond1.preheader---%for.end19.jscop'.
Writing JScop '%for.cond1.preheader---%for.end30' in function 'main' to './main___%for.cond1.preheader---%for.end30.jscop'.
8. **Import the changed jscop files and print the updated SCoP structure (optional)**
-------------------------------------------------------------------------------------
Polly can reimport jscop files, in which the schedules of the statements
are changed. These changed schedules are used to descripe
transformations. It is possible to import different jscop files by
providing the postfix of the jscop file that is imported.
We apply three different transformations on the SCoP in the main
function. The jscop files describing these transformations are
hand written (and available in docs/experiments/matmul).
**No Polly**
As a baseline we do not call any Polly code generation, but only apply the normal -O3 optimizations.
.. code-block:: console
$ opt matmul.preopt.ll -polly-import-jscop -polly-ast -analyze -polly-process-unprofitable
.. code-block:: c
[...]
:: isl ast :: main :: %for.cond1.preheader---%for.end30
if (1)
for (int c0 = 0; c0 <= 1535; c0 += 1)
for (int c1 = 0; c1 <= 1535; c1 += 1) {
Stmt_for_body3(c0, c1);
for (int c3 = 0; c3 <= 1535; c3 += 1)
Stmt_for_body8(c0, c1, c3);
}
else
{ /* original code */ }
[...]
**Loop Interchange (and Fission to allow the interchange)**
We split the loops and can now apply an interchange of the loop dimensions that enumerate Stmt_for_body8.
.. Although I feel (and have created a .jscop) we can avoid splitting the loops.
.. code-block:: console
$ opt matmul.preopt.ll -polly-import-jscop -polly-import-jscop-postfix=interchanged -polly-ast -analyze -polly-process-unprofitable
.. code-block:: c
[...]
:: isl ast :: main :: %for.cond1.preheader---%for.end30
if (1)
{
for (int c1 = 0; c1 <= 1535; c1 += 1)
for (int c2 = 0; c2 <= 1535; c2 += 1)
Stmt_for_body3(c1, c2);
for (int c1 = 0; c1 <= 1535; c1 += 1)
for (int c2 = 0; c2 <= 1535; c2 += 1)
for (int c3 = 0; c3 <= 1535; c3 += 1)
Stmt_for_body8(c1, c3, c2);
}
else
{ /* original code */ }
[...]
**Interchange + Tiling**
In addition to the interchange we now tile the second loop nest.
.. code-block:: console
$ opt matmul.preopt.ll -polly-import-jscop -polly-import-jscop-postfix=interchanged+tiled -polly-ast -analyze -polly-process-unprofitable
.. code-block:: c
[...]
:: isl ast :: main :: %for.cond1.preheader---%for.end30
if (1)
{
for (int c1 = 0; c1 <= 1535; c1 += 1)
for (int c2 = 0; c2 <= 1535; c2 += 1)
Stmt_for_body3(c1, c2);
for (int c1 = 0; c1 <= 1535; c1 += 64)
for (int c2 = 0; c2 <= 1535; c2 += 64)
for (int c3 = 0; c3 <= 1535; c3 += 64)
for (int c4 = c1; c4 <= c1 + 63; c4 += 1)
for (int c5 = c3; c5 <= c3 + 63; c5 += 1)
for (int c6 = c2; c6 <= c2 + 63; c6 += 1)
Stmt_for_body8(c4, c6, c5);
}
else
{ /* original code */ }
[...]
**Interchange + Tiling + Strip-mining to prepare vectorization**
To later allow vectorization we create a so called trivially
parallelizable loop. It is innermost, parallel and has only four
iterations. It can be replaced by 4-element SIMD instructions.
.. code-block:: console
$ opt matmul.preopt.ll -polly-import-jscop -polly-import-jscop-postfix=interchanged+tiled -polly-ast -analyze -polly-process-unprofitable
.. code-block:: c
[...]
:: isl ast :: main :: %for.cond1.preheader---%for.end30
if (1)
{
for (int c1 = 0; c1 <= 1535; c1 += 1)
for (int c2 = 0; c2 <= 1535; c2 += 1)
Stmt_for_body3(c1, c2);
for (int c1 = 0; c1 <= 1535; c1 += 64)
for (int c2 = 0; c2 <= 1535; c2 += 64)
for (int c3 = 0; c3 <= 1535; c3 += 64)
for (int c4 = c1; c4 <= c1 + 63; c4 += 1)
for (int c5 = c3; c5 <= c3 + 63; c5 += 1)
for (int c6 = c2; c6 <= c2 + 63; c6 += 4)
for (int c7 = c6; c7 <= c6 + 3; c7 += 1)
Stmt_for_body8(c4, c7, c5);
}
else
{ /* original code */ }
[...]
9. **Codegenerate the SCoPs**
-----------------------------
This generates new code for the SCoPs detected by polly. If
-polly-import-jscop is present, transformations specified in the
imported jscop files will be applied.
.. code-block:: console
$ opt matmul.preopt.ll | opt -O3 > matmul.normalopt.ll
.. code-block:: console
$ opt matmul.preopt.ll -polly-import-jscop -polly-import-jscop-postfix=interchanged -polly-codegen -polly-process-unprofitable | opt -O3 > matmul.polly.interchanged.ll
.. code-block:: guess
Reading JScop '%for.cond1.preheader---%for.end19' in function 'init_array' from './init_array___%for.cond1.preheader---%for.end19.jscop.interchanged'.
File could not be read: No such file or directory
Reading JScop '%for.cond1.preheader---%for.end30' in function 'main' from './main___%for.cond1.preheader---%for.end30.jscop.interchanged'.
.. code-block:: console
$ opt matmul.preopt.ll -polly-import-jscop -polly-import-jscop-postfix=interchanged+tiled -polly-codegen -polly-process-unprofitable | opt -O3 > matmul.polly.interchanged+tiled.ll
.. code-block:: guess
Reading JScop '%for.cond1.preheader---%for.end19' in function 'init_array' from './init_array___%for.cond1.preheader---%for.end19.jscop.interchanged+tiled'.
File could not be read: No such file or directory
Reading JScop '%for.cond1.preheader---%for.end30' in function 'main' from './main___%for.cond1.preheader---%for.end30.jscop.interchanged+tiled'.
.. code-block:: console
$ opt matmul.preopt.ll -polly-import-jscop -polly-import-jscop-postfix=interchanged+tiled+vector -polly-codegen -polly-vectorizer=polly -polly-process-unprofitable | opt -O3 > matmul.polly.interchanged+tiled+vector.ll
.. code-block:: guess
Reading JScop '%for.cond1.preheader---%for.end19' in function 'init_array' from './init_array___%for.cond1.preheader---%for.end19.jscop.interchanged+tiled+vector'.
File could not be read: No such file or directory
Reading JScop '%for.cond1.preheader---%for.end30' in function 'main' from './main___%for.cond1.preheader---%for.end30.jscop.interchanged+tiled+vector'.
.. code-block:: console
$ opt matmul.preopt.ll -polly-import-jscop -polly-import-jscop-postfix=interchanged+tiled+vector -polly-codegen -polly-vectorizer=polly -polly-parallel -polly-process-unprofitable | opt -O3 > matmul.polly.interchanged+tiled+openmp.ll
.. code-block:: guess
Reading JScop '%for.cond1.preheader---%for.end19' in function 'init_array' from './init_array___%for.cond1.preheader---%for.end19.jscop.interchanged+tiled+vector'.
File could not be read: No such file or directory
Reading JScop '%for.cond1.preheader---%for.end30' in function 'main' from './main___%for.cond1.preheader---%for.end30.jscop.interchanged+tiled+vector'.
10. **Create the executables**
------------------------------
.. code-block:: console
$ llc matmul.normalopt.ll -o matmul.normalopt.s && gcc matmul.normalopt.s -o matmul.normalopt.exe
$ llc matmul.polly.interchanged.ll -o matmul.polly.interchanged.s && gcc matmul.polly.interchanged.s -o matmul.polly.interchanged.exe
$ llc matmul.polly.interchanged+tiled.ll -o matmul.polly.interchanged+tiled.s && gcc matmul.polly.interchanged+tiled.s -o matmul.polly.interchanged+tiled.exe
$ llc matmul.polly.interchanged+tiled+vector.ll -o matmul.polly.interchanged+tiled+vector.s && gcc matmul.polly.interchanged+tiled+vector.s -o matmul.polly.interchanged+tiled+vector.exe
$ llc matmul.polly.interchanged+tiled+vector+openmp.ll -o matmul.polly.interchanged+tiled+vector+openmp.s && gcc -fopenmp matmul.polly.interchanged+tiled+vector+openmp.s -o matmul.polly.interchanged+tiled+vector+openmp.exe
11. **Compare the runtime of the executables**
----------------------------------------------
By comparing the runtimes of the different code snippets we see that a
simple loop interchange gives here the largest performance boost.
However in this case, adding vectorization and using OpenMP degrades
the performance.
.. code-block:: console
$ time ./matmul.normalopt.exe
real 0m11.295s
user 0m11.288s
sys 0m0.004s
$ time ./matmul.polly.interchanged.exe
real 0m0.988s
user 0m0.980s
sys 0m0.008s
$ time ./matmul.polly.interchanged+tiled.exe
real 0m0.830s
user 0m0.816s
sys 0m0.012s
$ time ./matmul.polly.interchanged+tiled+vector.exe
real 0m5.430s
user 0m5.424s
sys 0m0.004s
$ time ./matmul.polly.interchanged+tiled+vector+openmp.exe
real 0m3.184s
user 0m11.972s
sys 0m0.036s

View File

@@ -0,0 +1,57 @@
.. include:: <isonum.txt>
==================================================
Performance
==================================================
High-Performance Generalized Matrix Multiplication
--------------------------------------------------
Polly automatically detects and optimizes generalized matrix multiplication,
the computation C |larr| α ⊗ C ⊕ β ⊗ A ⊗ B, where A, B, and C are three appropriately sized matrices,
⊕ and ⊗ operations are originating from the corresponding matrix semiring, and α and β are
constants, and beta is not equal to zero. It allows to obtain the highly optimized form structured
similar to the expert implementation of GEMM that can be found in GotoBLAS and its successors. The
performance evaluation of GEMM is shown in the following figure.
.. image:: images/GEMM_double.png
:align: center
Compile Time Impact of Polly
----------------------------
Clang+LLVM+Polly are compiled using Clang on a Intel(R) Core(TM) i7-7700 based system. The experiment
is repeated twice: with and without Polly enabled in order to measure its compile time impact.
The following versions are used:
- Polly (git hash 0db98a4837b6f233063307bb9184374175401922)
- Clang (git hash 3e1d04a92b51ed36163995c96c31a0e4bbb1561d)
- LLVM git hash 0265ec7ebad69a47f5c899d95295b5eb41aba68e)
`ninja <https://ninja-build.org/>`_ is used as the build system.
For both cases the whole compilation was performed five times. The compile times in seconds are shown in the following table.
+----------------------------+
| Compile Time |
+--------------+-------------+
|Polly Disabled|Polly Enabled|
+==============+=============+
|964 |977 |
+--------------+-------------+
|964 |980 |
+--------------+-------------+
|967 |981 |
+--------------+-------------+
|967 |981 |
+--------------+-------------+
|968 |982 |
+--------------+-------------+
The median compile time without Polly enabled is 967 seconds and with Polly enabled it is 981 seconds. The overhead is 1.4%.

View File

@@ -0,0 +1,3 @@
=================
Release Notes 6.0
=================

View File

@@ -0,0 +1,56 @@
==================================================
Tips and Tricks on using and contributing to Polly
==================================================
Commiting to polly trunk
------------------------
- `General reference to git-svn workflow <https://stackoverflow.com/questions/190431/is-git-svn-dcommit-after-merging-in-git-dangerous>`_
Using bugpoint to track down errors in large files
--------------------------------------------------
If you know the ``opt`` invocation and have a large ``.ll`` file that causes
an error, ``bugpoint`` allows one to reduce the size of test cases.
The general calling pattern is:
- ``$ bugpoint <file.ll> <pass that causes the crash> -opt-args <opt option flags>``
An example invocation is:
- ``$ bugpoint crash.ll -polly-codegen -opt-args -polly-canonicalize -polly-process-unprofitable``
For more documentation on bugpoint, `Visit the LLVM manual <http://llvm.org/docs/Bugpoint.html>`_
Understanding which pass makes a particular change
--------------------------------------------------
If you know that something like `opt -O3 -polly` makes a change, but you wish to
isolate which pass makes a change, the steps are as follows:
- ``$ bugpoint -O3 file.ll -opt-args -polly`` will allow bugpoint to track down the pass which causes the crash.
To do this manually:
- ``$ opt -O3 -polly -debug-pass=Arguments`` to get all passes that are run by default. ``-debug-pass=Arguments`` will list all passes that have run.
- Bisect down to the pass that changes it.
Debugging regressions introduced at some unknown earlier point
--------------------------------------------------------------
In case of a regression in performance or correctness (e.g., an earlier version
of Polly behaved as expected and a later version does not), bisecting over the
version history is the standard approach to identify the commit that introduced
the regression.
LLVM has a single repository that contains all projects. It can be cloned at:
`<https://github.com/llvm-project/llvm-project-20170507>`_. How to bisect on a
git repository is explained here
`<https://www.metaltoad.com/blog/beginners-guide-git-bisect-process-elimination>`_.
The bisect process can also be automated as explained here:
`<https://www.metaltoad.com/blog/mechanizing-git-bisect-bug-hunting-lazy>`_.
An LLVM specific run script is available here:
`<https://gist.github.com/dcci/891cd98d80b1b95352a407d80914f7cf>`_.

View File

@@ -0,0 +1,132 @@
======================
Using Polly with Clang
======================
This documentation discusses how Polly can be used in Clang to automatically
optimize C/C++ code during compilation.
.. warning::
Warning: clang/LLVM/Polly need to be in sync (compiled from the same SVN
revision).
Make Polly available from Clang
===============================
Polly is available through clang, opt, and bugpoint, if Polly was checked out
into tools/polly before compilation. No further configuration is needed.
Optimizing with Polly
=====================
Optimizing with Polly is as easy as adding -O3 -mllvm -polly to your compiler
flags (Polly is only available at -O3).
.. code-block:: console
clang -O3 -mllvm -polly file.c
Automatic OpenMP code generation
================================
To automatically detect parallel loops and generate OpenMP code for them you
also need to add -mllvm -polly-parallel -lgomp to your CFLAGS.
.. code-block:: console
clang -O3 -mllvm -polly -mllvm -polly-parallel -lgomp file.c
Automatic Vector code generation
================================
Automatic vector code generation can be enabled by adding -mllvm
-polly-vectorizer=stripmine to your CFLAGS.
.. code-block:: console
clang -O3 -mllvm -polly -mllvm -polly-vectorizer=stripmine file.c
Extract a preoptimized LLVM-IR file
===================================
Often it is useful to derive from a C-file the LLVM-IR code that is actually
optimized by Polly. Normally the LLVM-IR is automatically generated from the C
code by first lowering C to LLVM-IR (clang) and by subsequently applying a set
of preparing transformations on the LLVM-IR. To get the LLVM-IR after the
preparing transformations have been applied run Polly with '-O0'.
.. code-block:: console
clang -O0 -mllvm -polly -S -emit-llvm file.c
Further options
===============
Polly supports further options that are mainly useful for the development or the
analysis of Polly. The relevant options can be added to clang by appending
-mllvm -option-name to the CFLAGS or the clang command line.
Limit Polly to a single function
--------------------------------
To limit the execution of Polly to a single function, use the option
-polly-only-func=functionname.
Disable LLVM-IR generation
--------------------------
Polly normally regenerates LLVM-IR from the Polyhedral representation. To only
see the effects of the preparing transformation, but to disable Polly code
generation add the option polly-no-codegen.
Graphical view of the SCoPs
---------------------------
Polly can use graphviz to show the SCoPs it detects in a program. The relevant
options are -polly-show, -polly-show-only, -polly-dot and -polly-dot-only. The
'show' options automatically run dotty or another graphviz viewer to show the
scops graphically. The 'dot' options store for each function a dot file that
highlights the detected SCoPs. If 'only' is appended at the end of the option,
the basic blocks are shown without the statements the contain.
Change/Disable the Optimizer
----------------------------
Polly uses by default the isl scheduling optimizer. The isl optimizer optimizes
for data-locality and parallelism using the Pluto algorithm.
To disable the optimizer entirely use the option -polly-optimizer=none.
Disable tiling in the optimizer
-------------------------------
By default both optimizers perform tiling, if possible. In case this is not
wanted the option -polly-tiling=false can be used to disable it. (This option
disables tiling for both optimizers).
Import / Export
---------------
The flags -polly-import and -polly-export allow the export and reimport of the
polyhedral representation. By exporting, modifying and reimporting the
polyhedral representation externally calculated transformations can be
applied. This enables external optimizers or the manual optimization of
specific SCoPs.
Viewing Polly Diagnostics with opt-viewer
-----------------------------------------
The flag -fsave-optimization-record will generate .opt.yaml files when compiling
your program. These yaml files contain information about each emitted remark.
Ensure that you have Python 2.7 with PyYaml and Pygments Python Packages.
To run opt-viewer:
.. code-block:: console
llvm/tools/opt-viewer/opt-viewer.py -source-dir /path/to/program/src/ \
/path/to/program/src/foo.opt.yaml \
/path/to/program/src/bar.opt.yaml \
-o ./output
Include all yaml files (use \*.opt.yaml when specifying which yaml files to view)
to view all diagnostics from your program in opt-viewer. Compile with `PGO
<https://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation>`_ to view
Hotness information in opt-viewer. Resulting html files can be viewed in an internet browser.

Some files were not shown because too many files have changed in this diff Show More