Every file outside sycl/ (and docs/INTEL.md) is now upstream's, byte for byte. The Intel pieces that used to edit shared files move under sycl/ and wrap upstream from outside: - sycl/setup_intel.py: runs setup.py's main() with the GPU check, engine step, RAM rule and config writer swapped for the SYCL port's - sycl/serve/server_intel.py: serve/server.py plus the Arc's Monitor readings (sycl/serve/xe_telemetry.py) and the optional model menu (sycl/serve/web/switcher.js) - sycl/tools/gpustat.py (was tools/intel/), sycl/.gitignore; migrate.sh writes its compilation database outside the checkout - removed: the llama.cpp engine path (serve/engine_llama.py), the README box Engine sources in sycl/ still track 0.1.31; the 0.1.32 kernels are not migrated yet.
48 lines
2.9 KiB
Bash
Executable File
48 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# CUDA -> SYCL migration of the Strata engine with SYCLomatic (dpct), run inside strata-sycl-dev.
|
|
# sycl/migrate.sh [repo] [out] repo defaults to the Strata_B70 checkout beside this dir
|
|
# Writes a compilation database first (there is no nvcc here, so CMake cannot make one), then migrates every
|
|
# CUDA-touching source into <out> mirroring the tree. Files dpct leaves alone are not copied - the port's
|
|
# CMake falls back to the original for those, so the diff against upstream stays the port itself.
|
|
set -euo pipefail
|
|
repo=${1:-/work/Strata_B70}
|
|
out=${2:-$repo/sycl}
|
|
hdr=${CUDA_HEADERS:-/cuda-headers/include}
|
|
source /opt/intel/oneapi/setvars.sh >/dev/null 2>&1 || true
|
|
export PATH=/opt/intel/oneapi/dpcpp-ct/latest/bin:$PATH
|
|
cd "$repo"
|
|
# the compilation database: every .cu plus every .cpp/.hpp that includes a CUDA header
|
|
db_dir=$(mktemp -d) # outside the checkout: nothing to ignore in git
|
|
trap 'rm -rf "$db_dir"' EXIT
|
|
python3 - "$repo" "$hdr" "$db_dir" <<'PY'
|
|
import json, os, re, sys, subprocess
|
|
repo, hdr, db_dir = sys.argv[1], sys.argv[2], sys.argv[3]
|
|
files = subprocess.check_output(["bash", "-c",
|
|
r"find src -name '*.cu'; grep -rl 'cuda_runtime\|cublas_v2\|cuda_fp16\|cuda\.h' src --include='*.cpp'"],
|
|
cwd=repo, text=True).split()
|
|
db = []
|
|
# not in this tree: the optional ggml MMQ prefill path needs llama.cpp's ggml-cuda sources, and one parity test needs
|
|
# ggml-cpu.h. Both stay CUDA-only for now.
|
|
skip = {"src/prefill/moe_mmq.cu", "src/prefill/ggml_cuda_host.cu", "src/kernels/native_expert_parity.cpp"}
|
|
for f in sorted(set(files) - skip):
|
|
tool = "nvcc" if f.endswith(".cu") else "g++"
|
|
cmd = [tool, "-std=c++20", "-Iinclude", "-Ithird_party/ggml", "-I" + hdr, "-DSTRATA_VERSION=\"port\""]
|
|
if tool == "nvcc": cmd += ["--cuda-gpu-arch=sm_80", "-x", "cuda"]
|
|
cmd += ["-c", f, "-o", f + ".o"]
|
|
db.append({"directory": repo, "file": os.path.join(repo, f), "arguments": cmd})
|
|
json.dump(db, open(os.path.join(db_dir, "compile_commands.json"), "w"), indent=1)
|
|
print(len(db), "translation units")
|
|
PY
|
|
mkdir -p "$out"
|
|
# --use-experimental-features: graph (cudaGraph -> sycl_ext_oneapi_graph), matrix (mma -> joint_matrix)
|
|
# --gen-helper-function: copy the dpct helper headers next to the output so the port builds without the tool
|
|
dpct -p "$db_dir" --in-root="$repo" --out-root="$out" \
|
|
--cuda-include-path="$hdr" \
|
|
--use-experimental-features=graph,matrix,logical-group,masked-sub-group-operation,occupancy-calculation,free-function-queries,local-memory-kernel-scope-allocation,bindless_images,virtual_mem,root-group,non-uniform-groups \
|
|
--gen-helper-function --always-use-async-handler --sycl-named-lambda \
|
|
--enable-ctad --optimize-migration --assume-nd-range-dim=3 \
|
|
--report-type=all --report-file-prefix=dpct_report --report-format=csv \
|
|
--stop-on-parse-err=false ${DPCT_EXTRA:-} 2>&1 | tee "$out/migrate.log" | tail -40
|
|
echo "MIGRATE EXIT ${PIPESTATUS[0]}"
|
|
find "$out" -type f | wc -l
|