如何在AMD64的GCC中获得更大数据移动的128位长度?

时间:2016-03-13 15:00:43

标签: c gcc openmp 128-bit

我的程序花费大部分时间将数组移到右边以让位于新数据插入。所以,我正在寻找优化这个特定代码的方法。我没有使用memmove(),而是决定创建自己的函数,利用OpenMP来加快执行速度。

这是我的C代码子程序:

#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#define INT_LENGTH      8 // =sizeof(8) <- long int size 
#define INT_PER_CELL    3 // int number per CELL

void insertCell(char *c_mem, int *i_mem_len, int *i_mem_ins, char *c_cell){
    // c_mem      : array of CELL on the heap.
    // i_mem_len  : length of c_mem in CELL count
    // i_mem_ins  : targeted Nth CELL of c_mem to be inserted.
    // c_cell     : content cell to be inserted into c_mem

    long int *li_mem = (long int *) c_mem;

    #pragma omp parallel for
    for(int a=0; a<INT_PER_CELL; a++){
        int b = (*i_mem_ins * INT_PER_CELL) + a;
        int temp = (*i_mem_len * INT_PER_CELL) + a;
        while(temp > b){
            temp -= INT_PER_CELL;
            li_mem[temp + INT_PER_CELL] = li_mem[temp];
        }
    }

    memcpy(&c_mem[*i_mem_ins * INT_LENGTH * INT_PER_CELL], c_cell, INT_LENGTH * INT_PER_CELL);
    *i_mem_len += 1;
}


int main(void){
    ...
}

希望下面的插图有助于理解。

enter image description here

从上面的代码中,我使用long int,因为它是可以在一个CPU步骤中移动的最大块数据(我假设)。但我正在寻找更大的数据长度。

我的问题是: INTEL处理器是否专门支持128位物理长度来移动数据?如果有的话,如何利用它?

我知道GCC支持数学运算的128位int长度,但根据我的理解,它需要两倍的CPU周期,所以它实际上是重复两次的本机64位数据。

0 个答案:

没有答案
相关问题