I have already known SIMD instructions sets contains SSE1 to SSE5.
But not found too much talk about any instruction sets support MIMD arch.
In c++ code , we can use intrinsic to write "SIMD running" code.
Is there any way to write "MIMD running" code ?
If MIMD is more powerful than SIMD,
it is better to write c++ code support MIMD.
Is my thought correct ?
问题:
回答1:
The Wikipedia page Flynn's taxonomy describes MIMD as:
Multiple autonomous processors simultaneously executing different instructions on different data. MIMD architectures include multi-core superscalar processors, and distributed systems, using either one shared memory space or a distributed memory space.
Any time you divide an algorithm (such as into threads using OpenMP, for example), you may be using MIMD. Generally, you don't need a special "MIMD instruction set" - the ISA is the same as for SISD, as each instruction stream operates independently of the others, on its own data. EPIC (explicitly parallel instruction computing) is an alternative approach where the functional units operate in lockstep, but with independent(ish) instructions and data.
As to which is "more powerful" (or more energy-efficient, or lowest latency, or whatever matters in your use case), there's no single answer. As with many complex issues, "it depends".
回答2:
Is my thought correct ?
It is certainly naive, and implementation specific. Remember the following facts:
optimizing compilers generate very clever code (when you enable optimizations). Try for example some recent GCC invoked as
g++ -march=native -O3 -Wall
(and perhaps also-fverbose-asm -S
if you want to look into the generated assembler code); see CppCon 2017: Matt Godbolt's talk “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”there are some extensions (done thru standardized pragmas) to improve optimizations for MIMD, look into OpenMP, OpenACC.
consider explicit parallelization approaches: multi-threading (read some pthread programming tutorial), MPI...
look also into dialects for GPGPU computing like OpenCL & CUDA.
See also this answer to a related question.
If MIMD is more powerful than SIMD, it is better to write c++ code support MIMD.
Certainly not always, if you just care about performance. As usual, it depends, and you need to benchmark.