MMX technology Overview
Intel's MMX & #8482; (Multimedia enhancement Instruction Set) technology can greatly improve application processing capabilities for 2D and 3D graphics and images. Intel MMX technology can be used for complex processing of large amounts of data and complex arrays. The basic units of data that can be processed using MMX technology can be byte, word ), or double-word ).
Visual Studio. NET 2003 provides support for MMX instruction set features, so that you can directly use C ++ code to implement MMX commands without having to write assembly code. By referring to Intel Software manuals [1] and reading the MMX programming technology topics in MSDN, you can better grasp the highlights of MMX programming.
MMX technology implements the Execution Mode of multiple data streams (SIMD, single-instruction, multiple-data) with single commands. Consider the following task to be programmed and add a number to each element in a BYTE array. In traditional programs, the algorithm for implementing this function is as follows:
For each B in array // for each element B in the array
B = B + n // Add the previous number n
Let's take a look at its implementation details:
For each B in array // for each element B in the array
{
Load B into the register
Add n to the number in this register
Return the result in the obtained register to the memory.
}
The processor with MMX instruction set support has eight 64-bit registers. Each register can store 8 bytes and 4 words) double-word ). The MMX technology also provides an MMX instruction set, where instructions can load a value (its type can be byte, word, or dual word) into these MMX registers, perform arithmetic or logical operations in the Register, and then put the results in the register back into the memory storage unit. The above example uses the MMX algorithm as follows:
For each 8 members in array // retrieves 8 bytes in the array (one of which is a unit in the array) as a group
{
Load these 8 bytes into the MMX register
Adds n to the 8 bytes in this register through a CPU instruction execution cycle
Write the calculation result in the register back to the memory.
}
C ++ programmers do not have to directly use commands in the MMX instruction set to access these MMX registers. You can use the 64-Bit Data Type _ m64 and a series of C ++ functions for related arithmetic and logical operations. It determines which MMX register the program uses and code optimization is a C ++ compiler task.
Visual C ++ MMXSwarm [4] is a good example of Image Processing Using MMX technology provided by MSDN. It contains encapsulated classes that simplify operations using MMX technology, it also shows you how to process images of different formats (such as 24-bit RGB and 32-bit RGB ). This article is just a brief introduction to MMX Program Design Using Visual C ++. If you are interested, refer to the MMXSwarm example on MSDN.