I have already known SIMD instructions sets contains SSE1 to SSE5.<br /> But not found too much talk about any instruction sets support MIMD arch.<br /> In c++ code , we can use intrinsic to write "SIMD running" code.<br /> Is there any way to write "MIMD running" code ?<br /> If MIMD is more powerful than SIMD, it is better to write c++ code support MIMD.<br /> Is my thought correct ?Answer1:
The Wikipedia page <a href="https://en.wikipedia.org/wiki/Flynn%27s_taxonomy#Multiple_instruction_streams,_multiple_data_streams_(MIMD)" rel="nofollow">Flynn's taxonomy</a> describes MIMD as:<blockquote>
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.</blockquote>
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".Answer2:
Is my thought correct ?</blockquote>
It is certainly naive, and implementation specific. Remember the following facts:<ul><li>
<a href="https://en.wikipedia.org/wiki/Optimizing_compiler" rel="nofollow">optimizing compilers</a> generate very clever code (when you <a href="https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html" rel="nofollow">enable</a> optimizations). Try for example some recent <a href="http://gcc.gnu.org/" rel="nofollow">GCC</a> 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 <a href="https://youtu.be/bSkpMdDe4g4" rel="nofollow">talk</a> <em>“What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”</em>
there are some extensions (done thru standardized pragmas) to improve optimizations for MIMD, look into <a href="https://en.wikipedia.org/wiki/OpenMP" rel="nofollow">OpenMP</a>, <a href="https://en.wikipedia.org/wiki/OpenACC" rel="nofollow">OpenACC</a>.</li> <li>
consider explicit parallelization approaches: multi-threading (read some <a href="https://computing.llnl.gov/tutorials/pthreads/" rel="nofollow">pthread programming</a> tutorial), <a href="https://en.wikipedia.org/wiki/Message_Passing_Interface" rel="nofollow">MPI</a>...</li> <li>
look also into dialects for GPGPU computing like <a href="https://en.wikipedia.org/wiki/OpenCL" rel="nofollow">OpenCL</a> & <a href="https://en.wikipedia.org/wiki/CUDA" rel="nofollow">CUDA</a>.</li> </ul>
See also <a href="https://stackoverflow.com/a/47528068/841108" rel="nofollow">this answer</a> to a related question.<blockquote>
If MIMD is more powerful than SIMD, it is better to write c++ code support MIMD.</blockquote>
Certainly not always, if you just care about performance. As usual, it depends, and you need to benchmark.