test.md

September 2, 2022 ยท View on GitHub

The following files contain C code (hopefully) equivalent to the AMX instructions:

FileContents
emulate.hCommon definitions and routines
ldst.cldx, ldy, ldz, ldzi, stx, sty, stz, stzi
extr.cextrx, extry, extrh, extrv
fma.cfma16, fma32, fma64
fms.cfms16, fms32, fms64
genlut.cgenlut
mac16.cmac16
matfp.cmatfp
matint.cmatint
vecfp.cvecfp
vecint.cvecint

The file test.c contains a very simple test harness that generates a bunch of random operands, and asserts that the behaviour of the above files matches the behaviour of the AMX instructions. This test harness requires an Apple Silicon machine, as otherwise the AMX instructions are not available to test against.

A very simple Makefile is provided to compile all of the above. Running make test should output:

Testing AMX_LDX... OK   
Testing AMX_LDY... OK   
Testing AMX_LDZ... OK   
Testing AMX_LDZI... OK   
Testing AMX_STX... OK   
Testing AMX_STY... OK   
Testing AMX_STZ... OK   
Testing AMX_STZI... OK   
Testing AMX_EXTRX... OK   
Testing AMX_EXTRY... OK   
Testing AMX_MAC16... OK   
Testing AMX_FMA16... OK   
Testing AMX_FMA32... OK   
Testing AMX_FMA64... OK   
Testing AMX_FMS16... OK   
Testing AMX_FMS32... OK   
Testing AMX_FMS64... OK   
Testing AMX_VECINT... OK   
Testing AMX_VECFP... OK   
Testing AMX_MATINT... OK   
Testing AMX_MATFP... OK   
Testing AMX_GENLUT... OK