#!/bin/bash # cu_map.sh — Read and display CU bitmap from DRM ioctl via libdrm. # # Optional health overlay: # ./cu_map.sh --health /var/lib/bc250-cu-health-test/results.tsv set -euo pipefail HEALTH="${BC250_CU_HEALTH_RESULTS:-/var/lib/bc250-cu-health-test/results.tsv}" while [ "$#" -gt 0 ]; do case "$1" in --health) HEALTH="${2:?missing value for --health}" shift 2 ;; --no-health) HEALTH="" shift ;; -h|--help) sed -n '1,10p' "$0" exit 0 ;; *) echo "ERROR: unknown argument: $1" >&2 exit 2 ;; esac done BC250_CU_HEALTH_RESULTS="$HEALTH" python3 << 'PYEOF' import ctypes, struct, os, sys libdrm = ctypes.CDLL("libdrm_amdgpu.so.1") fd = os.open("/dev/dri/renderD128", os.O_RDWR) dev = ctypes.c_void_p() maj, min_ = ctypes.c_uint32(), ctypes.c_uint32() libdrm.amdgpu_device_initialize(fd, ctypes.byref(maj), ctypes.byref(min_), ctypes.byref(dev)) buf = (ctypes.c_uint8 * 1024)() libdrm.amdgpu_query_info(dev, 0x16, 1024, ctypes.byref(buf)) raw = bytes(buf) num_se = struct.unpack_from('