Files

13 lines
904 B
Bash

#!/usr/bin/env bash
# cupti_trigger.sh SECONDS LABEL [TRIGGER_FILE] : ask the injected CUPTI tracer (tools/cupti-trace, claude/ledger) of the running
# leleka-inference to record SECONDS (max 120) of kernels/copies/syncs. Atomic write; logs the unix ms of the request to
# $(dirname TRIGGER)/windows.log so the window can be joined with leleka-api.log. The tracer writes <out>.lct/ and <out>.done.
sec=${1:?seconds}; label=${2:?label}
trigger=${3:-$HOME/work/codex-e2e/cupti/cupti.trigger}
dir=$(dirname "$trigger"); mkdir -p "$dir"
out="$dir/win-$(date -u +%H%M%S)-$(echo "$label" | tr -c 'A-Za-z0-9' '_')"
[ -e "$trigger" ] && { echo "a trigger is already pending"; exit 1; }
printf '{"seconds": %s, "out": "%s", "label": "%s"}\n' "$sec" "$out" "$label" >"$trigger.tmp" && mv "$trigger.tmp" "$trigger"
echo "$(date +%s%3N) requested seconds=$sec out=$out label=$label" >>"$dir/windows.log"
echo "$out"