interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / workloads / reduce_max / triton_kernel.py

18 lines · 563 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0
2import triton
3import triton.language as tl
4
5
6@triton.jit
7def _rmax(x, y, n, BLOCK: tl.constexpr):
8 # one program: BLOCK lane maxima over the strided input, then a tree max of the lanes
9 lane = tl.arange(0, BLOCK)
10 acc = tl.full([BLOCK], float("-inf"), dtype=tl.float32)
11 for off in range(0, n, BLOCK):
12 i = off + lane
13 acc = tl.maximum(acc, tl.load(x + i, mask=i < n, other=float("-inf")))
14 tl.store(y, tl.max(acc, axis=0))
15
16
17def launch(p, t):
18 _rmax[(1,)](t["x"], t["y"], p["n"], BLOCK=4096)