Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

From: Florian Weimer
Date: Mon May 17 2021 - 05:57:18 EST


* Thomas Gleixner:

> Having a proper interface (syscall, prctl) which user space can use to
> ask for permission and allocation of the necessary buffer(s) is clearly
> avoiding the downsides and provides the necessary mechanisms for proper
> control and failure handling.
>
> It's not the end of the world if something which wants to utilize this
> has do issue a syscall during detection. It does not matter whether
> that's a library or just the application code itself.
>
> That's a one off operation and every involved entity can cache the
> result in TLS.

I'm not sure if it's a good idea to have each AMX consumer to set up its
own TLS cache. How expensive is checking XCR0 via XGETBV instead on the
AMX path? Then AMX can be enabled on the thread via a system call. It
also allows disabling of AMX.

It would also need an AT_HWCAP2 feature flag telling user space that AMX
support is available after that system call (switching on AMX to check
whether AMX paths should enabled later seems potentially wasteful if the
AMX paths are never taken after all).

Thanks,
Florian