相关疑难解决方法(0)

为什么我的8M L3缓存不能为大于1M的阵列带来任何好处?

我受到这个问题的启发,编写了一个简单的程序来测试我的机器在每个缓存级别的内存带宽:

为什么矢量化循环没有性能改进

我的代码使用memset反复写入缓冲区(或缓冲区)并测量速度.它还保存了最后打印的每个缓冲区的地址.这是列表:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>

#define SIZE_KB {8, 16, 24, 28, 32, 36, 40, 48, 64, 128, 256, 384, 512, 768, 1024, 1025, 2048, 4096, 8192, 16384, 200000}
#define TESTMEM 10000000000 // Approximate, in bytes
#define BUFFERS 1

double timer(void)
{
    struct timeval ts;
    double ans;

    gettimeofday(&ts, NULL);
    ans = ts.tv_sec + ts.tv_usec*1.0e-6;

    return ans;
}

int main(int argc, char **argv)
{
    double *x[BUFFERS];
    double t1, t2;
    int kbsizes[] = SIZE_KB;
    double bandwidth[sizeof(kbsizes)/sizeof(int)];
    int …
Run Code Online (Sandbox Code Playgroud)

c c++ optimization performance cpu-cache

25
推荐指数
1
解决办法
921
查看次数

标签 统计

c ×1

c++ ×1

cpu-cache ×1

optimization ×1

performance ×1