Skip to content

Commit

Permalink
Vendor sleef as a submodule (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
int3 authored and ienkovich committed Dec 6, 2024
1 parent 77fcb05 commit 6b2cd51
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Python ${{ matrix.python }}
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ python/triton*.egg-info/

python/triton/_C/*.pyd
python/triton/_C/*.so
python/triton/_C/*.so.*
python/triton/_C/*.dylib
python/triton/_C/*.pdb
python/triton/_C/*.exe
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "sleef"]
path = third_party/sleef
url = https://github.com/shibatch/sleef
13 changes: 12 additions & 1 deletion third_party/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,16 @@ add_subdirectory(lib)
if(TRITON_BUILD_PYTHON_MODULE)
add_triton_plugin(TritonCPU ${CMAKE_CURRENT_SOURCE_DIR}/triton_cpu.cc LINK_LIBS TritonCPUToLLVM TritonCPUTransforms)
target_link_libraries(TritonCPU PUBLIC MLIRVectorToSCF MLIRAffineToStandard MLIRMathToLibm)
add_library(TritonCPURuntime SHARED ${CMAKE_CURRENT_SOURCE_DIR}/runtime/cpu_runtime.cpp)
endif()

add_library(TritonCPURuntime SHARED ${CMAKE_CURRENT_SOURCE_DIR}/runtime/cpu_runtime.cpp)

# Build and link sleef
set(SLEEF_BUILD_SHARED_LIBS ON CACHE BOOL "Build sleef shared lib" FORCE)
set(SLEEF_BUILD_DFT OFF CACHE BOOL "Don't build sleef DFT lib" FORCE)
set(SLEEF_BUILD_GNUABI_LIBS OFF CACHE BOOL "Don't build sleef gnuabi libs" FORCE)
set(SLEEF_BUILD_TESTS OFF CACHE BOOL "Don't build sleef tests" FORCE)
set(SLEEF_BUILD_SCALAR_LIB OFF CACHE BOOL "libsleefscalar will not be built." FORCE)
add_subdirectory("${CMAKE_SOURCE_DIR}/third_party/sleef" sleef)
# Override sleef's output directory with our own
set_target_properties(sleef PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
9 changes: 1 addition & 8 deletions third_party/cpu/backend/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,7 @@ def make_so(src, metadata, options):
asm_path = os.path.join(tmpdir, "kernel.s")
Path(asm_path).write_text(src)
lib_dirs = cpu_driver.library_dirs
libs = ["gcc", "m", "TritonCPURuntime"]
# TRITON_CPU_USE_SLEEF=1 - use system libsleef
# TRITON_CPU_USE_SLEEF=path - use libsleef from the specified path
use_sleef = os.environ.get("TRITON_CPU_USE_SLEEF", "0")
if use_sleef != "0":
if os.path.isdir(use_sleef):
lib_dirs.append(use_sleef)
libs.append("sleef")
libs = ["gcc", "m", "TritonCPURuntime", "sleef"]
so = _build("kernel", asm_path, tmpdir, lib_dirs, cpu_driver.include_dirs, libs)
with open(so, "rb") as f:
return f.read()
Expand Down
1 change: 1 addition & 0 deletions third_party/sleef
Submodule sleef added at 93f04d

0 comments on commit 6b2cd51

Please sign in to comment.