[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to write optimized code for an instruction set not supported by my computer?

On Thu, Nov 05, 2015 at 04:33:02PM -0600, Mario Castelán Castro wrote:


What is the usual workflow to write code that takes advantage of an instruction set that is not present in my computer (either in assembly or using intrinsic functions that represent those instructions in an higher level language)?. For example, if I want to write code for decoding and encoding Base64 that uses AVX instructions in my machine that has no support for any version of AVX (only SSE 4.2 and CLMUL), what is the recommended workflow?.

Is the intention to eventually run this code on a system that does support that instruction? If so, then yes, emulation should do the job. As you mention, it will be slower than native, but it will execute enough for debugging.

If you only ever intend to run it on a machine that doesn't support that instruction then... what's the point?

It seems like I *could* develop within a virtual machine emulated with Bochs that supports these instructions, but that would give a very big overhead, since I would have to emulate a whole system, and Bochs has no multithreading support (so that will make it less efficient if I want to write multithreaded code). Is there a better option?

I doubt that, even if the Bochs emulator is single-threaded, it doesn't support multiple threads in the emulated system. The nature of threads is that they're handled by the kernel, rather than the CPU.

Another alternative would be QEMU, which allows you to assign multiple vCPUs to a system.

Regards and thanks in advance.

-- For more information, please reread.

Attachment: signature.asc
Description: PGP signature

Reply to: