Skip to content

Commit 61be142

Browse files
committed
[eudsl-tile] Start
1 parent 549fd26 commit 61be142

3 files changed

Lines changed: 297 additions & 0 deletions

File tree

.github/workflows/build_test_release_eudsl.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ on:
3939
- "projects/eudsl-nbgen/**"
4040
- "projects/eudsl-py/**"
4141
- "projects/eudsl-llvmpy/**"
42+
- "projects/eudsl-tile/**"
4243
push:
4344
branches:
4445
- main
@@ -48,6 +49,7 @@ on:
4849
- "projects/eudsl-nbgen/**"
4950
- "projects/eudsl-py/**"
5051
- "projects/eudsl-llvmpy/**"
52+
- "projects/eudsl-tile/**"
5153

5254
concurrency:
5355
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}-build_test_release_eudsl
@@ -110,6 +112,11 @@ jobs:
110112
os: ${{ matrix.os }}
111113
host-arch: ${{ matrix.host-arch }}
112114
target-arch: ${{ matrix.target-arch }}
115+
116+
- name: "Which files changed"
117+
run: |
118+
119+
echo '${{ toJSON(github.event.commits[0].modified[*]) }}' | jq
113120
114121
- name: "Pip download MLIR from releases"
115122
if: ${{ !inputs.workflow_call }}
@@ -221,6 +228,11 @@ jobs:
221228
-DPython3_EXECUTABLE=$(which $python3_command)
222229
cmake --build "$PWD/eudsl-build" --target install
223230
231+
- name: "Build eudsl-tile"
232+
run: |
233+
234+
$python3_command -m cibuildwheel "$PWD/projects/mlir-python-bindings" --output-dir wheelhouse
235+
224236
- name: "Save cache"
225237
uses: actions/cache/save@v3
226238
if: (!cancelled() && github.event_name == 'push' && github.ref_name == 'main')

projects/eudsl-tile/CMakeLists.txt

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
# Copyright (c) 2025.
5+
6+
cmake_minimum_required(VERSION 3.29)
7+
project(eudsl-tile LANGUAGES CXX C)
8+
9+
set(CMAKE_CXX_STANDARD 17)
10+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
11+
set(CMAKE_CXX_EXTENSIONS OFF)
12+
13+
if(POLICY CMP0068)
14+
cmake_policy(SET CMP0068 NEW)
15+
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
16+
endif()
17+
18+
if(POLICY CMP0075)
19+
cmake_policy(SET CMP0075 NEW)
20+
endif()
21+
22+
if(POLICY CMP0077)
23+
cmake_policy(SET CMP0077 NEW)
24+
endif()
25+
26+
if(POLICY CMP0091)
27+
cmake_policy(SET CMP0091 NEW)
28+
endif()
29+
30+
if(POLICY CMP0116)
31+
cmake_policy(SET CMP0116 NEW)
32+
endif()
33+
34+
if(POLICY CMP0135)
35+
cmake_policy(SET CMP0116 OLD)
36+
endif()
37+
38+
if(MSVC OR WIN32)
39+
add_compile_options(
40+
$<$<CONFIG:>:/MT> # ---------|
41+
$<$<CONFIG:Debug>:/MTd> # ---|-- Statically link the runtime libraries
42+
$<$<CONFIG:Release>:/MT> # --|
43+
)
44+
endif()
45+
46+
set(CMAKE_C_VISIBILITY_PRESET "hidden")
47+
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
48+
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
49+
50+
find_package(MLIR REQUIRED CONFIG)
51+
52+
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
53+
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
54+
55+
set(MLIR_BINDINGS_PYTHON_NB_DOMAIN "eudsl_tile" CACHE STRING "")
56+
set(MLIR_PYTHON_PACKAGE_PREFIX "eudsl_tile" CACHE STRING "")
57+
58+
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/bin)
59+
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/lib)
60+
61+
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
62+
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
63+
include(TableGen)
64+
include(AddLLVM)
65+
include(AddMLIR)
66+
include(AddMLIRPython)
67+
include(MLIRDetectPythonEnv)
68+
include(HandleLLVMOptions)
69+
70+
include_directories(${LLVM_INCLUDE_DIRS})
71+
include_directories(${MLIR_INCLUDE_DIRS})
72+
link_directories(${LLVM_BUILD_LIBRARY_DIR})
73+
add_definitions(${LLVM_DEFINITIONS})
74+
75+
add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=${MLIR_PYTHON_PACKAGE_PREFIX}.")
76+
77+
mlir_configure_python_dev_packages()
78+
79+
add_mlir_python_common_capi_library(EUDSLTilePythonCAPI
80+
INSTALL_COMPONENT EUDSLTilePythonModules
81+
INSTALL_DESTINATION eudsl_tile/_mlir_libs
82+
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/eudsl_tile/_mlir_libs"
83+
RELATIVE_INSTALL_ROOT "../../../.."
84+
DECLARED_SOURCES
85+
# this needs to be here so that _mlir is linked against the CAPI
86+
MLIRPythonSources.Core
87+
# we register everything even though we don't use all the dialects
88+
# because currently RegisterEverything isn't factored (and probably won't ever be...)
89+
MLIRPythonExtension.RegisterEverything
90+
)
91+
92+
# ##############################################################################
93+
# The fully assembled package of modules. This must come last.
94+
# ##############################################################################
95+
96+
set(_declared_sources
97+
MLIRPythonExtension.RegisterEverything
98+
# not MLIRPythonExtension.Core, which doesn't depend on MLIRPythonSupport and etc.
99+
MLIRPythonSources.Core
100+
# other extensions
101+
MLIRPythonExtension.Dialects.GPU.Nanobind
102+
MLIRPythonExtension.Dialects.LLVM.Nanobind
103+
MLIRPythonExtension.Dialects.Linalg.Nanobind
104+
MLIRPythonExtension.Dialects.Transform.Nanobind
105+
MLIRPythonExtension.ExecutionEngine
106+
MLIRPythonExtension.GPUDialectPasses
107+
MLIRPythonExtension.LinalgPasses
108+
MLIRPythonExtension.TransformInterpreter
109+
# dialects
110+
MLIRPythonSources.Dialects.arith
111+
MLIRPythonSources.Dialects.bufferization
112+
MLIRPythonSources.Dialects.bufferization_transform
113+
MLIRPythonSources.Dialects.builtin
114+
MLIRPythonSources.Dialects.cf
115+
MLIRPythonSources.Dialects.func
116+
MLIRPythonSources.Dialects.gpu
117+
MLIRPythonSources.Dialects.gpu_transform
118+
MLIRPythonSources.Dialects.index
119+
MLIRPythonSources.Dialects.linalg
120+
MLIRPythonSources.Dialects.llvm
121+
MLIRPythonSources.Dialects.math
122+
MLIRPythonSources.Dialects.memref
123+
MLIRPythonSources.Dialects.memref_transform
124+
MLIRPythonSources.Dialects.scf
125+
MLIRPythonSources.Dialects.spirv
126+
MLIRPythonSources.Dialects.tensor
127+
MLIRPythonSources.Dialects.tensor_transform
128+
MLIRPythonSources.Dialects.transform
129+
MLIRPythonSources.Dialects.transform.extras
130+
MLIRPythonSources.Dialects.transform.interpreter
131+
MLIRPythonSources.Dialects.vector
132+
MLIRPythonSources.Dialects.vector_transform
133+
# other sources
134+
MLIRPythonSources.ExecutionEngine
135+
)
136+
if(NOT CMAKE_CROSSCOMPILING)
137+
list(APPEND _declared_sources MLIRPythonExtension.Core.type_stub_gen)
138+
endif()
139+
140+
add_mlir_python_modules(EUDSLTilePythonModules
141+
ROOT_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/eudsl_tile"
142+
INSTALL_PREFIX "eudsl_tile"
143+
MLIR_BINDINGS_PYTHON_NB_DOMAIN ${MLIR_BINDINGS_PYTHON_NB_DOMAIN}
144+
DECLARED_SOURCES
145+
${_declared_sources}
146+
COMMON_CAPI_LINK_LIBS
147+
EUDSLTilePythonCAPI
148+
)
149+
150+
set(_runtimes
151+
mlir_async_runtime
152+
mlir_c_runner_utils
153+
mlir_float16_utils
154+
mlir_runner_utils
155+
)
156+
157+
if (TARGET mlir_apfloat_wrappers)
158+
list(APPEND _runtimes mlir_apfloat_wrappers)
159+
endif()
160+
161+
if (TARGET mlir_rocm_runtime)
162+
list(APPEND _runtimes mlir_rocm_runtime)
163+
endif()
164+
165+
if (TARGET mlir_cuda_runtime)
166+
list(APPEND _runtimes mlir_cuda_runtime)
167+
endif()
168+
169+
if (TARGET omp)
170+
list(APPEND _runtimes omp)
171+
endif()
172+
173+
if (TARGET vulkan-runtime-wrappers)
174+
list(APPEND _runtimes vulkan-runtime-wrappers)
175+
endif()
176+
177+
foreach(r ${_runtimes})
178+
add_custom_command(
179+
TARGET EUDSLTilePythonModules
180+
PRE_BUILD
181+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${r}>
182+
${CMAKE_CURRENT_BINARY_DIR}/eudsl_tile/_mlir_libs)
183+
endforeach()
184+
185+
install(
186+
IMPORTED_RUNTIME_ARTIFACTS ${_runtimes}
187+
LIBRARY DESTINATION "eudsl_tile/_mlir_libs"
188+
COMPONENT EUDSLTilePythonModules
189+
)

projects/eudsl-tile/pyproject.toml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
# Copyright (c) 2025.
5+
6+
[project]
7+
name = "eudsl-tile"
8+
version = "0.0.1"
9+
requires-python = ">=3.8"
10+
dependencies = [
11+
"numpy>=1.19.5",
12+
"PyYAML>=5.4.0, <=6.0.1",
13+
"ml_dtypes>=0.1.0, <=0.6.0; python_version<'3.13'",
14+
"ml_dtypes>=0.5.0, <=0.6.0; python_version>='3.13'",
15+
]
16+
17+
[project.urls]
18+
Homepage = "https://github.com/llvm/eudsl"
19+
Discussions = "https://discourse.llvm.org/"
20+
"Issue Tracker" = "https://github.com/llvm/eudsl/issues"
21+
"Source Code" = "https://github.com/llvm/eudsl/tree/main/"
22+
23+
[build-system]
24+
requires = [
25+
"scikit-build-core>=0.10.7",
26+
"typing_extensions>=4.12.2",
27+
"nanobind>=2.9, <3.0",
28+
"numpy>=1.19.5, <=2.3.0",
29+
]
30+
build-backend = "scikit_build_core.build"
31+
32+
[tool.scikit-build]
33+
# This is the minimum version of scikit-build-core.
34+
minimum-version = "0.10.7"
35+
# This pyproject.toml must be adjacent to the root CMakeLists.txt (wherever project(...) is specified).
36+
cmake.source-dir = "."
37+
# This is for installing/distributing the python bindings target and only the python bindings target.
38+
build.targets = ["EUDSLTilePythonModules"]
39+
install.components = ["EUDSLTilePythonModules"]
40+
41+
[tool.scikit-build.cmake.define]
42+
# Optional
43+
CMAKE_C_COMPILER = { env = "CMAKE_C_COMPILER", default = "" }
44+
CMAKE_CXX_COMPILER = { env = "CMAKE_CXX_COMPILER", default = "" }
45+
CMAKE_C_COMPILER_LAUNCHER = { env = "CMAKE_C_COMPILER_LAUNCHER", default = "" }
46+
CMAKE_CXX_COMPILER_LAUNCHER = { env = "CMAKE_CXX_COMPILER_LAUNCHER", default = "" }
47+
CMAKE_GENERATOR = { env = "CMAKE_GENERATOR", default = "Ninja" }
48+
CMAKE_PLATFORM_NO_VERSIONED_SONAME = "ON"
49+
CMAKE_MSVC_RUNTIME_LIBRARY = "MultiThreaded"
50+
CMAKE_C_FLAGS = { env = "CMAKE_C_FLAGS", default = "" }
51+
CMAKE_CXX_FLAGS = { env = "CMAKE_CXX_FLAGS", default = "" }
52+
LLVM_USE_LINKER = { env = "LLVM_USE_LINKER", default = "" }
53+
# Optional but highly recommended (this makes the bindings compatible with other bindings packages
54+
# by preventing symbol collisions).
55+
CMAKE_VISIBILITY_INLINES_HIDDEN = "ON"
56+
CMAKE_C_VISIBILITY_PRESET = "hidden"
57+
CMAKE_CXX_VISIBILITY_PRESET = "hidden"
58+
59+
MLIR_DIR = { env = "MLIR_DIR", default = "" }
60+
CMAKE_PREFIX_PATH = { env = "CMAKE_PREFIX_PATH", default = "" }
61+
# Non-optional
62+
CMAKE_BUILD_TYPE = { env = "CMAKE_BUILD_TYPE", default = "Release" }
63+
MLIR_ENABLE_BINDINGS_PYTHON = "ON"
64+
MLIR_BINDINGS_PYTHON_NB_DOMAIN = "eudsl_tile"
65+
66+
[tool.cibuildwheel]
67+
enable = "cpython-prerelease cpython-freethreading"
68+
build-verbosity = 3
69+
manylinux-aarch64-image = "quay.io/pypa/manylinux_2_34_aarch64"
70+
manylinux-x86_64-image = "quay.io/pypa/manylinux_2_34_x86_64"
71+
archs = ["native"]
72+
73+
[tool.cibuildwheel.linux]
74+
build = "cp310-* cp311-* cp312-* cp313-* cp314-* cp314t-*"
75+
skip = ["*-manylinux_i686", "*-musllinux*"]
76+
environment-pass = [
77+
"CMAKE_CXX_FLAGS",
78+
"CMAKE_C_FLAGS",
79+
"CMAKE_PREFIX_PATH",
80+
"MLIR_DIR",
81+
"WHEEL_VERSION",
82+
]
83+
repair-wheel-command = [
84+
"LD_LIBRARY_PATH=$CMAKE_PREFIX_PATH/lib auditwheel repair -w {dest_dir} {wheel}",
85+
]
86+
87+
[tool.cibuildwheel.macos]
88+
build = "cp310-* cp311-* cp312-* cp313-* cp314-* cp314t-*"
89+
repair-wheel-command = [
90+
"DYLD_LIBRARY_PATH=$CMAKE_PREFIX_PATH/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
91+
]
92+
93+
[tool.cibuildwheel.windows]
94+
build = "cp310-* cp311-* cp312-* cp313-* cp314-* cp314t-*"
95+
skip = ["*-win32"]
96+
# repair-wheel-command = "delvewheel repair -v -w {dest_dir} {wheel}"

0 commit comments

Comments
 (0)