RDNA4 (experimental; untested on RDNA4 hardware) - kernels/common/wmma_layout.h picks the WMMA operand/accumulator layout per target; K (pwin_*) and M (swin_*) index through it, so the same sources build for gfx11 and gfx12. D4R_WMMA_LAYOUT=12 on gfx11 is a test shim that runs the gfx12 indexing on gfx11 WMMA. - M can use native e4m3 FP8 WMMA on gfx12 (D4R_NATIVE_FP8=1). Texture tails (enc0_tail, dec0_head) get gfx12 f16 and FP8 paths that match ZLUDA's gfx12 lowering. - ZLUDA patch 0007: gfx12 WMMA helpers, optional native FP8 MMA (D4R_ZLUDA_WMMA_FP8_NATIVE), a layout override for testing, and an architecture argument for d4r_emit. Texture kernels are now compiled offline per target through d4r_emit (D4R_ZLUDA_EMIT) instead of on the local GPU. - New d4r.ini option [Kernels] NativeFp8 (default on), wired through the shim and d4r_config.py. On gfx12 the bridge serves kernels/<arch>-fp8 when it is on. - The bridge picks the KFD GPU with the most SIMDs (so an iGPU is not chosen over a discrete GPU); D4R_GPU_ARCH overrides it. - kernels/build.sh and package_release.sh build gfx1100-gfx1103 and gfx1200/gfx1201 (plus -fp8 variants), and D4R_BUNDLE_TEX takes per-target folders. Performance (RDNA3; harness byte-identical unless noted) - ZLUDA patch 0006: m16n8k8 f16 MMAs on WMMA (E; not bit-exact, 52-55 dB per layer, D4R_ZLUDA_WMMA_K8=0 disables it), per-key weight-image slots for native prep kernels (d4r_prep_key_at, d4r_prep_key_slots), and wave64 builds of MMA-free kernels (D4R_ZLUDA_WAVE64). - M: packed FP8 encoding, conflict-free patch-merge reads, scalar weight loads in enc1, and weight prep once per weight set for the six enc3 tube blocks. - K: CU mode for the six non-wide pwin layers. - Texture kernels: every DLSS flag variant is built natively (24 K output, 8 M post, 4 M downsample, 4 M enc0), not only Townfall's; post and K output run as wave64. - M direct output: rrlite_downsample_kernel writes the shim's output buffer; the shim's default direct-output presets are now 11,13. Tools - dump_runner takes the prep grid from d4r_prep_blocks and refuses texture/surface dumps. - New pwin_check.py, swin_check.py, model_enc3.py and tail_check.hip. Docs: README GPU table and RDNA4 notes, building (patches 0002-0007, d4r_emit), native-kernels (RDNA4 section), performance (new numbers), packaging README. Version 0.1.2.
64 lines
2.5 KiB
Bash
Executable File
64 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
ZLUDA_SOURCE_ROOT="${ZLUDA_SOURCE_ROOT:-}"
|
|
ROCM_ROOT="${ROCM_ROOT:-/opt/rocm}"
|
|
HIPCC="${HIPCC:-$ROCM_ROOT/bin/hipcc}"
|
|
LLVM_DIS="${LLVM_DIS:-$ROCM_ROOT/lib/llvm/bin/llvm-dis}"
|
|
LLVM_AS="${LLVM_AS:-$ROCM_ROOT/lib/llvm/bin/llvm-as}"
|
|
OCML="${OCML:-$ROCM_ROOT/amdgcn/bitcode/ocml.bc}"
|
|
WORK_ROOT="${D4R_ZLUDA_PTX_HELPER_WORK:-${TMPDIR:-/tmp}/d4r-zluda-ptx-helpers}"
|
|
# D4R_ZLUDA_HELPER_FLAGS: extra compiler flags, e.g. -DD4R_WMMA12_SHIM for the gfx12-layout test build (never
|
|
# ship it: its gfx12 helpers use gfx11 WMMAs)
|
|
read -r -a EXTRA_FLAGS <<< "${D4R_ZLUDA_HELPER_FLAGS:-}"
|
|
|
|
if [[ -z "$ZLUDA_SOURCE_ROOT" || ! -f "$ZLUDA_SOURCE_ROOT/ptx/lib/zluda_ptx_impl.cpp" ]]; then
|
|
printf 'Set ZLUDA_SOURCE_ROOT to a ZLUDA source checkout\n' >&2
|
|
exit 2
|
|
fi
|
|
for dependency in "$HIPCC" "$LLVM_DIS" "$LLVM_AS" "$OCML"; do
|
|
if [[ ! -e "$dependency" ]]; then
|
|
printf 'Required ROCm/LLVM helper is missing: %s\n' "$dependency" >&2
|
|
exit 2
|
|
fi
|
|
done
|
|
|
|
mkdir -p "$WORK_ROOT"
|
|
SOURCE="$ZLUDA_SOURCE_ROOT/ptx/lib/zluda_ptx_impl.cpp"
|
|
PTX_LIB="$ZLUDA_SOURCE_ROOT/ptx/lib"
|
|
COMMON_FLAGS=(-DHIP_ENABLE_WARP_SYNC_BUILTINS -std=c++20 -Xclang -fdenormal-fp-math=dynamic
|
|
-Wall -Wextra -Wsign-compare -Wconversion -x hip "$SOURCE" -nogpulib -O3
|
|
-mno-wavefrontsize64 --offload-device-only --offload-arch=gfx1030 -emit-llvm -c
|
|
-Xclang -mlink-bitcode-file -Xclang "$OCML" "${EXTRA_FLAGS[@]}")
|
|
|
|
build_one() {
|
|
local suffix="$1"
|
|
shift
|
|
local raw="$WORK_ROOT/zluda_ptx_impl${suffix}.raw.bc"
|
|
local clean="$WORK_ROOT/zluda_ptx_impl${suffix}.clean.bc"
|
|
local ll="$WORK_ROOT/zluda_ptx_impl${suffix}.ll"
|
|
local output="$PTX_LIB/zluda_ptx_impl${suffix}.bc"
|
|
|
|
"$HIPCC" "${COMMON_FLAGS[@]}" "$@" -o "$raw"
|
|
"$LLVM_DIS" "$raw" -o "$ll"
|
|
sed -E \
|
|
-e '/@llvm.used/d' \
|
|
-e '/wchar_size/d' \
|
|
-e '/llvm.module.flags/d' \
|
|
-e '/__hip_cuid/d' \
|
|
-e 's/optnone//g' \
|
|
-e 's/define hidden/define linkonce_odr/g' \
|
|
-e 's/"target-cpu"="gfx1030"//g' \
|
|
-e 's/"target-features"="[^"]+"//g' "$ll" |
|
|
"$LLVM_AS" -o "$clean" -
|
|
mv "$clean" "$output"
|
|
printf 'Wrote %s (%s bytes)\n' "$output" "$(stat -c '%s' "$output")"
|
|
}
|
|
|
|
build_one ""
|
|
build_one "_constrained" -ffp-model=strict -ffp-exception-behavior=ignore
|
|
# wave64 helpers (D4R_ZLUDA_WAVE64: two CUDA warps per wave; see d4r_warp_base in zluda_ptx_impl.cpp)
|
|
build_one "_w64" -mwavefrontsize64 -DD4R_WAVE64
|
|
build_one "_constrained_w64" -ffp-model=strict -ffp-exception-behavior=ignore -mwavefrontsize64 -DD4R_WAVE64
|