Skip to content

Commit 351408a

Browse files
author
quintinwang5
authored
[BUILD]: update build file to download different LLVM binary for different OS (#78)
* [BUILD]: update build file to download different LLVM binary for specific OS * check LLVM_Base/lib/cmake instead of LLLVM_Base in case the directory is empty
1 parent 237b061 commit 351408a

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

CMakeLists.txt

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ MESSAGE(STATUS "[intel_xpu_backend]: using intel_llvm")
1010

1111
SET(TRITON_INTEL_LLVM_DIR $ENV{HOME}/.triton/intel_llvm)
1212
MESSAGE(STATUS "[intel_xpu_backend]: set intel llvm path ${TRITON_INTEL_LLVM_DIR}")
13-
if (EXISTS ${TRITON_INTEL_LLVM_DIR})
13+
if (EXISTS ${TRITON_INTEL_LLVM_DIR}/lib/cmake)
1414
MESSAGE(STATUS "[intel_xpu_backend]: using previous exists llvm")
1515
else()
1616
include(FetchContent)
1717
function(download_file url)
18-
18+
cmake_policy(SET CMP0135 NEW)
1919
FetchContent_Declare(intel-llvm
2020
URL ${url}
2121
SOURCE_DIR ${TRITON_INTEL_LLVM_DIR}
@@ -24,13 +24,40 @@ SOURCE_DIR ${TRITON_INTEL_LLVM_DIR}
2424
FetchContent_Populate(intel-llvm)
2525
endfunction(download_file)
2626

27+
set(LLVM_DOWNLOAD_URL https://github.com/intel/intel-xpu-backend-for-triton/releases/download/llvm_pkg_v0.1/llvm+mlir-17.0.0-x86_64-linux-gnu-ubuntu-18.04-release.tar.xz)
28+
set(OS_INFO_FILE "/etc/os-release")
2729
MESSAGE(STATUS "[intel_xpu_backend]: downloading intel llvm for intel_xpu_backend, path ${TRITON_INTEL_LLVM_DIR}")
28-
download_file(
29-
https://github.com/intel/intel-xpu-backend-for-triton/releases/download/llvm_pkg_v0.1/llvm+mlir-17.0.0-x86_64-linux-gnu-ubuntu-22.04-release.tar.xz
30-
)
30+
if(EXISTS ${OS_INFO_FILE})
31+
file(STRINGS ${OS_INFO_FILE} OS_INFO_KEY_LIST REGEX "^(ID|VERSION_ID)")
32+
set(OS_ID "")
33+
set(OS_VERSION_ID "")
34+
foreach(_os_info ${OS_INFO_KEY_LIST})
35+
if("${_os_info}" MATCHES "^(ID)=(.*)$")
36+
string(TOLOWER "${CMAKE_MATCH_2}" OS_ID)
37+
elseif("${_os_info}" MATCHES "(VERSION_ID)=(.*)$")
38+
string(TOLOWER "${CMAKE_MATCH_2}" OS_VERSION_ID)
39+
string(REGEX REPLACE "^\"(.*)\"$" "\\1" OS_VERSION_ID "${OS_VERSION_ID}")
40+
endif()
41+
endforeach()
42+
43+
if("${OS_ID}" STREQUAL "ubuntu")
44+
if("${OS_VERSION_ID}" STREQUAL "22.04")
45+
set(LLVM_DOWNLOAD_URL https://github.com/intel/intel-xpu-backend-for-triton/releases/download/llvm_pkg_v0.1/llvm+mlir-17.0.0-x86_64-linux-gnu-ubuntu-22.04-release.tar.xz)
46+
MESSAGE(STATUS "[intel_xpu_backend]: downloading intel llvm for ${OS_ID} ${OS_VERSION_ID}")
47+
endif()
48+
elseif("${OS_ID}" STREQUAL "centos")
49+
if("${OS_VERSION_ID}" STREQUAL "7")
50+
set(LLVM_DOWNLOAD_URL https://github.com/intel/intel-xpu-backend-for-triton/releases/download/llvm_pkg_v0.1/llvm+mlir-17.0.0-x86_64-linux-gnu-centos-7-release.tar.xz)
51+
MESSAGE(STATUS "[intel_xpu_backend]: downloading intel llvm for ${OS_ID} ${OS_VERSION_ID}")
52+
endif()
53+
endif()
54+
endif()
55+
56+
MESSAGE(STATUS "[intel_xpu_backend]: downloading intel llvm from ${LLVM_DOWNLOAD_URL}")
57+
download_file(${LLVM_DOWNLOAD_URL})
3158
endif()
32-
MESSAGE(STATUS "[intel_xpu_backend]:Triton uses LLVM version ${LLVM_PACKAGE_VERSION} with revision ${LLVM_GIT_REVISION}")
33-
MESSAGE(STATUS "[intel_xpu_backend]:Use the LLVM version with revision to re-config for the intel_xpu_backend")
59+
MESSAGE(STATUS "[intel_xpu_backend]: Triton uses LLVM version ${LLVM_PACKAGE_VERSION} with revision ${LLVM_GIT_REVISION}")
60+
MESSAGE(STATUS "[intel_xpu_backend]: Use the LLVM version with revision to re-config for the intel_xpu_backend")
3461

3562
# hints from https://stackoverflow.com/questions/10205986/how-to-capture-cmake-command-line-arguments
3663
# Propagate the CMake vars to the intel xpu backend

0 commit comments

Comments
 (0)