okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Trial2 merge f-0291-pr-intel (2b4d43bac)5438023a6

main
3.4 KiB52 linesraw
1#!/usr/bin/env bash
2# Configure + build the SYCL port inside strata-sycl-dev.  sycl/build.sh [target...]
3#   AOT=bmg-g31         ahead-of-time device code (empty: SPIR-V, JIT at the first start)
4#   IQ_DECODE_FAST=OFF  the earlier IQ/Q2 decode helpers (default ON: bit-exact packed arithmetic, PR #4185)
5#   I8_ESIMD=OFF        no fused int8 ESIMD expert kernels (stubs; the prompt's experts take the XMX path). AUTO (default) or ON otherwise.
6#   ALLOW_BAD_OCLOC=1   build although this ocloc is known to crash on the Battlemage kernels (see below)
7set -uo pipefail
8set +u; source /opt/intel/oneapi/setvars.sh >/dev/null 2>&1 || true; set -u
9
10# #3219: ocloc from Compute Runtime 26.22.38646.x (IGC 2.36.3) ends with "IGC: Internal Compiler Error: Floating point exception" on the
11# fused int8 expert kernels when it builds for a Battlemage device (bmg-*): 77 device images, then "gen compiler command failed with exit
12# code 245" at the last link, after the long compile.  A newer ocloc builds them.  The strata-sycl-dev image keeps whatever ocloc its base image
13# had when it was built (the base tag moves; `docker build` reuses a cached base unless it gets --pull).  Say it before the compile, not after.
14# Other versions are not judged: the list holds what has been seen to fail.
15known_bad_ocloc() {
16  case "$1" in
17    26.22.38646|26.22.38646.*) return 0 ;;
18  esac
19  return 1
20}
21ocloc_version() {
22  command -v ocloc >/dev/null 2>&1 || return 1
23  ocloc --version 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1
24}
25if [[ "${AOT:-}" =~ ^(bmg|lnl) ]] && [[ "${I8_ESIMD:-AUTO}" != "OFF" ]] && [[ "${ALLOW_BAD_OCLOC:-}" != "1" ]]; then
26  v=$(ocloc_version || true)
27  if [[ -n "$v" ]] && known_bad_ocloc "$v"; then
28    cat >&2 <<EOF
29build.sh: this image's ocloc is $v (IGC 2.36.3). It is known to crash while it compiles the int8 ESIMD kernels for AOT=${AOT} (#3219).
30  Fix: rebuild the image with a fresh base, then build again:   docker build --pull -t strata-sycl-dev sycl/tools
31  Or build without those kernels (the prompt's experts take the slower XMX path):   I8_ESIMD=OFF
32  Or build anyway:   ALLOW_BAD_OCLOC=1
33EOF
34    exit 2
35  fi
36fi
37
38repo=${REPO:-$(git rev-parse --show-toplevel)}
39b=${BUILD_DIR:-$repo/build-sycl}
40[ -f $b/build.ninja ] || cmake -S $repo/sycl -B $b -G Ninja -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx \
41    -DSTRATA_SYCL_AOT="${AOT:-}" -DSTRATA_SYCL_SPIN_MAX="${SPIN_MAX:-}" -DSTRATA_SYCL_I8_ESIMD="${I8_ESIMD:-AUTO}" -DSTRATA_SYCL_IQ_DECODE_FAST="${IQ_DECODE_FAST:-ON}" 2>&1 | tail -15
42# an existing build folder keeps its cache: a switch given now reaches it (only this one, so AOT and the rest stay as configured)
43[ -z "${I8_ESIMD:-}" ] || cmake -S $repo/sycl -B $b -DSTRATA_SYCL_I8_ESIMD="$I8_ESIMD" >/dev/null 2>&1
44cmake --build $b -j ${JOBS:-12} ${1:+--target "$@"} -- -k 0 2>&1 | tee $b/build.log | grep -E '^FAILED|error:|^ninja: build stopped|Linking|^\[[0-9]+/[0-9]+\] Linking' | tail -40
45rc=${PIPESTATUS[0]}                       # cmake's status, kept: the script ends with this, not with the status of the greps below (#2990)
46echo "BUILD EXIT $rc"
47grep -c 'error:' $b/build.log | sed 's/^/errors: /'
48grep -E '^FAILED' $b/build.log | sed 's#.*/##' | sort | uniq | head -60
49if grep -q 'IGC: Internal Compiler Error' $b/build.log 2>/dev/null; then
50  echo "build.sh: the device compiler (ocloc $(ocloc_version || echo '?')) crashed: try  docker build --pull -t strata-sycl-dev sycl/tools  or  I8_ESIMD=OFF  (#3219)"
51fi
52exit "$rc"