Skip to content

Commit 7bdab48

Browse files
committed
fix l0 loader version
Signed-off-by: Mateusz P. Nowak <[email protected]>
1 parent a0c26b3 commit 7bdab48

File tree

3 files changed

+134
-26
lines changed

3 files changed

+134
-26
lines changed

devops/dependencies.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"root": "{DEPS_ROOT}/opencl/runtime/linux/oclgpu"
2020
},
2121
"level_zero": {
22-
"github_tag": "v1.24.2",
22+
"github_commit": "5187acd1c0f34097658f6ed890f1e5a65bdc35b9",
2323
"version": "v1.24.2",
24-
"url": "https://github.com/oneapi-src/level-zero/releases/tag/v1.24.2",
24+
"url": "https://github.com/oneapi-src/level-zero/commit/5187acd1c0f34097658f6ed890f1e5a65bdc35b9",
2525
"root": "{DEPS_ROOT}/opencl/runtime/linux/oclgpu"
2626
},
2727
"tbb": {
@@ -56,4 +56,4 @@
5656
"root": "{DEPS_ROOT}/opencl/runtime/linux/oclcpu"
5757
}
5858
}
59-
}
59+
}

devops/scripts/install_drivers.sh

Lines changed: 112 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if [ -f "$1" ]; then
1010
CR_TAG=$(jq -r '.linux.compute_runtime.github_tag' $CONFIG_FILE)
1111
IGC_TAG=$(jq -r '.linux.igc.github_tag' $CONFIG_FILE)
1212
CM_TAG=$(jq -r '.linux.cm.github_tag' $CONFIG_FILE)
13-
L0_TAG=$(jq -r '.linux.level_zero.github_tag' $CONFIG_FILE)
13+
L0_TAG=$(jq -r '.linux.level_zero.github_tag // .linux.level_zero.github_commit' $CONFIG_FILE)
1414
TBB_TAG=$(jq -r '.linux.tbb.github_tag' $CONFIG_FILE)
1515
FPGA_TAG=$(jq -r '.linux.fpgaemu.github_tag' $CONFIG_FILE)
1616
CPU_TAG=$(jq -r '.linux.oclcpu.github_tag' $CONFIG_FILE)
@@ -56,6 +56,94 @@ function get_pre_release_igfx() {
5656
unzip $HASH.zip && rm $HASH.zip
5757
}
5858

59+
function get_commit_artifacts() {
60+
REPO=$1
61+
COMMIT=$2
62+
HEADER=""
63+
if [ "$GITHUB_TOKEN" != "" ]; then
64+
HEADER="Authorization: Bearer $GITHUB_TOKEN"
65+
fi
66+
# Get artifacts from GitHub Actions for the specific commit
67+
curl -s -L -H "$HEADER" -H "Accept: application/vnd.github.v3+json" \
68+
"https://api.github.com/repos/${REPO}/actions/runs?head_sha=${COMMIT}&status=completed&per_page=1" \
69+
| jq -r '.workflow_runs[0] | select(.conclusion == "success") | .id' \
70+
| head -1 \
71+
| xargs -I {} curl -s -L -H "$HEADER" -H "Accept: application/vnd.github.v3+json" \
72+
"https://api.github.com/repos/${REPO}/actions/runs/{}/artifacts" \
73+
| jq -r '.artifacts[] | select(.name | test(".*deb.*")) | .archive_download_url'
74+
}
75+
76+
function download_commit_artifacts() {
77+
REPO=$1
78+
COMMIT=$2
79+
UBUNTU_VER=$3
80+
HEADER=""
81+
if [ "$GITHUB_TOKEN" != "" ]; then
82+
HEADER="Authorization: Bearer $GITHUB_TOKEN"
83+
fi
84+
85+
echo "Downloading artifacts for commit $COMMIT from $REPO"
86+
get_commit_artifacts $REPO $COMMIT | while read -r artifact_url; do
87+
if [ -n "$artifact_url" ]; then
88+
echo "Downloading artifact: $artifact_url"
89+
curl -L -H "$HEADER" "$artifact_url" -o "artifact-$(basename $artifact_url).zip"
90+
unzip -j "artifact-$(basename $artifact_url).zip" "*.deb" 2>/dev/null || true
91+
rm "artifact-$(basename $artifact_url).zip"
92+
fi
93+
done
94+
}
95+
96+
function build_level_zero_from_source() {
97+
COMMIT=$1
98+
99+
echo "Building Level Zero from source at commit $COMMIT"
100+
101+
# Create temporary build directory
102+
BUILD_DIR="/tmp/level-zero-build"
103+
INSTALL_DIR="/tmp/level-zero-install"
104+
rm -rf $BUILD_DIR $INSTALL_DIR
105+
mkdir -p $BUILD_DIR $INSTALL_DIR
106+
cd $BUILD_DIR
107+
108+
# Clone and checkout specific commit
109+
echo "Cloning Level Zero repository..."
110+
git clone https://github.com/oneapi-src/level-zero.git
111+
cd level-zero
112+
git checkout $COMMIT
113+
114+
# Create build directory
115+
mkdir build
116+
cd build
117+
118+
# Configure build
119+
echo "Configuring Level Zero build..."
120+
cmake .. \
121+
-DCMAKE_BUILD_TYPE=Release \
122+
-DCMAKE_INSTALL_PREFIX=/usr/local \
123+
-DLEVEL_ZERO_BUILD_TESTS=OFF \
124+
-DLEVEL_ZERO_BUILD_SAMPLES=OFF
125+
126+
# Build
127+
echo "Building Level Zero..."
128+
make -j$(nproc)
129+
130+
# Staged install (doesn't affect system)
131+
echo "Creating staged installation..."
132+
make install DESTDIR=$INSTALL_DIR
133+
134+
# Copy files to their final destinations
135+
echo "Installing Level Zero to system..."
136+
cp -r $INSTALL_DIR/usr/local/* /usr/local/
137+
138+
# Update library cache
139+
ldconfig
140+
141+
# Clean up build and install directories
142+
rm -rf $BUILD_DIR $INSTALL_DIR
143+
144+
echo "Level Zero built and installed successfully from commit $COMMIT"
145+
}
146+
59147
TBB_INSTALLED=false
60148

61149
if [[ -v INSTALL_LOCATION ]]; then
@@ -96,6 +184,16 @@ CheckIGCdevTag() {
96184
fi
97185
}
98186

187+
CheckIfCommitHash() {
188+
local arg="$1"
189+
# Check if it's a 40-character hex string (SHA-1 commit hash)
190+
if [[ $arg =~ ^[a-f0-9]{40}$ ]]; then
191+
echo "Yes"
192+
else
193+
echo "No"
194+
fi
195+
}
196+
99197
InstallIGFX () {
100198
echo "Installing Intel Graphics driver..."
101199
echo "Compute Runtime version $CR_TAG"
@@ -122,9 +220,19 @@ InstallIGFX () {
122220
| grep ".*deb" \
123221
| grep -v "u18" \
124222
| wget -qi -
125-
get_release oneapi-src/level-zero $L0_TAG \
126-
| grep ".*$UBUNTU_VER.*deb$" \
127-
| wget -qi -
223+
224+
# Check if L0_TAG is a commit hash or a regular tag
225+
IS_L0_COMMIT=$(CheckIfCommitHash $L0_TAG)
226+
if [ "$IS_L0_COMMIT" == "Yes" ]; then
227+
echo "Level Zero is using commit hash, building from source..."
228+
build_level_zero_from_source $L0_TAG
229+
# Install other packages (Level Zero was already installed from source)
230+
dpkg -i --force-all *.deb && rm *.deb *.sum
231+
else
232+
get_release oneapi-src/level-zero $L0_TAG \
233+
| grep ".*$UBUNTU_VER.*deb$" \
234+
| wget -qi -
235+
fi
128236
dpkg -i --force-all *.deb && rm *.deb *.sum
129237
mkdir -p /usr/local/lib/igc/
130238
echo "$IGC_TAG" > /usr/local/lib/igc/IGCTAG.txt

unified-runtime/cmake/FetchLevelZero.cmake

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ find_package(PkgConfig QUIET)
1212
# LevelZero doesn't install a CMake config target, just PkgConfig,
1313
# so try using that to find the install and if it's not available
1414
# just try to search for the path.
15-
if(PkgConfig_FOUND)
16-
pkg_check_modules(level-zero level-zero>=1.24.3)
17-
if(level-zero_FOUND)
18-
set(LEVEL_ZERO_INCLUDE_DIR "${level-zero_INCLUDEDIR}/level_zero")
19-
set(LEVEL_ZERO_LIBRARY_SRC "${level-zero_LIBDIR}")
20-
set(LEVEL_ZERO_LIB_NAME "${level-zero_LIBRARIES}")
21-
message(STATUS "Level Zero Adapter: Using preinstalled level zero loader at ${level-zero_LINK_LIBRARIES}")
22-
endif()
23-
else()
24-
set(L0_HEADER_PATH "loader/ze_loader.h")
25-
find_path(L0_HEADER ${L0_HEADER_PATH} ${CMAKE_PREFIX_PATH} PATH_SUFFIXES "level_zero")
26-
find_library(ZE_LOADER NAMES ze_loader HINTS /usr ${CMAKE_PREFIX_PATH})
27-
if(L0_HEADER AND ZE_LOADER)
28-
set(LEVEL_ZERO_INCLUDE_DIR "${L0_HEADER}")
29-
set(LEVEL_ZERO_LIBRARY "${ZE_LOADER}")
30-
message(STATUS "Level Zero Adapter: Using preinstalled level zero loader at ${LEVEL_ZERO_LIBRARY}")
31-
add_library(ze_loader INTERFACE)
32-
endif()
33-
endif()
15+
# if(PkgConfig_FOUND)
16+
# pkg_check_modules(level-zero level-zero>1.24.3)
17+
# if(level-zero_FOUND)
18+
# set(LEVEL_ZERO_INCLUDE_DIR "${level-zero_INCLUDEDIR}/level_zero")
19+
# set(LEVEL_ZERO_LIBRARY_SRC "${level-zero_LIBDIR}")
20+
# set(LEVEL_ZERO_LIB_NAME "${level-zero_LIBRARIES}")
21+
# message(STATUS "Level Zero Adapter: Using preinstalled level zero loader at ${level-zero_LINK_LIBRARIES}")
22+
# endif()
23+
# else()
24+
# set(L0_HEADER_PATH "loader/ze_loader.h")
25+
# find_path(L0_HEADER ${L0_HEADER_PATH} ${CMAKE_PREFIX_PATH} PATH_SUFFIXES "level_zero")
26+
# find_library(ZE_LOADER NAMES ze_loader HINTS /usr ${CMAKE_PREFIX_PATH})
27+
# if(L0_HEADER AND ZE_LOADER)
28+
# set(LEVEL_ZERO_INCLUDE_DIR "${L0_HEADER}")
29+
# set(LEVEL_ZERO_LIBRARY "${ZE_LOADER}")
30+
# message(STATUS "Level Zero Adapter: Using preinstalled level zero loader at ${LEVEL_ZERO_LIBRARY}")
31+
# add_library(ze_loader INTERFACE)
32+
# endif()
33+
# endif()
3434

3535
if(NOT LEVEL_ZERO_LIB_NAME AND NOT LEVEL_ZERO_LIBRARY)
3636
message(STATUS "Level Zero Adapter: Download Level Zero loader and headers from github.com")

0 commit comments

Comments
 (0)