相关疑难解决方法(0)

29
推荐指数
3
解决办法
2万
查看次数

系统上的缓存大小估算?

我从这个链接(https://gist.github.com/jiewmeng/3787223)获得了这个程序.我一直在网上搜索,以便更好地理解处理器缓存(L1和L2).我想成为能够编写一个程序,让我能够猜测我的新笔记本电脑上L1和L2缓存的大小.(仅用于学习目的.我知道我可以检查规格.)

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define KB 1024
#define MB 1024 * 1024

int main() {
    unsigned int steps = 256 * 1024 * 1024;
    static int arr[4 * 1024 * 1024];
    int lengthMod;
    unsigned int i;
    double timeTaken;
    clock_t start;
    int sizes[] = {
        1 * KB, 4 * KB, 8 * KB, 16 * KB, 32 * KB, 64 * KB, 128 * KB, 256 * KB,
        512 * KB, 1 * MB, 1.5 …
Run Code Online (Sandbox Code Playgroud)

c performance caching cpu-cache

10
推荐指数
1
解决办法
1813
查看次数

/ sys/device /和dmidecode报告的不同CPU缓存大小

我正试图在我的系统中获得不同缓存级别的大小.

我试过两种技巧.

a)使用/ sys/device中的信息.这是输出.

$ cat /sys/devices/system/cpu/cpu0/cache/index1/size
32K
$ cat /sys/devices/system/cpu/cpu0/cache/index2/size
256K
$ cat /sys/devices/system/cpu/cpu0/cache/index3/size
8192K
Run Code Online (Sandbox Code Playgroud)

b)使用来自dmidecode的信息

$ sudo dmidecode -t cache
Cache Information
    Socket Designation: CPU Internal L1
    Configuration: Enabled, Not Socketed, Level 1
    Operational Mode: Write Through
    Location: Internal
    Installed Size: 256 KB
    Maximum Size: 256 KB
        < .... >
Cache Information
    Socket Designation: CPU Internal L2
    Configuration: Enabled, Not Socketed, Level 2
    Operational Mode: Write Through
    Location: Internal
    Installed Size: 1024 KB
    Maximum Size: 1024 KB
        < …
Run Code Online (Sandbox Code Playgroud)

linux caching

8
推荐指数
1
解决办法
4972
查看次数

intel core i7处理器使用哪种缓存映射技术?

我已经了解了不同的缓存映射技术,如直接映射,关联映射和集合关联映射技术,还学习了权衡.但我很好奇现在在intel core i7或AMD处理器中使用了什么.以及这些技术是如何演变的.还有哪些事情需要改进?

x86 amd intel cpu-architecture cpu-cache

8
推荐指数
1
解决办法
2255
查看次数

指令减少 33%,内存访问减少 17%,但速度提高 4 倍?

概括

我有两段 C++ 代码,它们执行相同的计算。与代码 A 相比,代码 B 确实减少了大约 33% 的指令,大约减少了 17% 的内存访问,但运行速度是代码 A 的四倍(而不是两倍)。会是什么原因呢?此外,我们如何才能确认您的回答所提供的主张?

在这两个代码中,

  • howmany是 20 000 000
  • testees有 20 000 000 个元素,mt19937在启动时(在这些片段之前)为代码 A 和代码 B 随机生成 ( )。
  • 乘法是通过对内存的一次访问来处理的(如稍后在汇编代码中看到的)
  • 两个代码都是用优化标志编译的-O1

一些代码

代码 A - 运行时间约为。95 至 110 毫秒

    GF2 sum {GF2(1)};
    auto a = system_clock::now();
    for(size_t i=0;i<howmany;i++){
        sum *= testees[i]; 
    }
    auto b = system_clock::now();
Run Code Online (Sandbox Code Playgroud)

代码 B - 运行时间约为。25 至 30 毫秒

    GF2 sum1 {GF2(1)};
    GF2 sum2 {GF2(1)};
    GF2 sum3 …
Run Code Online (Sandbox Code Playgroud)

c++ performance assembly g++

5
推荐指数
0
解决办法
260
查看次数

标签 统计

caching ×3

cpu-cache ×3

cpu-architecture ×2

performance ×2

amd ×1

assembly ×1

c ×1

c++ ×1

g++ ×1

intel ×1

linux ×1

memory ×1

processor ×1

x86 ×1