Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/openaccel-lab/blob/main/workloads/reduce_sum/triton_kernel.py # openaccel-lab aien-dev/openaccel-lab Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `openaccel-lab / workloads / reduce_sum / triton_kernel.py` 18 lines ยท 529 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 2 import triton 3 import triton.language as tl 4 5 6 @triton.jit 7 def _rsum(x, y, n, BLOCK: tl.constexpr): 8 # one program: BLOCK lane accumulators over the strided input, then a tree sum of the lanes 9 lane = tl.arange(0, BLOCK) 10 acc = tl.zeros([BLOCK], dtype=tl.float32) 11 for off in range(0, n, BLOCK): 12 i = off + lane 13 acc += tl.load(x + i, mask=i < n, other=0.0) 14 tl.store(y, tl.sum(acc, axis=0)) 15 16 17 def launch(p, t): 18 _rsum[(1,)](t["x"], t["y"], p["n"], BLOCK=4096)