-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathL3Mem.cpp
More file actions
48 lines (31 loc) · 755 Bytes
/
L3Mem.cpp
File metadata and controls
48 lines (31 loc) · 755 Bytes
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
#include <random>
#include <x86intrin.h>
#include <iostream>
unsigned int taux=0;
inline volatile unsigned long long rdtsc() {
return __rdtscp(&taux);
}
int main(int argc, char**) {
std::mt19937 eng;
std::uniform_real_distribution<float> rgen(0.,1.);
constexpr int NN = 1024*1024;
float r[NN];
std::cout << sizeof(r) << std::endl;
for (int i=0;i!=NN;++i)
r[i]=rgen(eng);
constexpr int KK=1000;
long long t1=0;
bool err=false;
float s[KK];
for (int ok=0; ok!=KK; ++ok) {
s[ok]=0;
t1 -= rdtsc();
for (int i=0;i!=NN;++i)
s[ok]+=r[i];
t1 += rdtsc();
if (ok>0 && s[ok] != s[ok-1]) err=true;
}
std::cout << t1 << std::endl;
if (err) std::cout << "a mess " << std::endl;
return 0;
}