hawk.scatter

Contents

hawk.scatter#

hawk.scatter(sink, policy='auto')[source]#

hawk.scatter(sink)[key] += v adds v into sink at key, = v stores it there. Many lanes may share a key; the adds are combined (atomics or a segmented sum), never a race; the order is not fixed unless policy="ordered": then each key’s adds are made in lane order within fixed lane chunks and the chunks are added in order (no atomics: the same bits on every launch for one lane count and one target size, ULP of np.add.at otherwise). A scalar or vector payload; any number of such statements, and in a for of static trip; a lane that skips it (a masked or index-set lane) adds nothing, and a negative key adds nothing (under policy="ordered" only -1 is the skip key: any other key outside the target is reported by name). "auto" and "compensated" add with a correction kept in a companion plane <sink>_c that the runtime owns (the caller never passes it); "plain" is the atomic add alone. key is an index, one coordinate per axis of a sink declared with named axes, an Index plane or a Sorted[Index] one. hawk.scatter(mask, policy="or")[word] |= bits sets bits of an Int32 or UInt32 plane (a bit mask: the word index is the key): the commit is the target’s atomic OR, so any number of lanes may hit one word and the result is the exact np.bitwise_or.at; the C target ORs serially. A bit mask is discrete: vjp and jvp of a kernel that writes one refuse by name. Written only as the target of a store in a kernel body.

Return type:

Any

Parameters:
  • sink (Any)

  • policy (str)