Uploaded sanitized BC250/ROCm Repository.

This commit is contained in:
Fabian
2026-08-20 00:45:43 +02:00
parent 7d2184f1e8
commit d7d22e93b3
678 changed files with 65963 additions and 1 deletions
+48
View File
@@ -0,0 +1,48 @@
#!/bin/bash
# =============================================================================
# Step 1: Install ROCm 7.2.0 Packages — AMD BC-250
# =============================================================================
# Install all 16 required ROCm packages from CachyOS/Arch repos.
# Run as: sudo bash 01_install_rocm_packages.sh
# =============================================================================
set -euo pipefail
echo "============================================"
echo " Installing ROCm 7.2.0 Packages for BC-250"
echo "============================================"
# Ensure pacman is up to date
sudo pacman -Sy
# Install all 16 ROCm packages
sudo pacman -S --needed --noconfirm \
rocm-core \
rocm-hip-runtime \
rocm-hip-sdk \
rocm-opencl-runtime \
rocm-opencl-sdk \
hip-runtime-amd \
rocm-clang-ocl \
rocm-device-libs \
rocminfo \
rocm-smi-lib \
hsa-rocr \
hsakmt-roct \
comgr \
hipcc \
rocprofiler-register \
rocm-llvm
echo ""
echo "============================================"
echo " ROCm packages installed successfully"
echo "============================================"
# Verify installation
echo ""
echo "Installed ROCm packages:"
pacman -Q | grep -E "rocm|hip-|hsa|comgr|hipcc" | sort
echo ""
echo "Next: Run 02_configure_environment.sh"
+162
View File
@@ -0,0 +1,162 @@
#!/bin/bash
# =============================================================================
# Step 2: Configure System Environment — AMD BC-250 ROCm
# =============================================================================
# Sets up:
# 1. User group membership (render, video)
# 2. Environment variables (fish shell + bash fallback)
# 3. Modprobe configuration (amdgpu.conf)
# 4. Boot parameters (Limine or GRUB)
#
# Run as: bash 02_configure_environment.sh
# Some steps will prompt for sudo.
# =============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GUIDE_DIR="$(dirname "$SCRIPT_DIR")"
CURRENT_USER="$(whoami)"
echo "============================================"
echo " Configuring System for BC-250 ROCm"
echo "============================================"
# ─────────────────────────────────────────────
# 1. User Groups
# ─────────────────────────────────────────────
echo ""
echo "[1/4] Adding $CURRENT_USER to render and video groups..."
sudo usermod -aG render,video "$CURRENT_USER"
echo " Done. (Requires re-login to take effect)"
# ─────────────────────────────────────────────
# 2. Environment Variables
# ─────────────────────────────────────────────
echo ""
echo "[2/4] Configuring environment variables..."
# Detect shell
if command -v fish &>/dev/null && [[ "$SHELL" == *fish* ]]; then
echo " Detected fish shell — configuring fish universal vars"
fish -c '
set -Ux HSA_OVERRIDE_GFX_VERSION 10.1.0
set -Ux HIP_VISIBLE_DEVICES 0
set -Ux HSA_ENABLE_SDMA 0
set -Ux HSA_TOOLS_LIB ""
set -Ux HSA_TOOLS_REPORT_LOAD_FAILURE 0
set -Ux ROCM_PATH /opt/rocm
set -Ux HIP_PATH /opt/rocm
echo " Fish universal variables set."
'
# Also add to fish config for PATH
FISH_CONFIG="$HOME/.config/fish/config.fish"
if ! grep -q "ROCm PATH" "$FISH_CONFIG" 2>/dev/null; then
mkdir -p "$(dirname "$FISH_CONFIG")"
cat >> "$FISH_CONFIG" << 'FISHEOF'
# ROCm PATH
if not contains /opt/rocm/bin $PATH
set -gx PATH /opt/rocm/bin $PATH
end
FISHEOF
echo " Added /opt/rocm/bin to fish PATH"
fi
else
echo " Configuring bash/zsh environment..."
PROFILE="$HOME/.bashrc"
if ! grep -q "HSA_OVERRIDE_GFX_VERSION" "$PROFILE" 2>/dev/null; then
cat >> "$PROFILE" << 'BASHEOF'
# ===== ROCm BC-250 Environment =====
export HSA_OVERRIDE_GFX_VERSION=10.1.0
export HIP_VISIBLE_DEVICES=0
export HSA_ENABLE_SDMA=0
export HSA_TOOLS_LIB=""
export HSA_TOOLS_REPORT_LOAD_FAILURE=0
export ROCM_PATH=/opt/rocm
export HIP_PATH=/opt/rocm
export PATH=/opt/rocm/bin:$PATH
# ===== End ROCm =====
BASHEOF
echo " Added to $PROFILE"
else
echo " Already configured in $PROFILE"
fi
fi
echo ""
echo " CRITICAL BC-250 Environment Variables:"
echo " HSA_OVERRIDE_GFX_VERSION=10.1.0 (map gfx1013 → gfx1010)"
echo " HIP_VISIBLE_DEVICES=0 (single GPU)"
echo " HSA_ENABLE_SDMA=0 (SDMA broken on Cyan Skillfish)"
echo " HSA_TOOLS_LIB=\"\" (disable profiling tools)"
echo ""
echo " DO NOT SET these (they cause hangs):"
echo " HIP_LAUNCH_BLOCKING=1"
echo " GPU_MAX_HW_QUEUES=1"
# ─────────────────────────────────────────────
# 3. Modprobe Configuration
# ─────────────────────────────────────────────
echo ""
echo "[3/4] Installing modprobe configuration..."
AMDGPU_CONF="$GUIDE_DIR/config/amdgpu.conf"
if [[ -f "$AMDGPU_CONF" ]]; then
sudo cp "$AMDGPU_CONF" /etc/modprobe.d/amdgpu.conf
echo " Installed /etc/modprobe.d/amdgpu.conf"
echo " Contents: $(cat /etc/modprobe.d/amdgpu.conf)"
else
echo " Creating amdgpu.conf manually..."
echo 'options amdgpu noretry=0 gpu_recovery=1 sched_hw_submission=2 ppfeaturemask=0xfff73ef7' | \
sudo tee /etc/modprobe.d/amdgpu.conf
fi
# ─────────────────────────────────────────────
# 4. Boot Parameters
# ─────────────────────────────────────────────
echo ""
echo "[4/4] Configuring boot parameters..."
BOOT_PARAMS="amdgpu.ppfeaturemask=0xfff73ef7 amdgpu.noretry=0 amdgpu.gpu_recovery=1 amdgpu.sched_hw_submission=2"
if [[ -f /boot/limine.conf ]]; then
echo " Detected Limine bootloader"
if ! grep -q "ppfeaturemask" /boot/limine.conf; then
echo ""
echo " Add these parameters to your kernel cmdline in /boot/limine.conf:"
echo " $BOOT_PARAMS"
echo ""
echo " Example: Find the 'cmdline=' line and append the parameters."
echo " Then run: sudo limine-update"
else
echo " Boot parameters already configured in /boot/limine.conf"
fi
elif [[ -f /etc/default/grub ]]; then
echo " Detected GRUB bootloader"
if ! grep -q "ppfeaturemask" /etc/default/grub; then
sudo sed -i "s|GRUB_CMDLINE_LINUX_DEFAULT=\"|GRUB_CMDLINE_LINUX_DEFAULT=\"$BOOT_PARAMS |" /etc/default/grub
sudo grub-mkconfig -o /boot/grub/grub.cfg
echo " GRUB updated with boot parameters"
else
echo " Boot parameters already configured in GRUB"
fi
else
echo " WARNING: Unknown bootloader. Manually add these kernel parameters:"
echo " $BOOT_PARAMS"
fi
echo ""
echo "============================================"
echo " System configuration complete"
echo "============================================"
echo ""
echo "NOTE: Log out and back in for group changes to take effect."
echo " Boot parameters require a reboot after module installation."
echo ""
echo "Next: Download kernel source and build patched module"
echo " Run: bash 04_build_patched_module.sh"
+197
View File
@@ -0,0 +1,197 @@
#!/bin/bash
# =============================================================================
# Step 4: Download CachyOS Kernel Source, Patch & Build amdgpu Module
# =============================================================================
# CRITICAL: Must use CachyOS kernel source (NOT vanilla kernel.org source).
# Vanilla source has different struct layouts → NULL pointer crash.
#
# This script:
# 1. Detects current kernel version
# 2. Downloads matching CachyOS source PKGBUILD
# 3. Extracts and prepares the source tree
# 4. Applies 3 BC-250 patches (GFXOFF, KIQ bypass, dead-GPU detection)
# 5. Builds ONLY the amdgpu.ko module (not the entire kernel)
# 6. Strips debug symbols and compresses with zstd
#
# Run as: bash 04_build_patched_module.sh [build_dir]
# Default build_dir: ~/kernel-build
#
# Prerequisites:
# - CachyOS with ROCm packages installed
# - base-devel, asp/pkgctl, clang, llvm, lld installed
# =============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GUIDE_DIR="$(dirname "$SCRIPT_DIR")"
PATCHES_DIR="$GUIDE_DIR/patches"
BUILD_DIR="${1:-$HOME/kernel-build}"
KERNEL_VER="$(uname -r)"
echo "============================================"
echo " Building Patched amdgpu Module for BC-250"
echo "============================================"
echo ""
echo " Kernel: $KERNEL_VER"
echo " Build dir: $BUILD_DIR"
echo " Patches: $PATCHES_DIR"
echo ""
# ─────────────────────────────────────────────
# 1. Install Build Dependencies
# ─────────────────────────────────────────────
echo "[1/7] Installing build dependencies..."
sudo pacman -S --needed --noconfirm base-devel asp clang llvm lld bc cpio
# ─────────────────────────────────────────────
# 2. Create Build Directory
# ─────────────────────────────────────────────
echo "[2/7] Creating build directory..."
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# ─────────────────────────────────────────────
# 3. Get CachyOS Kernel Source
# ─────────────────────────────────────────────
echo "[3/7] Getting CachyOS kernel source..."
# Extract base version from running kernel (e.g., 6.19.6-2-cachyos → 6.19.6)
BASE_VER=$(echo "$KERNEL_VER" | sed 's/-.*//')
echo " Base kernel version: $BASE_VER"
# Try to get the PKGBUILD via asp (Arch Source Package)
if command -v pkgctl &>/dev/null; then
echo " Using pkgctl to fetch source..."
pkgctl repo clone --protocol=https linux-cachyos 2>/dev/null || true
elif command -v asp &>/dev/null; then
echo " Using asp to fetch source..."
asp checkout linux-cachyos 2>/dev/null || true
fi
# If asp/pkgctl didn't work, try direct download
if [[ ! -d linux-cachyos ]]; then
echo " Trying CachyOS GitHub..."
if command -v git &>/dev/null; then
git clone --depth 1 https://github.com/CachyOS/linux-cachyos.git 2>/dev/null || true
fi
fi
if [[ ! -d linux-cachyos ]]; then
echo ""
echo " ERROR: Could not fetch CachyOS kernel source automatically."
echo " Please manually download the CachyOS kernel source matching $KERNEL_VER"
echo " and place it in $BUILD_DIR/linux-cachyos/"
echo ""
echo " Options:"
echo " 1. pkgctl repo clone --protocol=https linux-cachyos"
echo " 2. git clone https://github.com/CachyOS/linux-cachyos.git"
echo " 3. Download from https://github.com/CachyOS/linux-cachyos/releases"
exit 1
fi
cd linux-cachyos
# Run makepkg to download and extract source (don't build yet)
echo " Extracting source (makepkg --nobuild)..."
makepkg --nobuild --skippgpcheck 2>&1 | tail -5
# Find the extracted source directory
SRC_DIR=$(find . -maxdepth 2 -name "drivers" -type d | head -1 | sed 's|/drivers$||')
if [[ -z "$SRC_DIR" ]]; then
SRC_DIR=$(find "$BUILD_DIR" -maxdepth 3 -name "Kconfig" -path "*/linux-*" | head -1 | xargs dirname 2>/dev/null || true)
fi
if [[ -z "$SRC_DIR" || ! -d "$SRC_DIR" ]]; then
echo " ERROR: Could not find extracted kernel source."
echo " Look for a linux-* directory under $BUILD_DIR/linux-cachyos/src/"
exit 1
fi
echo " Source dir: $SRC_DIR"
AMDGPU_DIR="$SRC_DIR/drivers/gpu/drm/amd/amdgpu"
if [[ ! -d "$AMDGPU_DIR" ]]; then
echo " ERROR: amdgpu source not found at $AMDGPU_DIR"
exit 1
fi
# ─────────────────────────────────────────────
# 4. Prepare Build Environment
# ─────────────────────────────────────────────
echo "[4/7] Preparing build environment..."
cd "$SRC_DIR"
# Copy running kernel's config
zcat /proc/config.gz > .config 2>/dev/null || cp /boot/config-"$KERNEL_VER" .config 2>/dev/null || true
if [[ ! -f .config ]]; then
echo " ERROR: Could not find kernel config"
exit 1
fi
# Prepare the build environment
make LLVM=1 olddefconfig
make LLVM=1 modules_prepare
# ─────────────────────────────────────────────
# 5. Apply BC-250 Patches
# ─────────────────────────────────────────────
echo "[5/7] Applying BC-250 patches..."
echo " Applying patch 1: GFXOFF disable (gfx_v10_0.c)..."
python3 "$PATCHES_DIR/patch1_gfxoff.py" "$AMDGPU_DIR"
echo " Applying patch 2: KIQ bypass + dead-GPU (gmc_v10_0.c)..."
python3 "$PATCHES_DIR/patch2_gmc.py" "$AMDGPU_DIR"
echo " Applying patch 3: KIQ bypass + dead-GPU (amdgpu_gmc.c)..."
python3 "$PATCHES_DIR/patch3_amdgpu_gmc.py" "$AMDGPU_DIR"
echo " All patches applied."
# ─────────────────────────────────────────────
# 6. Build the amdgpu Module
# ─────────────────────────────────────────────
echo "[6/7] Building amdgpu module (LLVM=1)..."
echo " This may take several minutes..."
# Get number of CPU cores for parallel build
NPROC=$(nproc)
echo " Using $NPROC parallel jobs"
make LLVM=1 -j"$NPROC" M=drivers/gpu/drm/amd/amdgpu modules 2>&1 | tail -20
# Check build result
MODULE="drivers/gpu/drm/amd/amdgpu/amdgpu.ko"
if [[ ! -f "$MODULE" ]]; then
echo " ERROR: Build failed — amdgpu.ko not found"
echo " Check the build output above for errors."
exit 1
fi
echo " Build successful!"
ls -lh "$MODULE"
# ─────────────────────────────────────────────
# 7. Strip and Compress
# ─────────────────────────────────────────────
echo "[7/7] Stripping debug symbols and compressing..."
strip --strip-debug "$MODULE"
zstd -f --rm "$MODULE" -o "${MODULE}.zst"
FINAL_MODULE="${MODULE}.zst"
echo " Final module: $FINAL_MODULE"
ls -lh "$FINAL_MODULE"
echo ""
echo "============================================"
echo " Module built successfully!"
echo "============================================"
echo ""
echo " Module: $(realpath "$FINAL_MODULE")"
echo " Size: $(du -h "$FINAL_MODULE" | cut -f1)"
echo ""
echo "Next: Run 05_install_module.sh to install and reboot"
echo " bash $SCRIPT_DIR/05_install_module.sh $(realpath "$FINAL_MODULE")"
+109
View File
@@ -0,0 +1,109 @@
#!/bin/bash
# =============================================================================
# Step 5: Install Patched amdgpu Module
# =============================================================================
# Installs the patched amdgpu.ko.zst module, backs up the original,
# runs depmod, and rebuilds initramfs.
#
# Usage: sudo bash 05_install_module.sh [path_to_amdgpu.ko.zst]
# If no path given, looks in the default build location.
#
# IMPORTANT: Reboot after running this script!
# =============================================================================
set -euo pipefail
KERNEL_VER="$(uname -r)"
MODULE_DIR="/lib/modules/$KERNEL_VER/kernel/drivers/gpu/drm/amd/amdgpu"
ORIGINAL="$MODULE_DIR/amdgpu.ko.zst"
# Find the module to install
if [[ -n "${1:-}" ]]; then
NEW_MODULE="$1"
else
# Try default build location
NEW_MODULE="$HOME/kernel-build/linux-cachyos/src/linux-*/drivers/gpu/drm/amd/amdgpu/amdgpu.ko.zst"
NEW_MODULE=$(ls $NEW_MODULE 2>/dev/null | head -1 || true)
fi
if [[ -z "$NEW_MODULE" || ! -f "$NEW_MODULE" ]]; then
echo "ERROR: No module found. Provide path as argument:"
echo " sudo bash $0 /path/to/amdgpu.ko.zst"
exit 1
fi
echo "============================================"
echo " Installing Patched amdgpu Module"
echo "============================================"
echo ""
echo " Kernel: $KERNEL_VER"
echo " Source: $NEW_MODULE"
echo " Target: $ORIGINAL"
echo ""
# ─────────────────────────────────────────────
# 1. Backup Original Module
# ─────────────────────────────────────────────
echo "[1/4] Backing up original module..."
if [[ -f "$ORIGINAL" && ! -f "$ORIGINAL.orig" ]]; then
sudo cp "$ORIGINAL" "$ORIGINAL.orig"
echo " Backup: $ORIGINAL.orig"
elif [[ -f "$ORIGINAL.orig" ]]; then
echo " Backup already exists: $ORIGINAL.orig"
else
echo " WARNING: Original module not found at $ORIGINAL"
fi
# ─────────────────────────────────────────────
# 2. Install New Module
# ─────────────────────────────────────────────
echo "[2/4] Installing patched module..."
sudo cp "$NEW_MODULE" "$ORIGINAL"
echo " Installed: $(ls -lh "$ORIGINAL" | awk '{print $5, $9}')"
# ─────────────────────────────────────────────
# 3. Run depmod
# ─────────────────────────────────────────────
echo "[3/4] Running depmod..."
sudo depmod -a "$KERNEL_VER"
echo " Done."
# ─────────────────────────────────────────────
# 4. Rebuild Initramfs
# ─────────────────────────────────────────────
echo "[4/4] Rebuilding initramfs..."
if command -v mkinitcpio &>/dev/null; then
# Arch/CachyOS
sudo mkinitcpio -P
echo " mkinitcpio completed."
elif command -v dracut &>/dev/null; then
sudo dracut --force
echo " dracut completed."
elif command -v update-initramfs &>/dev/null; then
sudo update-initramfs -u
echo " update-initramfs completed."
fi
# Update bootloader if Limine
if command -v limine-update &>/dev/null; then
echo " Updating Limine bootloader..."
sudo limine-update
echo " Limine updated."
fi
echo ""
echo "============================================"
echo " Module installed successfully!"
echo "============================================"
echo ""
echo " REBOOT NOW to load the patched module:"
echo " sudo reboot"
echo ""
echo " After reboot, run 06_verify_installation.sh"
echo ""
echo " To restore original module if needed:"
echo " sudo cp $ORIGINAL.orig $ORIGINAL"
echo " sudo depmod -a $KERNEL_VER"
echo " sudo mkinitcpio -P && sudo limine-update"
echo " sudo reboot"
+193
View File
@@ -0,0 +1,193 @@
#!/bin/bash
# =============================================================================
# Step 6: Verify Installation — AMD BC-250 ROCm
# =============================================================================
# Post-reboot verification. Checks all critical components:
# - amdgpu module loaded (out-of-tree, GFXOFF disabled)
# - No KIQ timeouts or GPU crashes
# - Device nodes present
# - ppfeaturemask correct
# - GPU clock states available
# - Governor active (if installed)
# - rocminfo detects GPU
#
# Run as: bash 06_verify_installation.sh
# =============================================================================
set -euo pipefail
PASS=0
FAIL=0
WARN=0
check() {
local name="$1"
local result="$2"
local expected="${3:-}"
if [[ "$result" == "PASS" ]]; then
echo " [PASS] $name"
((PASS++))
elif [[ "$result" == "WARN" ]]; then
echo " [WARN] $name${expected:+ — $expected}"
((WARN++))
else
echo " [FAIL] $name${expected:+ — expected: $expected}"
((FAIL++))
fi
}
echo "============================================"
echo " BC-250 ROCm Installation Verification"
echo "============================================"
echo ""
# ─────────────────────────────────────────────
# 1. amdgpu Module
# ─────────────────────────────────────────────
echo "--- Module Status ---"
if lsmod | grep -q "^amdgpu"; then
SIZE=$(lsmod | grep "^amdgpu" | awk '{print $2}')
check "amdgpu module loaded (${SIZE} bytes)" "PASS"
else
check "amdgpu module loaded" "FAIL" "module not loaded"
fi
# Check out-of-tree (patched module indicator)
if dmesg 2>/dev/null | grep -q "loading out-of-tree module"; then
check "Out-of-tree module (patched)" "PASS"
else
check "Out-of-tree module (patched)" "WARN" "may be using stock module"
fi
# Check GFXOFF disabled
if dmesg 2>/dev/null | grep -qi "gfxoff.*not supported\|gfxoff.*disabled\|does not support GFXOFF"; then
check "GFXOFF disabled" "PASS"
else
check "GFXOFF disabled" "WARN" "no GFXOFF message in dmesg"
fi
# ─────────────────────────────────────────────
# 2. Stability Checks
# ─────────────────────────────────────────────
echo ""
echo "--- Stability ---"
KIQ_COUNT=$(dmesg 2>/dev/null | grep -c "timeout waiting for kiq fence" || echo 0)
if [[ "$KIQ_COUNT" -eq 0 ]]; then
check "KIQ timeouts: 0" "PASS"
else
check "KIQ timeouts: $KIQ_COUNT" "FAIL" "should be 0"
fi
DEAD_COUNT=$(dmesg 2>/dev/null | grep -c "GPU unreachable\|GPU died" || echo 0)
if [[ "$DEAD_COUNT" -eq 0 ]]; then
check "Dead-GPU events: 0" "PASS"
else
check "Dead-GPU events: $DEAD_COUNT" "WARN" "dead-GPU bypass triggered"
fi
# ─────────────────────────────────────────────
# 3. Device Nodes
# ─────────────────────────────────────────────
echo ""
echo "--- Device Nodes ---"
for DEV in /dev/dri/card0 /dev/dri/renderD128 /dev/kfd; do
if [[ -e "$DEV" ]]; then
check "$DEV exists" "PASS"
else
check "$DEV exists" "FAIL" "not found"
fi
done
# ─────────────────────────────────────────────
# 4. Boot Parameters
# ─────────────────────────────────────────────
echo ""
echo "--- Boot Parameters ---"
PPF=$(cat /sys/module/amdgpu/parameters/ppfeaturemask 2>/dev/null || echo "N/A")
if [[ "$PPF" == "0xfff73ef7" || "$PPF" == "4293918455" ]]; then
check "ppfeaturemask: $PPF" "PASS"
else
check "ppfeaturemask: $PPF" "FAIL" "expected 0xfff73ef7"
fi
NORETRY=$(cat /sys/module/amdgpu/parameters/noretry 2>/dev/null || echo "N/A")
check "noretry: $NORETRY" "$([ "$NORETRY" = "0" ] && echo PASS || echo WARN)"
# ─────────────────────────────────────────────
# 5. GPU Status
# ─────────────────────────────────────────────
echo ""
echo "--- GPU Status ---"
if [[ -f /sys/class/drm/card0/device/pp_dpm_sclk ]]; then
CLOCKS=$(cat /sys/class/drm/card0/device/pp_dpm_sclk)
echo " GPU Clocks:"
echo "$CLOCKS" | sed 's/^/ /'
check "GPU clock states available" "PASS"
else
check "GPU clock states" "FAIL" "pp_dpm_sclk not found"
fi
# Governor check
if systemctl --user is-active cyan-skillfish-governor 2>/dev/null | grep -q "active"; then
check "Governor service active" "PASS"
elif pgrep -f "cyan-skillfish-governor" &>/dev/null; then
check "Governor process running" "PASS"
else
check "Governor" "WARN" "not running (optional)"
fi
# ─────────────────────────────────────────────
# 6. ROCm Runtime
# ─────────────────────────────────────────────
echo ""
echo "--- ROCm Runtime ---"
if command -v rocminfo &>/dev/null; then
ROCM_OUT=$(HSA_OVERRIDE_GFX_VERSION=10.1.0 rocminfo 2>&1 || true)
if echo "$ROCM_OUT" | grep -q "gfx1010"; then
check "rocminfo detects gfx1010" "PASS"
else
check "rocminfo detects gfx1010" "FAIL" "GPU not found"
fi
AGENT_NAME=$(echo "$ROCM_OUT" | grep "Marketing Name" | head -1 | sed 's/.*: *//')
if [[ -n "$AGENT_NAME" ]]; then
check "GPU Name: $AGENT_NAME" "PASS"
fi
CU_COUNT=$(echo "$ROCM_OUT" | grep "Compute Unit:" | tail -1 | awk '{print $NF}')
if [[ "$CU_COUNT" == "24" ]]; then
check "Compute Units: 24" "PASS"
elif [[ -n "$CU_COUNT" ]]; then
check "Compute Units: $CU_COUNT" "WARN" "expected 24"
fi
if echo "$ROCM_OUT" | grep -q "Done"; then
check "rocminfo completed successfully" "PASS"
fi
else
check "rocminfo" "FAIL" "not installed"
fi
# ─────────────────────────────────────────────
# Summary
# ─────────────────────────────────────────────
echo ""
echo "============================================"
echo " Results: $PASS passed, $FAIL failed, $WARN warnings"
echo "============================================"
if [[ "$FAIL" -eq 0 ]]; then
echo " STATUS: READY — Run 07_run_hip_tests.sh for GPU compute tests"
else
echo " STATUS: ISSUES DETECTED — Review failures above"
fi
exit "$FAIL"
+188
View File
@@ -0,0 +1,188 @@
#!/bin/bash
# =============================================================================
# Step 7: Compile and Run HIP Tests — AMD BC-250
# =============================================================================
# Compiles and runs all 3 HIP test programs, plus a sequential stress test.
#
# Tests:
# 1. hip_probe — Device query, memory allocation (safe probe)
# 2. hip_minimal_test — Kernel launch, compute verification (32 values)
# 3. hip_vector_add — Full managed-memory vector addition (65536 elements)
# 4. Sequential stress — Run hip_vector_add 3 times back-to-back
#
# Run as: bash 07_run_hip_tests.sh
# =============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GUIDE_DIR="$(dirname "$SCRIPT_DIR")"
TESTS_DIR="$GUIDE_DIR/tests"
BUILD_DIR="$GUIDE_DIR/tests/bin"
# Ensure environment
export HSA_OVERRIDE_GFX_VERSION=10.1.0
export HIP_VISIBLE_DEVICES=0
export HSA_ENABLE_SDMA=0
export HSA_TOOLS_LIB=""
export HSA_TOOLS_REPORT_LOAD_FAILURE=0
PASS=0
FAIL=0
echo "============================================"
echo " HIP Test Suite — AMD BC-250"
echo "============================================"
echo ""
# ─────────────────────────────────────────────
# Compile
# ─────────────────────────────────────────────
echo "--- Compiling Tests ---"
mkdir -p "$BUILD_DIR"
TESTS=("hip_probe" "hip_minimal_test" "hip_vector_add")
for TEST in "${TESTS[@]}"; do
SRC="$TESTS_DIR/${TEST}.cpp"
BIN="$BUILD_DIR/$TEST"
if [[ ! -f "$SRC" ]]; then
echo " [SKIP] $TEST — source not found: $SRC"
continue
fi
echo " Compiling $TEST..."
if hipcc --offload-arch=gfx1010 -o "$BIN" "$SRC" 2>&1; then
echo " [OK] $TEST compiled ($(du -h "$BIN" | cut -f1))"
else
echo " [FAIL] $TEST compilation failed"
((FAIL++))
fi
done
echo ""
# ─────────────────────────────────────────────
# Test 1: hip_probe
# ─────────────────────────────────────────────
echo "--- Test 1: hip_probe ---"
BIN="$BUILD_DIR/hip_probe"
if [[ -x "$BIN" ]]; then
OUTPUT=$("$BIN" 2>&1) && RC=$? || RC=$?
echo "$OUTPUT" | head -20
if echo "$OUTPUT" | grep -q "ALL STEPS COMPLETED"; then
echo " [PASS] hip_probe"
((PASS++))
else
echo " [FAIL] hip_probe (exit code: $RC)"
((FAIL++))
fi
else
echo " [SKIP] Not compiled"
fi
echo ""
# ─────────────────────────────────────────────
# Test 2: hip_minimal_test
# ─────────────────────────────────────────────
echo "--- Test 2: hip_minimal_test ---"
BIN="$BUILD_DIR/hip_minimal_test"
if [[ -x "$BIN" ]]; then
OUTPUT=$("$BIN" 2>&1) && RC=$? || RC=$?
echo "$OUTPUT" | head -20
if echo "$OUTPUT" | grep -q "PASS"; then
echo " [PASS] hip_minimal_test"
((PASS++))
else
echo " [FAIL] hip_minimal_test (exit code: $RC)"
((FAIL++))
fi
else
echo " [SKIP] Not compiled"
fi
echo ""
# ─────────────────────────────────────────────
# Test 3: hip_vector_add
# ─────────────────────────────────────────────
echo "--- Test 3: hip_vector_add ---"
BIN="$BUILD_DIR/hip_vector_add"
if [[ -x "$BIN" ]]; then
OUTPUT=$("$BIN" 2>&1) && RC=$? || RC=$?
echo "$OUTPUT" | head -20
if echo "$OUTPUT" | grep -q "FULLY OPERATIONAL"; then
echo " [PASS] hip_vector_add"
((PASS++))
else
echo " [FAIL] hip_vector_add (exit code: $RC)"
((FAIL++))
fi
else
echo " [SKIP] Not compiled"
fi
echo ""
# ─────────────────────────────────────────────
# Test 4: Sequential Stress
# ─────────────────────────────────────────────
echo "--- Test 4: Sequential Stress (3 rounds) ---"
BIN="$BUILD_DIR/hip_vector_add"
if [[ -x "$BIN" ]]; then
STRESS_PASS=0
for i in 1 2 3; do
OUTPUT=$("$BIN" 2>&1) && RC=$? || RC=$?
if echo "$OUTPUT" | grep -q "FULLY OPERATIONAL"; then
echo " Round $i/3: PASS"
((STRESS_PASS++))
else
echo " Round $i/3: FAIL (exit code: $RC)"
fi
done
if [[ "$STRESS_PASS" -eq 3 ]]; then
echo " [PASS] Sequential stress: $STRESS_PASS/3"
((PASS++))
else
echo " [FAIL] Sequential stress: $STRESS_PASS/3"
((FAIL++))
fi
else
echo " [SKIP] hip_vector_add not compiled"
fi
echo ""
# ─────────────────────────────────────────────
# Final Check
# ─────────────────────────────────────────────
echo "--- Post-Test Stability ---"
KIQ_COUNT=$(dmesg 2>/dev/null | grep -c "timeout waiting for kiq fence" || echo 0)
echo " KIQ timeout count: $KIQ_COUNT"
ROCM_OK=$(HSA_OVERRIDE_GFX_VERSION=10.1.0 rocminfo 2>&1 | grep -c "Done" || echo 0)
if [[ "$ROCM_OK" -gt 0 ]]; then
echo " rocminfo: Still working"
((PASS++))
else
echo " rocminfo: FAILED after tests"
((FAIL++))
fi
echo ""
echo "============================================"
echo " Results: $PASS passed, $FAIL failed"
echo "============================================"
if [[ "$FAIL" -eq 0 ]]; then
echo ""
echo " ROCm is FULLY OPERATIONAL on your BC-250!"
echo ""
echo " Your GPU is ready for HIP compute workloads."
echo " See the README.md 'HIP Programming Guidelines' section"
echo " for BC-250-specific coding rules."
fi
exit "$FAIL"
+101
View File
@@ -0,0 +1,101 @@
#!/bin/bash
# =============================================================================
# GPU Watchdog for AMD BC-250 (Cyan Skillfish)
# =============================================================================
# Monitors kernel logs for KIQ fence timeouts and immediately kills the
# offending GPU process before the timeout cascade crashes the system.
#
# BC-250 Crash Pattern:
# 1st KIQ timeout → 12s → 2nd KIQ timeout → 12s → cascade → hard crash
# Window to act: ~10 seconds after first timeout
#
# Usage:
# ./gpu_watchdog.sh # Monitor and auto-kill
# ./gpu_watchdog.sh --dry-run # Monitor only, don't kill
# ./gpu_watchdog.sh --max-kiq 2 # Kill after 2 KIQ timeouts
# =============================================================================
set -euo pipefail
MAX_KIQ_TIMEOUTS=1
CHECK_INTERVAL=2
DRY_RUN=false
LOG_FILE="/tmp/gpu_watchdog.log"
while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run) DRY_RUN=true; shift ;;
--max-kiq) MAX_KIQ_TIMEOUTS="$2"; shift 2 ;;
--interval) CHECK_INTERVAL="$2"; shift 2 ;;
*) echo "Unknown: $1"; exit 1 ;;
esac
done
log() {
local msg="[$(date '+%H:%M:%S')] $1"
echo "$msg"
echo "$msg" >> "$LOG_FILE"
}
get_kiq_count() {
local count
count=$(journalctl -k -b --no-pager 2>/dev/null | grep -c "timeout waiting for kiq fence" | head -1 | tr -d '[:space:]')
echo "${count:-0}"
}
kill_gpu_processes() {
local pids
pids=$(fuser /dev/kfd 2>/dev/null || true)
pids=$(echo "$pids" | xargs)
if [[ -z "$pids" ]]; then
log "WARN: No GPU processes found"
return 1
fi
for pid in $pids; do
local name
name=$(ps -p "$pid" -o comm= 2>/dev/null || echo "?")
if [[ "$DRY_RUN" == "true" ]]; then
log "DRY-RUN: Would SIGKILL PID $pid ($name)"
else
log "SIGKILL PID $pid ($name)"
kill -9 "$pid" 2>/dev/null || true
fi
done
}
echo "=========================================="
echo " GPU Watchdog — AMD BC-250"
echo " Kill after: $MAX_KIQ_TIMEOUTS KIQ timeout(s)"
echo " Interval: ${CHECK_INTERVAL}s"
echo " Dry run: $DRY_RUN"
echo "=========================================="
log "Watchdog started"
INITIAL_KIQ=$(get_kiq_count)
PREV_KIQ=$INITIAL_KIQ
log "Baseline KIQ count: $INITIAL_KIQ"
[[ "$INITIAL_KIQ" -gt 0 ]] && log "WARNING: GPU already has $INITIAL_KIQ pre-existing KIQ timeouts"
while true; do
CUR=$(get_kiq_count)
NEW=$((CUR - INITIAL_KIQ))
if [[ "$CUR" -ne "$PREV_KIQ" ]]; then
log "!! KIQ timeout #$CUR (new=$NEW)"
if [[ "$NEW" -ge "$MAX_KIQ_TIMEOUTS" ]]; then
log "!!! THRESHOLD HIT — EMERGENCY KILL !!!"
kill_gpu_processes
log "GPU processes killed. Reboot needed for clean GPU."
INITIAL_KIQ=$CUR
log "Watchdog reset, continuing..."
fi
fi
PREV_KIQ=$CUR
sleep "$CHECK_INTERVAL"
done
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail
KVER=$(uname -r)
MODPATH="/lib/modules/$KVER/kernel/drivers/gpu/drm/amd/amdgpu"
echo "Kernel: $KVER"
echo "Module path: $MODPATH"
echo "--- Backup existing module ---"
sudo cp "$MODPATH/amdgpu.ko.zst" "$MODPATH/amdgpu.ko.zst.bak_2230"
echo "--- Install patched module (2500 MHz max) ---"
sudo cp /tmp/amdgpu_patched.ko.zst "$MODPATH/amdgpu.ko.zst"
echo "--- Verify ---"
ls -lh "$MODPATH/amdgpu.ko.zst" "$MODPATH/amdgpu.ko.zst.bak_2230"
echo "--- Running depmod ---"
sudo depmod -a
echo "--- Rebuilding initramfs ---"
sudo mkinitcpio -P
echo "DONE. Reboot required to load new module."
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail
KVER=$(uname -r)
MODPATH="/lib/modules/$KVER/kernel/drivers/gpu/drm/amd/amdgpu"
echo "Kernel: $KVER"
echo "Module path: $MODPATH"
echo "--- Install validation-patched module (2500 MHz range check) ---"
sudo cp /tmp/amdgpu_repatched.ko.zst "$MODPATH/amdgpu.ko.zst"
ls -lh "$MODPATH/amdgpu.ko.zst"
echo "--- Running depmod ---"
sudo depmod -a
echo "--- Rebuilding initramfs via limine-update ---"
sudo limine-update
echo "DONE. Reboot required."