Skip to content

Commit 4b04755

Browse files
ivanradanovvataiwsmoses
committed
Integrate Polymer into Polygeist
Co-authored-by: Emil VATAI <[email protected]> Co-authored-by: William Moses <[email protected]>
1 parent 7e59c5d commit 4b04755

File tree

76 files changed

+1082
-1045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1082
-1045
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: llvm_project_build
1+
name: Polygeist build and test
22

33
on:
44
push:
@@ -8,14 +8,17 @@ on:
88

99
jobs:
1010
build:
11-
name: Build ${{ matrix.build }} ${{ matrix.os }} ${{ matrix.compiler }}
11+
name: Build ${{ matrix.os }} ${{ matrix.compiler }} polymer=${{ matrix.polymer }} pluto ${{ matrix.pluto-build }} mlir ${{ matrix.mlir-build }} polygeist ${{ matrix.polygeist-build }}
1212
runs-on: ${{ matrix.os }}
1313

1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
build: ["Release"] #, "Debug"] # "RelWithDebInfo"
18-
os: [ubuntu-latest]
17+
pluto-build: ["Release"] # Only Release supported currently
18+
mlir-build: ["Release"] #, "Debug"] # "RelWithDebInfo"
19+
polygeist-build: ["Release", "Debug"] #, "Debug"] # "RelWithDebInfo"
20+
polymer: ["0", "1"]
21+
os: [ubuntu-22.04]
1922
compiler: [gcc, clang]
2023
cxxcompiler: [g++, clang++]
2124
exclude:
@@ -32,39 +35,72 @@ jobs:
3235
path: src
3336
submodules: 'recursive'
3437

38+
- name: add dependencies
39+
run: sudo apt-get install -y llvm-15-tools ninja-build libbison-dev libtool libgmp-dev #libflex-dev cmake binutils-gold binutils binutils-dev ${{ matrix.compiler }} ${{ matrix.linker-pkg }}
40+
41+
- name: Cache Pluto
42+
id: cache-pluto
43+
uses: actions/cache@v3
44+
with:
45+
path: pluto-build
46+
key: ${{ matrix.pluto-build }}-${{ matrix.os }}-pluto-${{ matrix.polymer }}
47+
48+
- name: Pluto build
49+
if: steps.cache-pluto.outputs.cache-hit != 'true' && matrix.polymer == '1'
50+
run: |
51+
mkdir -p pluto-build
52+
PATH="/usr/lib/llvm-15/bin/:$PATH" src/tools/polymer/build_polymer_deps.sh $(pwd)/pluto-build
53+
sleep 1s
54+
- uses: actions/cache/save@v3
55+
if: steps.cache-pluto.outputs.cache-hit != 'true'
56+
with:
57+
path: pluto-build
58+
key: ${{ matrix.pluto-build }}-${{ matrix.os }}-pluto-${{ matrix.polymer }}
59+
3560
- name: Read LLVM commit
3661
id: getversion
37-
run: echo "::set-output name=version::$(cat src/.git/modules/llvm-project/HEAD)"
62+
run: echo "version=$(cat src/.git/modules/llvm-project/HEAD)" >> $GITHUB_OUTPUT
3863

3964
- name: Cache MLIR
4065
id: cache-mlir
4166
uses: actions/cache@v3
4267
with:
4368
path: mlir-build
44-
key: ${{ matrix.build }}-${{ matrix.os }}-mlir-${{ steps.getversion.outputs.version }}
45-
46-
- name: add dependencies
47-
run: sudo apt-get install -y ninja-build #cmake binutils-gold binutils binutils-dev ${{ matrix.compiler }} ${{ matrix.linker-pkg }}
69+
key: ${{ matrix.mlir-build }}-${{ matrix.os }}-mlir-${{ steps.getversion.outputs.version }}
4870

4971
- name: MLIR build
5072
if: steps.cache-mlir.outputs.cache-hit != 'true'
5173
run: |
5274
mkdir mlir-build
5375
cd mlir-build
54-
CYMBL=OFF cmake ../src/llvm-project/llvm -GNinja -DLLVM_ENABLE_PROJECTS="llvm;clang;mlir;openmp" -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_C_COMPILER=/bin/clang -DCMAKE_CXX_COMPILER=/bin/clang++ -DCMAKE_ASM_COMPILER=/bin/clang -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing"
76+
CYMBL=OFF cmake ../src/llvm-project/llvm -GNinja -DLLVM_ENABLE_PROJECTS="llvm;clang;mlir" -DCMAKE_BUILD_TYPE=${{ matrix.mlir-build }} -DCMAKE_C_COMPILER=/bin/clang -DCMAKE_CXX_COMPILER=/bin/clang++ -DCMAKE_ASM_COMPILER=/bin/clang -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing"
5577
#cymbld & disown
56-
sleep 10
78+
sleep 1
5779
CYMBL=OFF ninja
80+
- uses: actions/cache/save@v3
81+
if: steps.cache-mlir.outputs.cache-hit != 'true'
82+
with:
83+
path: mlir-build
84+
key: ${{ matrix.mlir-build }}-${{ matrix.os }}-mlir-${{ steps.getversion.outputs.version }}
5885

5986
- name: mkdir
6087
run: mkdir build
6188
- name: cmake
6289
run: |
6390
cd build
6491
ls ../mlir-build/lib/cmake/clang
65-
cmake ../src/ -GNinja -DMLIR_DIR=`pwd`/../mlir-build/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=`pwd`/../mlir-build/bin/llvm-lit -DClang_DIR=`pwd`/../mlir-build/lib/cmake/clang -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_C_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_COMPILER=${{matrix.cxxcompiler}}
92+
cmake ../src/ -GNinja -DMLIR_DIR=`pwd`/../mlir-build/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=`pwd`/../mlir-build/bin/llvm-lit -DClang_DIR=`pwd`/../mlir-build/lib/cmake/clang -DCMAKE_BUILD_TYPE=${{ matrix.polygeist-build }} -DCMAKE_C_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_COMPILER=${{matrix.cxxcompiler}} -DPOLYGEIST_ENABLE_POLYMER=${{ matrix.polymer }} -DPOLYMER_DEP_DIR=$(pwd)/../pluto-build/
93+
6694
- name: test cgeist
6795
run: |
6896
cd build
97+
ninja -j1
6998
ninja check-polygeist-opt
7099
ninja check-cgeist
100+
101+
- name: test polymer
102+
if: matrix.polymer == '1'
103+
run: |
104+
cd build
105+
ninja
106+
PATH="`pwd`/../mlir-build/bin:$PATH" LLVM_SYMBOLIZER_PATH="`pwd`/../mlir-build/bin/llvm-symbolizer" ninja check-polymer

.github/workflows/clang-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ jobs:
1616
fetch-depth: 1
1717
- uses: DoozyX/[email protected]
1818
with:
19-
exclude: './tools/cgeist/Test ./test'
19+
exclude: './tools/cgeist/Test ./test ./tools/polymer/example'
2020
clangFormatVersion: 11
2121
style: llvm

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.13.4)
22

33
include(CheckCXXSourceCompiles)
44

55
set(POLYGEIST_ENABLE_CUDA 0 CACHE BOOL "Enable CUDA frontend and backend")
66
set(POLYGEIST_ENABLE_ROCM 0 CACHE BOOL "Enable ROCM backend")
77

8+
set(POLYGEIST_ENABLE_POLYMER 0 CACHE BOOL "Enable Polymer")
9+
10+
set(POLYMER_DEP_DIR "" CACHE STRING "Pluto build root directory")
11+
12+
if ("${POLYMER_DEP_DIR}" STREQUAL "")
13+
set(POLYGEIST_PLUTO_DIR ${CMAKE_CURRENT_BINARY_DIR})
14+
else()
15+
set(POLYGEIST_PLUTO_DIR ${POLYMER_DEP_DIR})
16+
endif()
17+
18+
message(STATUS "polygeist_pluto_dir '${POLYGEIST_PLUTO_DIR}'")
19+
820
if(POLICY CMP0068)
921
cmake_policy(SET CMP0068 NEW)
1022
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,23 @@ ninja
5050
ninja check-polygeist-opt && ninja check-cgeist
5151
```
5252

53-
To enable compilation to cuda add `-DPOLYGEIST_ENABLE_CUDA=1`
53+
For faster compilation we recommend using `-DPOLYGEIST_USE_LINKER=lld`.
54+
55+
1. GPU backends
56+
57+
To enable the CUDA backend add `-DPOLYGEIST_ENABLE_CUDA=1`
5458

5559
To enable the ROCM backend add `-DPOLYGEIST_ENABLE_ROCM=1`
5660

57-
For faster compilation we recommend using `-DPOLYGEIST_USE_LINKER=lld`.
61+
2. Polymer
62+
63+
To enable polymer, add `-DPOLYGEIST_ENABLE_POLYMER=1`
64+
65+
This will cause the cmake invokation to pull and build the dependencies for polymer. To specify a custom directory for the dependencies, specify `-DPOLYMER_DEP_DIR=<absolute-dir>`. The dependencies will be build using the `tools/polymer/build_polymer_deps.sh`.
66+
67+
To run the polymer tests, use `ninja check-polymer`.
68+
69+
5870

5971
#### Option 2: Using unified LLVM, MLIR, Clang, and Polygeist build
6072

tools/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
add_subdirectory(polygeist-opt)
22
add_subdirectory(cgeist)
3+
4+
if(POLYGEIST_ENABLE_POLYMER)
5+
add_subdirectory(polymer)
6+
endif()

tools/cgeist/Test/polybench/stencils/seidel-2d/seidel-2d.pluto.i64.pluto.cloog

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

tools/polymer/CMakeLists.txt

Lines changed: 23 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,20 @@
1-
# Check if Polymer is built as a standalone out-of-(llvm/mlir)-tree project.
2-
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
1+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
2+
"${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
3+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
34

4-
project(polymer LANGUAGES CXX C)
5-
cmake_minimum_required(VERSION 3.13.4)
6-
7-
message (STATUS "Building Polymer as a standalone project")
8-
9-
# Policies requried by LLVM.
10-
if(POLICY CMP0068)
11-
cmake_policy(SET CMP0068 NEW)
12-
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
13-
endif()
14-
15-
if(POLICY CMP0075)
16-
cmake_policy(SET CMP0075 NEW)
17-
endif()
18-
19-
if(POLICY CMP0077)
20-
cmake_policy(SET CMP0077 NEW)
21-
endif()
22-
23-
set(CMAKE_CXX_STANDARD 14)
24-
set(CMAKE_CXX_STANDARD_REQUIRED YES)
25-
26-
# ----------------------------- LLVM/MLIR references
27-
find_package(LLVM REQUIRED CONFIG)
28-
find_package(MLIR REQUIRED CONFIG)
29-
30-
include_directories("${LLVM_INCLUDE_DIRS}")
31-
include_directories("${MLIR_INCLUDE_DIRS}")
32-
33-
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
34-
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
35-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
36-
37-
include(TableGen)
38-
include(AddLLVM)
39-
include(AddMLIR)
40-
include(HandleLLVMOptions)
41-
42-
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
43-
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
44-
45-
set(LLVM_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/bin")
46-
set(LLVM_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/lib")
47-
set(MLIR_BINARY_DIR "${CMAKE_BINARY_DIR}")
48-
49-
link_directories(${LLVM_BUILD_LIBRARY_DIR})
50-
add_definitions(${LLVM_DEFINITIONS})
51-
52-
# ----------------------------- Testing with LIT
53-
# Define the default arguments to use with 'lit', and an option for the user to
54-
# override.
55-
set(LIT_ARGS_DEFAULT "-sv")
56-
if (MSVC_IDE OR XCODE)
57-
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
58-
endif()
59-
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
60-
61-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
62-
"${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
63-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
64-
65-
set(POLYMER_TRANSFORM_DEPENDS "")
66-
67-
else()
68-
# Build as an external project to MLIR.
69-
# Need to wait until these targets are built.
70-
set(POLYMER_TRANSFORM_DEPENDS
71-
MLIRAffineOpsIncGen
72-
MLIRAffinePassIncGen
73-
MLIRLoopLikeInterfaceIncGen
74-
)
75-
76-
endif()
5+
set(POLYMER_TRANSFORM_DEPENDS
6+
MLIRAffineOpsIncGen
7+
MLIRAffinePassIncGen
8+
MLIRLoopLikeInterfaceIncGen
9+
)
7710

7811
set(POLYMER_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}" )
7912
set(POLYMER_MAIN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" )
8013

8114
set(POLYMER_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
8215
set(POLYMER_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/bin")
8316
set(POLYMER_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include" )
84-
set(POLYMER_TOOLS_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bin")
17+
set(POLYMER_TOOLS_DIR ${CMAKE_BINARY_DIR}/bin)
8518

8619
# ----------------------------- Customize CMake
8720

@@ -91,11 +24,23 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
9124
# Find whether the GMP package exists.
9225
find_package(GMP REQUIRED)
9326

94-
# Configure and build PLUTO to ${CMAKE_BUILD_DIR}/pluto
27+
# build pluto, openscop, cloog
28+
execute_process(
29+
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/build_polymer_deps.sh" "${POLYGEIST_PLUTO_DIR}"
30+
COMMAND_ERROR_IS_FATAL ANY
31+
)
32+
# configure the cmake variables for pluto
9533
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddPluto.cmake")
9634
include_directories("${PLUTO_INCLUDE_DIR}")
9735
message(STATUS "Will build and use Polymer-bundled Pluto")
9836

37+
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/OpenScop.cmake")
38+
include_directories("${OSL_INCLUDE_DIR}")
39+
40+
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CLooG.cmake")
41+
include_directories("${CLOOG_INCLUDE_DIR}")
42+
43+
9944
# ------------------------------------------------- This project
10045
include_directories("${POLYMER_MAIN_INCLUDE_DIR}")
10146
include_directories("${POLYMER_INCLUDE_DIR}")
@@ -111,7 +56,7 @@ add_subdirectory(tools)
11156
add_subdirectory(test)
11257

11358
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
114-
install(DIRECTORY include/polymer
59+
install(DIRECTORY include/polymer
11560
DESTINATION include
11661
FILES_MATCHING
11762
PATTERN "*.h"

0 commit comments

Comments
 (0)