46 lines
2.2 KiB
Bash
Executable file
46 lines
2.2 KiB
Bash
Executable file
#!/bin/sh
|
|
set -eu
|
|
|
|
[ "$#" -eq 1 ] || { echo "usage: $0 ANALYZER" >&2; exit 2; }
|
|
analyzer=$1
|
|
fixture=$(mktemp -d /private/tmp/gem-metal-counter-analysis.XXXXXX)
|
|
trap 'rm -rf "$fixture"' EXIT INT TERM HUP
|
|
|
|
jq -n '
|
|
{schema_version: 1, workload: "metal-counter-info",
|
|
device: {name: "fixture", architecture: "fixture", registry_id: 1,
|
|
has_unified_memory: true, recommended_max_working_set_bytes: 1,
|
|
max_threadgroup_memory_bytes: 32768,
|
|
max_threads_per_threadgroup: {width: 1024, height: 1024, depth: 1024},
|
|
gpu_families: {apple7: true, apple8: true, apple9: true, apple10: false}},
|
|
sampling_points: {stage_boundary: true, draw_boundary: false,
|
|
dispatch_boundary: true, tile_dispatch_boundary: false,
|
|
blit_boundary: false},
|
|
counter_sets: [{name: "timestamp", counters: ["timestamp"]}]}
|
|
' > "$fixture/timestamp.json"
|
|
"$analyzer" "$fixture/timestamp.json" "$fixture/timestamp-analysis.json"
|
|
jq -e '
|
|
.capabilities.timestamp == true and .capabilities.occupancy == false and
|
|
.capabilities.bandwidth == false and .capabilities.limiter_or_stall == false and
|
|
.instrumentation.stage_timestamps_available == true and
|
|
.instrumentation.dispatch_performance_counters_available == false and
|
|
.instrumentation.selected == "stage-timestamps-plus-xcode-gpu-trace"
|
|
' "$fixture/timestamp-analysis.json" >/dev/null
|
|
|
|
jq '.counter_sets += [{name: "performance", counters:
|
|
["GPU Occupancy", "Device Memory Read Bytes", "ALU Limiter"]}]' \
|
|
"$fixture/timestamp.json" > "$fixture/performance.json"
|
|
"$analyzer" "$fixture/performance.json" "$fixture/performance-analysis.json"
|
|
jq -e '
|
|
.capabilities == {timestamp: true, occupancy: true, bandwidth: true,
|
|
limiter_or_stall: true} and
|
|
.instrumentation.dispatch_performance_counters_available == true and
|
|
.instrumentation.selected == "public-dispatch-counter-sampling"
|
|
' "$fixture/performance-analysis.json" >/dev/null
|
|
|
|
jq '.device.gpu_families.apple9 = false' "$fixture/timestamp.json" \
|
|
> "$fixture/wrong-device.json"
|
|
if "$analyzer" "$fixture/wrong-device.json" >/dev/null 2>&1; then
|
|
echo "non-Apple9 counter inventory was accepted" >&2
|
|
exit 1
|
|
fi
|