Skip to content

Commit 5f4e78b

Browse files
author
echo_stone
committed
add scripts for async demo test
1 parent 54c8d44 commit 5f4e78b

1 file changed

Lines changed: 121 additions & 0 deletions

File tree

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
6+
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../.." && pwd)"
7+
8+
DEVICE_LIST="6,7"
9+
PLATFORM="a2a3"
10+
PTO_ISA_COMMIT=""
11+
CLONE_PROTOCOL="https"
12+
CANN_ENV_SCRIPT="${CANN_ENV_SCRIPT:-}"
13+
14+
usage() {
15+
cat <<'EOF'
16+
Usage: examples/scripts/run_async_tests.sh [options]
17+
18+
Run the two async distributed hardware test cases:
19+
1. async_completion_demo
20+
2. async_notify_demo
21+
22+
Options:
23+
--devices <list> Device list for distributed run (default: 6,7)
24+
--platform <name> Platform passed to run_example.py (default: a2a3)
25+
--pto-isa-commit <sha> PTO-ISA commit to pin (default: latest)
26+
--clone-protocol <proto> PTO-ISA clone protocol: ssh|https (default: https)
27+
--cann-env <path> CANN environment script to source
28+
-h, --help Show this help
29+
30+
Examples:
31+
CANN_ENV_SCRIPT=/path/to/set_env.sh examples/scripts/run_async_tests.sh
32+
examples/scripts/run_async_tests.sh --devices 6,7 --cann-env /path/to/set_env.sh
33+
EOF
34+
}
35+
36+
while [[ $# -gt 0 ]]; do
37+
case "$1" in
38+
--devices)
39+
DEVICE_LIST="$2"
40+
shift 2
41+
;;
42+
--platform)
43+
PLATFORM="$2"
44+
shift 2
45+
;;
46+
--pto-isa-commit)
47+
PTO_ISA_COMMIT="$2"
48+
shift 2
49+
;;
50+
--clone-protocol)
51+
CLONE_PROTOCOL="$2"
52+
shift 2
53+
;;
54+
--cann-env)
55+
CANN_ENV_SCRIPT="$2"
56+
shift 2
57+
;;
58+
-h|--help)
59+
usage
60+
exit 0
61+
;;
62+
*)
63+
echo "Unknown argument: $1" >&2
64+
usage >&2
65+
exit 1
66+
;;
67+
esac
68+
done
69+
70+
if [[ -z "${CANN_ENV_SCRIPT}" ]]; then
71+
echo "CANN env script is required. Pass --cann-env or set CANN_ENV_SCRIPT." >&2
72+
exit 1
73+
fi
74+
75+
if [[ ! -f "${CANN_ENV_SCRIPT}" ]]; then
76+
echo "CANN env script not found: ${CANN_ENV_SCRIPT}" >&2
77+
exit 1
78+
fi
79+
80+
source "${CANN_ENV_SCRIPT}"
81+
export PTO_PLATFORM="${PLATFORM}"
82+
83+
run_case() {
84+
local name="$1"
85+
local kernels="$2"
86+
local golden="$3"
87+
local -a cmd
88+
89+
echo
90+
echo "============================================================"
91+
echo "Running ${name}"
92+
echo "============================================================"
93+
94+
cmd=(
95+
python "${REPO_ROOT}/examples/scripts/run_example.py"
96+
-k "${kernels}"
97+
-g "${golden}"
98+
-p "${PLATFORM}"
99+
--devices "${DEVICE_LIST}"
100+
--clone-protocol "${CLONE_PROTOCOL}"
101+
)
102+
103+
if [[ -n "${PTO_ISA_COMMIT}" ]]; then
104+
cmd+=(-c "${PTO_ISA_COMMIT}")
105+
fi
106+
107+
"${cmd[@]}"
108+
}
109+
110+
run_case \
111+
"async_completion_demo" \
112+
"${REPO_ROOT}/examples/a2a3/tensormap_and_ringbuffer/async_completion_demo/kernels" \
113+
"${REPO_ROOT}/examples/a2a3/tensormap_and_ringbuffer/async_completion_demo/golden.py"
114+
115+
run_case \
116+
"async_notify_demo" \
117+
"${REPO_ROOT}/examples/a2a3/tensormap_and_ringbuffer/async_notify_demo/kernels" \
118+
"${REPO_ROOT}/examples/a2a3/tensormap_and_ringbuffer/async_notify_demo/golden.py"
119+
120+
echo
121+
echo "All async tests passed."

0 commit comments

Comments
 (0)