-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoy.cpp
More file actions
41 lines (31 loc) · 770 Bytes
/
Copy pathtoy.cpp
File metadata and controls
41 lines (31 loc) · 770 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
#include "../include/pside.h"
#include <cstdio>
#include <thread>
static constexpr unsigned long long HOT_ADDS = 4'000'000ULL;
static constexpr unsigned long long CAP_ADDS = HOT_ADDS / 2;
static constexpr int ITERATIONS = 1000;
void hot() {
volatile unsigned long long x;
for (x = 0; x < HOT_ADDS; ++x)
;
}
void cap() {
volatile unsigned long long y;
for (y = 0; y < CAP_ADDS; ++y)
;
}
int main() {
std::printf("Starting: two threads.\n");
for (int i = 0; i < ITERATIONS; ++i) {
std::thread hot_thread(hot);
std::thread cap_thread(cap);
hot_thread.join();
cap_thread.join();
PSIDE_THROUGHPUT_POINT("loop_iter");
if (i % 100 == 0) {
std::printf(".");
std::fflush(stdout);
}
}
std::printf("\n");
}