HPMC User Guide v 1.00
© 2026 Bassem W. Jamaleddine


3-4

   MIC Architecture Superscalar and Pipelines


In the previous subchapter "MIC Cores Threads and Cache Organization", we have seen the MIC architecture from an administrative point of view: the cores and their logical processors as laid out in a ring topology to interact with shared memory. We also showed how to execute intrinsic instructions on the 512-bit vectors of the VPU.

In this section, we will look at the vector processing unit and its pipelines, you will gain basic understanding on the importance of using homogeneous data type in your code to avoid extra clock cycles penalty.

■ MIC's cores VPUs and the Vector Execution Pipelines


Each VPU instruction passes through one or more of the following five pipelines to completion:
  • Double-precision (DP) pipeline executes float64 arithmetic, conversion from float64 to float32, and DP-compare instructions.
  • Single-precision (SP) pipeline Executes most of the instructions including 64-bit integer loads, float32/int32 arithmetic and logical operations, shuffle/broadcast, loadunpack, type conversions from float32/int32 pipelines, extended math unit (EMU) transcendental instructions, int64 loads, int64/float64 logical, and other instructions.
  • Mask pipeline executes mask instructions with 1-cycle latency.
  • Store pipeline executes the vector store operations.
  • Scatter/gather pipeline executes the vector register read/writes from sparse memory locations.


  • Because there are no bypasses between the DP pipeline and the SP pipeline, it is recommended to keep your data type consistent to take advantage of the MIC vector processing. Say you have an instruction in the DP pipeline, followed by a dependent instruction executing in an SP pipeline, the DP instruction has to complete the write before the dependent SP instruction can execute. The SP instruction is stalled until the DP instruction completes its write back, incurring the full 7-cycle delay.

    The vector pipeline stages relative to the core pipeline:
     +-----------+   +-----------+   +-----------+   +-----------+   +-----------+   +-----------+   +-----------+
     |Per Thread |   | Thread    |   |Decode     |   |Instruction|   | Microcode |   |           |   |  Write    |
     |Picker     +-->| Picker    +-->|Prefixes   +-->|Decode     +-->| Control   +-->| EXECUTION +-->|  Back     |
     |Function   |   | Function  |   | (D0)      |   |(D1)       |   |  (D2)     |   |   (E)     |   |  (WB)     |
     |(PPF)      |   | (PF)      |   |           |   |           |   |           |   |           |   |           |
     +-----------+   +-----------+   +-----------+   +-----------+   +-----------+   +-----+-----+   +-----------+
                                                                                           |
                                                                                           v
                                                                          +----VECTOR EXECUTION PIPELINE----+
                                                                          | E       detects dependency stall|
                                                                          | VC1-VC2 shuffle/load conversion |
                                                                          | V1-V4   four cycles multiply/add|
                                                                          +---------------------------------+
    
    Shown below the execution of two independent SP/SP instructions, where the pipeline can throughput 1 instruction per cycle, with each instruction execution incurring a latency of 4 or more cycles. The 4-cycle minimum constitutes a vector operation on registers spent only in the MADD computation as V1-V4. Any additional shuffle or writing back to memory will add more cycles to the four cycles.
      +---------+    +---------+    +---------+    +---------+
      | EXECUTE |==> | VC1-VC2 |==> |  V1-V4  |==> |WriteBack|
      +---------+    +---------+    +---------+    +---------+
                     +---------+    +---------+    +---------+    +---------+
                     | EXECUTE |==> | VC1-VC2 |==> |  V1-V4  |==> |WriteBack|
                     +---------+    +---------+    +---------+    +---------+
    


    If there are data dependencies for two consecutive SP instructions, the second instruction will wait until data are produced at stage V4, where they will be passed over to the V1 stage of the second instruction using an internal bypass. For an SP instruction followed by a dependent SP instruction, there is a forward path and, after the results of the first instruction are computed, the result is forwarded to the V1 stage of the second instruction, causing an additional three-cycle delay, as for the DP instructions.
      +---+   +---+   +---+   +---+   +---+   +---+   +---+   +---+
      | E |==>|VC1|==>|VC2|==>| V1|==>| V2|==>| V3|==>| V4|==>| WB|
      +---+   +---+   +---+   +---+   +---+   +---+   +---+   +---+
                                                                |
                                                                v
             +----------------------------+   +---+   +---+   +---+   +---+   +---+   +---+   +---+
             |            E               |==>|VC1|==>|VC2|==>| V1|==>| V2|==>| V3|==>| V4|==>| WB|
             +----------------------------+   +---+   +---+   +---+   +---+   +---+   +---+   +---+
    
    This section is not included in the SAMPLE PREVIEW.


     

    ■ Avoid Mixing Data Type


    Type casting should be avoided when iterating or looping over a block of instructions in a program. We will use the previous program, however, we will modify one of the register type to be a 32 bit float instead of a double float. The following listing shows the program vecmul512mixCV.cpp. On line 12 we defined the variables Af, Bf, and Cf as arrays of type float. The compiler optimizer will align them on 64 bytes memory boundary.

     -LIS- Listing. 3.4.1   [Vector Operations on Float Data Type: mic-gigaflopsFloat.cpp]
    (raw text)
    1.     #include <stdio.h>
    2.     #include <stdlib.h>
    3.     #include <omp.h>
    4.     
    5.     unsigned int const SIZEd=16;
    6.     unsigned int const SIZEf=32;
    7.     unsigned int const ITER=50000000;
    8.     
    9.     int main() {
    10.        int i;
    11.    
    12.        float Af[SIZEf]; float Bf[SIZEf]; float Cf[SIZEf];
    13.        // initialize floats arrays
    14.        for (i=0;i<SIZEf;i++) {
    15.            Cf[i]=Bf[i]=Af[i] = (float)rand();
    16.        }
    17.        // warm up cache
    18.        #pragma omp parallel for
    19.        for(i=0;i<ITER;i++) {
    20.            #pragma vector aligned(Af,Bf,Cf)
    21.            Af[0:SIZEf]=Bf[0:SIZEf]*Cf[0:SIZEf]+Af[0:SIZEf];
    22.        }
    23.        // parallel fused operations on floats 
    24.        #pragma omp parallel for
    25.        for(i=0;i<ITER;i++) {
    26.            #pragma vector aligned(Af,Bf,Cf)
    27.            Af[0:SIZEf]=Bf[0:SIZEf]*Cf[0:SIZEf]+Af[0:SIZEf];
    28.        }
    29.        return 0;
    30.    }
    
    
    HPMC 2026


    This section is not included in the SAMPLE PREVIEW.


    13:03 root@HPMC: /MIC_PROG/GIGAFLOPS #  grep -E vblendmps mic-gigaflopsMixed_xphi_Gg.MIC-ASMcode
            vblendmps zmm19{k2},zmm4,zmm10
            vblendmps zmm27{k2},zmm4,zmm16
            vblendmps zmm6{k2},zmm4,zmm24
            vblendmps zmm5{k2},zmm4,zmm5
            vblendmps zmm8{k1},zmm14,zmm5
            vblendmps zmm18{k1},zmm14,zmm15
            vblendmps zmm19{k2},zmm2,zmm10
            vblendmps zmm27{k2},zmm2,zmm16
            vblendmps zmm6{k2},zmm2,zmm24
            vblendmps zmm5{k2},zmm2,zmm5
            vblendmps zmm8{k1},zmm14,zmm5
            vblendmps zmm18{k1},zmm14,zmm15
    
    The instruction VBLENDMPS blends float32 vectors using an instruction mask.
    For example, consider vblendmps zmm19{k2},zmm4,zmm10 This instruction performs an element-by-element blending between float32 vector zmm4 and the float32 vector result of the swizzle/broadcast/conversion process on float32 vector zmm10, using the instruction mask k2 as selector. The result is written into float32 vector zmm9. That is, the above instruction blends float32 vector zmm4 and float32 vector zmm10 and store the result in zmm19 under write-mask.

    Now that we explained the ALU pipelines and how the MIC vector registers are mapped to lanes, we can look into the instructions used in mic-gigaflopsMixed_xphi_Gg.MIC-ASMcode. In particular we focus on these instructions that need to do intralane shuffles (adding extra clock cycles, stalling or delaying the execution due to the data conversion).

    Let's take a look at a snippet of assembly code in mic-gigaflopsMixed_xphi_Gg.MIC-ASMcode, where the instructions vpermf32x4 and vcvtps2pd are being used.
    175     vpermf32x4 zmm3,ZMMWORD PTR [r14],0xee
    176     mov    ebx,0xff
    177     vpermf32x4 zmm0,ZMMWORD PTR [r14+0x40],0xee
    178     vcvtps2pd zmm2,YMMWORD PTR [r14]
    179     kmov   k2,ebx
    180     vcvtps2pd zmm6,ymm3
    181     mov    ebx,0xff00
    182     vcvtps2pd zmm1,YMMWORD PTR [r14+0x40]
    183     kmov   k1,ebx
    184     vcvtps2pd zmm5,ymm0
    185     vmulpd zmm3,zmm2,ZMMWORD PTR [r13+0x0]
    186     vmulpd zmm2,zmm6,ZMMWORD PTR [r13+0x40]
    187     vmulpd zmm0,zmm5,ZMMWORD PTR [r13+0xc0]
    188     vpxord zmm4,zmm4,zmm4
    
    A lot of shuffling and conversion taking place before the multiplication operations. When executing the program mic-gigaflopsMixed.cpp, the MIC was busy shuffling the data to convert it from float to double, causing extra clock cycles due to stalling for the intralane conversions - as explained in the previous section.

    Penalties in Clock Cycles Due to Mixing Data Type:
    In the previous subchapter, in the section "Casting Vectorized Data Type", we showed that the type conversion caused the use of the instruction vcvtps2pd. In this section we showed why you need to avoid type casting of data elements in a loop, otherwise, you will acquire unnecessary clock cycles penalty.

    Keep your data type consistent for data structures
    used within the same loop.
    Use float throughout your program, as there is no
    need for double (except for memory references).