Date: Wed, 19 Jun 2019 10:04:07 +0100 From: Steve O'Hara-Smith <steve@sohara.org> To: mayuresh@kathe.in Cc: freebsd-questions@freebsd.org Subject: Re: How are modern processor instructions exposed to userland? Message-ID: <20190619100407.2e730ae147d87894e9479e23@sohara.org> In-Reply-To: <4b320042bd82ffe9b7793b62719d06f0@kathe.in> References: <4b320042bd82ffe9b7793b62719d06f0@kathe.in>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 19 Jun 2019 11:58:23 +0530 Mayuresh Kathe <mayuresh@kathe.in> wrote: > Hello, > > I have been wondering about this, and couldn't find an answer on the Web > because I didn't know what to search for. > > Let's think about the AVX-512 instruction introduced with the latest > Intel Core i9 Skylake-X processor. > I wanted to know how one could use such capabilities via regular C. The usual way that processor features get exposed is by being used in the implementation of low level routines. Depending on the application there may be run or compile time detection of CPU and choice of implementation (mplayer/mencoder offers both in its build). > There should be some way, someone working on the FreeBSD core who would > expose that instruction capability to the userland via libc, right? Not necessarily libc and not usually the instruction directly, but if it is worthwhile some functions may grow implementation versions based on the new instruction to be used when that CPU is available. Other approaches are used sometimes, for example the hardware crypto engine in some processors is exposed via a device with a fallback software implementation in the kernel. Kernel code and a user/kernel interface will be needed whenever the instruction is privileged. The principle is the same the new feature is used to conditionally implement an API for which there are fallback implementations for CPUs without the new feature. The fine details vary feature by feature. > If my assumption is correct, may I know who does that? And, how do they > go about doing it? Either by writing assembler that implements entry points with the C calling conventions or using the C extensions that allow embedded assembler. > Obviously, knowledge of x86-64 assembler would be a must, so would > knowledge of C89; right? Yep. -- Steve O'Hara-Smith <steve@sohara.org>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190619100407.2e730ae147d87894e9479e23>