Skip to content

Commit 2a21d7c

Browse files
committed
Add 2d tree reduce
1 parent a11ff84 commit 2a21d7c

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
# E2E test: pipelined 2-D binary-tree reduction ((2^LX)*(2^LY) PEs, K elements per PE).
3+
# Kernel: tree_reduce_2D.sptl params: LX LY K
4+
# Reference: OUT_out[0,0,:] == sum(a_in[:,:,:])
5+
6+
set -e
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
. "$SCRIPT_DIR/_lib.sh"
9+
10+
LX=2 # 2^LX = 4 PEs in X
11+
LY=2 # 2^LY = 4 PEs in Y
12+
K=4
13+
FOLDER="tree_reduce_2d_sptl"
14+
15+
sptlc "$COLLECTIVES_DIR/tree_reduce_2D.sptl" "$FOLDER" -p LX=$LX -p LY=$LY -p K=$K
16+
17+
python3 - <<PYEOF
18+
import numpy as np
19+
nx = 1 << $LX # 2^LX
20+
ny = 1 << $LY # 2^LY
21+
a = np.random.rand(nx, ny, $K).astype(np.float32)
22+
np.save('a_in.npy', a)
23+
PYEOF
24+
25+
timeout -s 9 120 cs_python "$RUNTIME_PY" "$FOLDER" a_in.npy --benchmark
26+
27+
verify_reduce_sum_2d
28+
cleanup "$FOLDER"

0 commit comments

Comments
 (0)