| { | |
| "name": "loop_034", | |
| "op_type": "loop_034", | |
| "description": "Compare many short null-terminated strings for equality", | |
| "tags": [ | |
| "simd-loop" | |
| ], | |
| "axes": { | |
| "N": { | |
| "type": "var", | |
| "description": "Buffer length (bytes)" | |
| } | |
| }, | |
| "inputs": { | |
| "a": { | |
| "shape": [ | |
| "N" | |
| ], | |
| "dtype": "uint8" | |
| }, | |
| "b": { | |
| "shape": [ | |
| "N" | |
| ], | |
| "dtype": "uint8" | |
| } | |
| }, | |
| "outputs": { | |
| "checksum": { | |
| "shape": null, | |
| "dtype": "uint32", | |
| "description": "Scalar checksum" | |
| } | |
| }, | |
| "reference": "import numpy as np\n\ndef run(a, b):\n n = len(a); res = 0; cnt = 0; length = 13; off = 0\n while off < n:\n k = off\n while k < n and a[k] == b[k] and int(a[k]) != 0: k += 1\n av = int(a[k]) if k < n else 0\n bv = int(b[k]) if k < n else 0\n r = av - bv\n cmp = 2 if r > 0 else (3 if r < 0 else 1)\n res = (res + cnt * cmp) & 0xffffffff\n off += length; cnt += 1; length = 3 + (length + 11) % 43\n return np.uint32(res)\n", | |
| "simd_loop_meta": { | |
| "output_inplace": false, | |
| "array_pad": 0, | |
| "scratch": [], | |
| "axes_order": [] | |
| } | |
| } | |