Skip to content

Commit 077dbae

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

File tree

4 files changed

+256
-42
lines changed

4 files changed

+256
-42
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: 232 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
2+
# UPDATED FOR LEVEL-ZERO COMMIT BUILD - $(date)
33
set -e
44
set -x
55
set -o pipefail
@@ -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)
@@ -48,12 +48,162 @@ function get_release() {
4848
function get_pre_release_igfx() {
4949
URL=$1
5050
HASH=$2
51+
echo "*** USING UPDATED get_pre_release_igfx FUNCTION - COMMIT: $(date) ***"
5152
HEADER=""
5253
if [ "$GITHUB_TOKEN" != "" ]; then
5354
HEADER="Authorization: Bearer $GITHUB_TOKEN"
5455
fi
55-
curl -L -H "$HEADER" -H "Accept: application/vnd.github.v3+json" $URL -o $HASH.zip
56-
unzip $HASH.zip && rm $HASH.zip
56+
57+
# Ensure we're in a writable directory
58+
WORK_DIR="/tmp/igc-download"
59+
mkdir -p "$WORK_DIR"
60+
cd "$WORK_DIR"
61+
62+
echo "=== NEW IGC DOWNLOAD FUNCTION - Downloading IGC dev package to $WORK_DIR ==="
63+
if ! curl -L -H "$HEADER" -H "Accept: application/vnd.github.v3+json" "$URL" -o "$HASH.zip"; then
64+
echo "ERROR: Failed to download IGC dev package"
65+
return 1
66+
fi
67+
68+
if [ ! -f "$HASH.zip" ]; then
69+
echo "ERROR: Downloaded file $HASH.zip not found"
70+
return 1
71+
fi
72+
73+
echo "Extracting IGC dev package"
74+
if ! unzip "$HASH.zip"; then
75+
echo "ERROR: Failed to extract $HASH.zip"
76+
return 1
77+
fi
78+
79+
rm "$HASH.zip"
80+
81+
# Move deb files back to the calling directory if any exist
82+
if ls *.deb 1> /dev/null 2>&1; then
83+
mv *.deb /tmp/
84+
cd /tmp/
85+
fi
86+
87+
# Clean up work directory
88+
rm -rf "$WORK_DIR"
89+
}
90+
91+
function get_commit_artifacts() {
92+
REPO=$1
93+
COMMIT=$2
94+
HEADER=""
95+
if [ "$GITHUB_TOKEN" != "" ]; then
96+
HEADER="Authorization: Bearer $GITHUB_TOKEN"
97+
fi
98+
# Get artifacts from GitHub Actions for the specific commit
99+
curl -s -L -H "$HEADER" -H "Accept: application/vnd.github.v3+json" \
100+
"https://api.github.com/repos/${REPO}/actions/runs?head_sha=${COMMIT}&status=completed&per_page=1" \
101+
| jq -r '.workflow_runs[0] | select(.conclusion == "success") | .id' \
102+
| head -1 \
103+
| xargs -I {} curl -s -L -H "$HEADER" -H "Accept: application/vnd.github.v3+json" \
104+
"https://api.github.com/repos/${REPO}/actions/runs/{}/artifacts" \
105+
| jq -r '.artifacts[] | select(.name | test(".*deb.*")) | .archive_download_url'
106+
}
107+
108+
function download_commit_artifacts() {
109+
REPO=$1
110+
COMMIT=$2
111+
UBUNTU_VER=$3
112+
HEADER=""
113+
if [ "$GITHUB_TOKEN" != "" ]; then
114+
HEADER="Authorization: Bearer $GITHUB_TOKEN"
115+
fi
116+
117+
echo "Downloading artifacts for commit $COMMIT from $REPO"
118+
get_commit_artifacts $REPO $COMMIT | while read -r artifact_url; do
119+
if [ -n "$artifact_url" ]; then
120+
echo "Downloading artifact: $artifact_url"
121+
curl -L -H "$HEADER" "$artifact_url" -o "artifact-$(basename $artifact_url).zip"
122+
unzip -j "artifact-$(basename $artifact_url).zip" "*.deb" 2>/dev/null || true
123+
rm "artifact-$(basename $artifact_url).zip"
124+
fi
125+
done
126+
}
127+
128+
function build_level_zero_from_source() {
129+
COMMIT=$1
130+
131+
echo "Building Level Zero from source at commit $COMMIT"
132+
133+
# Install build dependencies if not already present
134+
echo "Ensuring build dependencies are available..."
135+
apt-get update -qq
136+
apt-get install -y build-essential cmake git libc6-dev linux-libc-dev
137+
138+
# Check CMake version (Level Zero requires CMake 3.5+)
139+
CMAKE_VERSION=$(cmake --version | head -n1 | sed 's/.*cmake version \([0-9]\+\.[0-9]\+\).*/\1/')
140+
echo "CMake version: $CMAKE_VERSION"
141+
142+
# Create temporary build directory
143+
BUILD_DIR="/tmp/level-zero-build"
144+
INSTALL_DIR="/tmp/level-zero-install"
145+
rm -rf $BUILD_DIR $INSTALL_DIR
146+
mkdir -p $BUILD_DIR $INSTALL_DIR
147+
cd $BUILD_DIR
148+
149+
# Clone and checkout specific commit
150+
echo "Cloning Level Zero repository..."
151+
if ! git clone https://github.com/oneapi-src/level-zero.git; then
152+
echo "ERROR: Failed to clone Level Zero repository"
153+
return 1
154+
fi
155+
156+
cd level-zero
157+
if ! git checkout $COMMIT; then
158+
echo "ERROR: Failed to checkout commit $COMMIT"
159+
return 1
160+
fi
161+
162+
# Create build directory
163+
mkdir build
164+
cd build
165+
166+
# Configure build
167+
echo "Configuring Level Zero build..."
168+
if ! cmake .. \
169+
-DCMAKE_BUILD_TYPE=Release \
170+
-DCMAKE_INSTALL_PREFIX=/usr/local \
171+
-DLEVEL_ZERO_BUILD_TESTS=OFF \
172+
-DLEVEL_ZERO_BUILD_SAMPLES=OFF; then
173+
echo "ERROR: CMake configuration failed"
174+
return 1
175+
fi
176+
177+
# Build
178+
echo "Building Level Zero..."
179+
if ! make -j$(nproc); then
180+
echo "ERROR: Build failed"
181+
return 1
182+
fi
183+
184+
# Staged install (doesn't affect system)
185+
echo "Creating staged installation..."
186+
if ! make install DESTDIR=$INSTALL_DIR; then
187+
echo "ERROR: Staged installation failed"
188+
return 1
189+
fi
190+
191+
# Copy files to their final destinations
192+
echo "Installing Level Zero to system..."
193+
if [ -d "$INSTALL_DIR/usr/local" ]; then
194+
cp -r $INSTALL_DIR/usr/local/* /usr/local/
195+
else
196+
echo "ERROR: Staged installation directory not found"
197+
return 1
198+
fi
199+
200+
# Update library cache
201+
ldconfig
202+
203+
# Clean up build and install directories
204+
rm -rf $BUILD_DIR $INSTALL_DIR
205+
206+
echo "Level Zero built and installed successfully from commit $COMMIT"
57207
}
58208

59209
TBB_INSTALLED=false
@@ -96,6 +246,16 @@ CheckIGCdevTag() {
96246
fi
97247
}
98248

249+
CheckIfCommitHash() {
250+
local arg="$1"
251+
# Check if it's a 40-character hex string (SHA-1 commit hash)
252+
if [[ $arg =~ ^[a-f0-9]{40}$ ]]; then
253+
echo "Yes"
254+
else
255+
echo "No"
256+
fi
257+
}
258+
99259
InstallIGFX () {
100260
echo "Installing Intel Graphics driver..."
101261
echo "Compute Runtime version $CR_TAG"
@@ -122,10 +282,29 @@ InstallIGFX () {
122282
| grep ".*deb" \
123283
| grep -v "u18" \
124284
| wget -qi -
125-
get_release oneapi-src/level-zero $L0_TAG \
126-
| grep ".*$UBUNTU_VER.*deb$" \
127-
| wget -qi -
128-
dpkg -i --force-all *.deb && rm *.deb *.sum
285+
286+
# Check if L0_TAG is a commit hash or a regular tag
287+
IS_L0_COMMIT=$(CheckIfCommitHash $L0_TAG)
288+
if [ "$IS_L0_COMMIT" == "Yes" ]; then
289+
echo "Level Zero is using commit hash, building from source..."
290+
if ! build_level_zero_from_source $L0_TAG; then
291+
echo "ERROR: Failed to build Level Zero from source"
292+
exit 1
293+
fi
294+
# Install other packages (Level Zero was already installed from source)
295+
if ls *.deb 1> /dev/null 2>&1; then
296+
dpkg -i --force-all *.deb && rm *.deb
297+
fi
298+
if ls *.sum 1> /dev/null 2>&1; then
299+
rm *.sum
300+
fi
301+
else
302+
get_release oneapi-src/level-zero $L0_TAG \
303+
| grep ".*$UBUNTU_VER.*deb$" \
304+
| wget -qi -
305+
# Install all packages including Level Zero
306+
dpkg -i --force-all *.deb && rm *.deb *.sum
307+
fi
129308
mkdir -p /usr/local/lib/igc/
130309
echo "$IGC_TAG" > /usr/local/lib/igc/IGCTAG.txt
131310
if [ "$IS_IGC_DEV" == "Yes" ]; then
@@ -134,22 +313,56 @@ InstallIGFX () {
134313
# Backup and install it from release igc as a temporarily workaround
135314
# while we working to resolve the issue.
136315
echo "Backup libopencl-clang"
137-
cp -d /usr/local/lib/libopencl-clang2.so.15* .
316+
317+
# Ensure we're in a writable directory for backup operations
318+
BACKUP_DIR="/tmp/igc-backup"
319+
mkdir -p "$BACKUP_DIR"
320+
cd "$BACKUP_DIR"
321+
echo "Working in backup directory: $BACKUP_DIR"
322+
323+
if ls /usr/local/lib/libopencl-clang2.so.15* 1> /dev/null 2>&1; then
324+
cp -d /usr/local/lib/libopencl-clang2.so.15* .
325+
LIBOPENCL_BACKED_UP=true
326+
echo "Successfully backed up libopencl-clang files"
327+
else
328+
echo "Warning: libopencl-clang2.so.15* not found, skipping backup"
329+
LIBOPENCL_BACKED_UP=false
330+
fi
138331
echo "Download IGC dev git hash $IGC_DEV_VER"
139-
get_pre_release_igfx $IGC_DEV_URL $IGC_DEV_VER
332+
if ! get_pre_release_igfx $IGC_DEV_URL $IGC_DEV_VER; then
333+
echo "ERROR: Failed to download IGC dev package"
334+
exit 1
335+
fi
140336
echo "Install IGC dev git hash $IGC_DEV_VER"
141337
# New dev IGC packaged iga64 conflicting with iga64 from intel-igc-media
142338
# force overwrite to workaround it first.
143-
dpkg -i --force-all *.deb
144-
echo "Install libopencl-clang"
145-
# Workaround only, will download deb and install with dpkg once fixed.
146-
cp -d libopencl-clang2.so.15* /usr/local/lib/
147-
rm /usr/local/lib/libigc.so /usr/local/lib/libigc.so.1* && \
148-
ln -s /usr/local/lib/libigc.so.2 /usr/local/lib/libigc.so && \
149-
ln -s /usr/local/lib/libigc.so.2 /usr/local/lib/libigc.so.1
339+
if ls *.deb 1> /dev/null 2>&1; then
340+
dpkg -i --force-all *.deb
341+
else
342+
echo "Warning: No IGC dev deb files found after download"
343+
fi
344+
if [ "$LIBOPENCL_BACKED_UP" == "true" ]; then
345+
echo "Install libopencl-clang"
346+
# Workaround only, will download deb and install with dpkg once fixed.
347+
echo "Copying backed up libopencl-clang files from $BACKUP_DIR"
348+
cp -d "$BACKUP_DIR"/libopencl-clang2.so.15* /usr/local/lib/
349+
fi
350+
if [ -f /usr/local/lib/libigc.so.2 ]; then
351+
rm -f /usr/local/lib/libigc.so /usr/local/lib/libigc.so.1* && \
352+
ln -s /usr/local/lib/libigc.so.2 /usr/local/lib/libigc.so && \
353+
ln -s /usr/local/lib/libigc.so.2 /usr/local/lib/libigc.so.1
354+
fi
150355
echo "Clean up"
151-
rm *.deb libopencl-clang2.so.15*
356+
if ls *.deb 1> /dev/null 2>&1; then
357+
rm *.deb
358+
fi
152359
echo "$IGC_DEV_TAG" > /usr/local/lib/igc/IGCTAG.txt
360+
361+
# Clean up backup directory (this also removes the backed up libopencl-clang files)
362+
if [ -d "$BACKUP_DIR" ]; then
363+
echo "Cleaning up backup directory: $BACKUP_DIR"
364+
rm -rf "$BACKUP_DIR"
365+
fi
153366
fi
154367
}
155368

@@ -169,6 +382,7 @@ InstallCPURT () {
169382
if [ -e $INSTALL_LOCATION/oclcpu/install.sh ]; then \
170383
bash -x $INSTALL_LOCATION/oclcpu/install.sh
171384
else
385+
mkdir -p /etc/OpenCL/vendors
172386
echo $INSTALL_LOCATION/oclcpu/x64/libintelocl.so > /etc/OpenCL/vendors/intel_oclcpu.icd
173387
fi
174388
}

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")

unified-runtime/test/adapters/level_zero/v2/event_pool_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ struct EventPoolTest : public uur::urQueueTestWithParam<ProviderParams> {
136136
// the provider
137137
switch (params.provider) {
138138
case TEST_PROVIDER_COUNTER:
139-
return std::make_unique<provider_counter>(platform, context,
140-
device);
139+
return std::make_unique<provider_counter>(
140+
platform, context, param.queue, device, flags);
141141
case TEST_PROVIDER_NORMAL:
142142
return std::make_unique<provider_normal>(context, params.queue,
143143
flags);

0 commit comments

Comments
 (0)