openaccel-lab
aien-dev/openaccel-lab
Brought by drakestapleton
openaccel-lab / workloads / argmax / workload.json
| 1 | { |
| 2 | "name": "argmax", |
| 3 | "family": "reduction", |
| 4 | "summary": "y[0] = index of the first maximum of n f32 elements (grid inputs repeat values, so ties are common); OpenCL/CUDA reduce (value, index) pairs in a 256-wide local tree per block, then one block reduces the block partials", |
| 5 | "provenance": "authored for OpenAccel Lab (Apache-2.0)", |
| 6 | "params": { |
| 7 | "n": 100003 |
| 8 | }, |
| 9 | "derived": { |
| 10 | "nb": "(n + 255) // 256" |
| 11 | }, |
| 12 | "cases": [ |
| 13 | {}, |
| 14 | {"n": 1}, |
| 15 | {"n": 257} |
| 16 | ], |
| 17 | "shrink": { |
| 18 | "n": {"min": 1} |
| 19 | }, |
| 20 | "inputs": [ |
| 21 | {"name": "x", "dtype": "f32", "shape": ["n"], "gen": {"kind": "grid", "klo": -40, "khi": 40, "shift": 3}} |
| 22 | ], |
| 23 | "outputs": [ |
| 24 | {"name": "y", "dtype": "i32", "shape": [1]} |
| 25 | ], |
| 26 | "scratch": [ |
| 27 | {"name": "pval", "dtype": "f32", "shape": ["nb"]}, |
| 28 | {"name": "pidx", "dtype": "i32", "shape": ["nb"]} |
| 29 | ], |
| 30 | "tolerance": { |
| 31 | "y": { |
| 32 | "kind": "int", |
| 33 | "atol": 0, |
| 34 | "why": "integer index, exact: the first index i with x[i] equal to the maximum (numpy argmax). With 81 grid values each occurs about n/81 times, so a kernel that keeps any but the first maximum fails" |
| 35 | } |
| 36 | }, |
| 37 | "timing": {"warmup": 1, "repeats": 5}, |
| 38 | "backends": { |
| 39 | "omega": {"src": "omega.om"}, |
| 40 | "opencl": { |
| 41 | "src": "kernel.cl", |
| 42 | "launches": [ |
| 43 | {"kernel": "amax_part", "global": ["nb * 256"], "local": [256], "args": ["x", "pval", "pidx", "n", "local:f32:256", "local:i32:256"]}, |
| 44 | {"kernel": "amax_fin", "global": [256], "local": [256], "args": ["pval", "pidx", "y", "nb", "local:f32:256", "local:i32:256"]} |
| 45 | ] |
| 46 | }, |
| 47 | "triton": {"src": "triton_kernel.py"}, |
| 48 | "cuda": {"src": "kernel.cu"} |
| 49 | } |
| 50 | } |