-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache.cpp
More file actions
62 lines (54 loc) · 1.59 KB
/
cache.cpp
File metadata and controls
62 lines (54 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include <fstream>
#include <string>
#include <iostream>
#include "mpi.h"
using namespace std;
int main(int argc, char *argv[])
{
MPI_Init(NULL, NULL);
// Get the name of the processor
char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(processor_name, &name_len);
string line;
ifstream index0("/sys/devices/system/cpu/cpu0/cache/index0/size");
if (index0.is_open())
{
while (getline(index0, line))
{
cout << processor_name << ": Level 1 icache size = " << line << "\n";
}
index0.close();
}
ifstream index1("/sys/devices/system/cpu/cpu0/cache/index1/size");
if (index1.is_open())
{
while (getline(index1, line))
{
cout << processor_name << ": Level 1 dcache size = " << line << "\n";
}
index1.close();
}
ifstream index2("/sys/devices/system/cpu/cpu0/cache/index2/size");
if (index2.is_open())
{
while (getline(index2, line))
{
cout << processor_name << ": Level 2 cache size = " << line << "\n";
}
index2.close();
}
ifstream index3("/sys/devices/system/cpu/cpu0/cache/index3/size");
if (index3.is_open())
{
while (getline(index3, line))
{
cout << processor_name << ": Level 3 cache size = " << line << "\n";
}
index3.close();
}
// Finalize the MPI environment. No more MPI calls can be made after this
MPI_Finalize();
return 0;
}