3 ms·
Because the binary might contain a JIT, or even more simply, it might load a DLL with new code.
by deadbeeves 3y ago
Because the binary might contain a JIT, or even more simply, it might load a DLL with new code.
- mjan22640 3y agoBoth the library and the AVX512 generating JIT binary would have the arch set to AVX512 in the executable format header.
- deadbeeves 3y agoWell, but what if it doesn't? Also, who's supposed to set that bit? The programmer, or the compiler? In either case it's possible to set it wrong.
- mjan22640 3y agoIf the compiler generates the instructions, the compiler has to set the correct arch, if the JIT does that, the author has to override the arch in the build scripts. If the arch is incorrect, it is a bug, and program will crash on illegal instruction. Ie like if you had an ARM binary that was incorrectly set to x64 and was run on x64.
- deadbeeves 3y agoThis isn't an architecture, though. It's an instruction set. What if the JIT generates new instructions dynamically and initially there are no AVX512 instructions but later on in the process' lifetime there are?
- Veliladon 3y agoThen it crashes with an illegal instruction exception.
- mjan22640 3y agoThe instruction set is the major part of an architecture spec from the point of view of an userspace application. You can design the binary header flags to express instruction sub/set when you find that reasonable. In any case, regardless if the instructions are hardcoded to the text or generated during the runtime, you need to communicate the intention to use the specific instruction set to the kernel, so it can schedule your process on appropriate cores, and check if there are such cores present in the first place.