#!/bin/sh # op_inventory.sh -- the op vocabulary as a markdown table, for docs/SYCL_PORTING.md. # # One row per op that libref or libr4d declares: whether libref has it (the oracle), the libr4d # kernels that implement it (from the kKernels rows in libr4d/r4d_rows.cpp, read as source because a # build without HIP has no libr4d.so), the dtypes those rows state, and the architecture plugins # whose source names the op. "Architectures naming it" is a grep, so it over-counts an op a plugin # names only conditionally; --debug-graph on a real container is the exact answer for one model. # # Usage: scripts/sycl/op_inventory.sh [BUILD_DIR] (default build/) set -e root=$(cd "$(dirname "$0")/../.." && pwd) build=${1:-$root/build} tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT RADIANCE_HOME=$build/radiance_home "$build/bin/rad-schemas" "$build/radiance_home/kernels/libref.so" | awk '/^ [a-z0-9_]+$/ {print $1}' | sort -u > "$tmp/libref" python3 -I "$root/scripts/sycl/r4d_rows.py" "$root/libr4d/r4d_rows.cpp" | sort > "$tmp/r4d" cut -f1 "$tmp/r4d" | sort -u > "$tmp/r4d_ops" sort -u "$tmp/libref" "$tmp/r4d_ops" > "$tmp/all" echo "| op | libref | libr4d kernels | libr4d dtypes (first three rows' prose) | architectures naming it |" echo "|---|---|---|---|---|" while read -r op; do ref=no; grep -qx "$op" "$tmp/libref" && ref=yes kern=$(awk -F'\t' -v o="$op" '$1 == o {print $2}' "$tmp/r4d" | tr '\n' ' ' | sed 's/ $//; s/ /, /g') dts=$(awk -F'\t' -v o="$op" '$1 == o && $3 != "" {print $3}' "$tmp/r4d" | sort -u | head -3 | tr '\n' ';' | sed 's/;$//; s/;/; /g; s/|/\\|/g') archs=$(grep -rlw --include=*.cpp --include=*.h -e "\"$op\"" "$root/arch" 2>/dev/null | sed "s#$root/arch/##; s#/.*##" | sort -u | tr '\n' ' ' | sed 's/ $//; s/ /, /g') [ -z "$kern" ] && kern="--" [ -z "$archs" ] && archs="--" echo "| \`$op\` | $ref | $kern | $dts | $archs |" done < "$tmp/all"