Skip to content

Instantly share code, notes, and snippets.

View moon-chilled's full-sized avatar

moon-chilled

View GitHub Profile
@moon-chilled
moon-chilled / pointer-publication.s
Last active March 18, 2024 05:43
bad but cute implementation strategies for safe pointer publication
// aarch64 assumed, but reasonably general
// x0: address of object to be initialised; x1, x2, x3, values to use to initialise its first three slots
// we want to ensure no other thread ever sees an unitialised x0
// the dumb way: fence
str x1, [x0]
str x2, [x0, 8]
str x3, [x0, 16]
dmb ishst
@moon-chilled
moon-chilled / macaroni-jam.asm
Last active June 21, 2023 00:04
funny prototype 48-bit umac with floating point I got bored with before finishing
;; hash based on fp multiply
;; first we need to make our integers into normal floats (since denormals cost on skx)
;; we can vcvtuqq2pd to get a normal float incorporating at least the top 53 bits of the input (todo could maybe get 54 bits with signed vcvtqq2pd; worth looking into?); it remains to ensure we take account of the low 11 bits
;; we handle three vectors at a time, as follows
;; a: oxxx oxxx oxxx oxxx oxxx oxxx oxxx oxxx
;; b: oxxx oxxx oxxx oxxx oxxx oxxx oxxx oxxx
;; c: oxxx oxxx oxxx oxxx oxxx oxxx oxxx oxxx
;;
;; d: ooo- ooo- ooo- ooo- ooo- ooo- ooo- ooo-
;; a, b, and c are the inputs; the xes are the 16-bit quantities that vcvtuqq2pd incorporates; the os are the 16-bit quantities which it does not; we want to pack the os into d