-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteam-timing.h
65 lines (55 loc) · 1.58 KB
/
team-timing.h
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
63
64
65
#if _LIBGOMP_TEAM_TIMING_
/* Header file for measuring execution time of the team. */
#ifndef RDTSC
#define RDTSC() ({ \
unsigned int cycles_low; \
unsigned int cycles_high; \
asm volatile ( \
"RDTSC\n\t" \
"mov %%edx, %0\n\t" \
"mov %%eax, %1\n\t" \
: \
"=r" (cycles_high), "=r" (cycles_low) \
: \
: \
"%rax", "%rdx" \
); \
(((uint64_t) cycles_high << 32) | cycles_low); \
})
#endif
struct gomp_team_time
{
uint64_t start;
uint64_t end;
};
extern struct gomp_task_icv gomp_global_icv;
static inline __attribute__((always_inline)) void
gomp_save_team_start_time (struct gomp_team_time *team_time)
{
team_time->start = RDTSC();
}
static inline __attribute__((always_inline)) void
gomp_save_team_end_time (struct gomp_team_time *team_time)
{
team_time->end = RDTSC();
}
static inline __attribute__((always_inline)) void
gomp_print_team_time (struct gomp_team_time *team_time)
{
size_t length;
time_t rawtime;
struct tm *timeinfo;
char filename[128];
time(&rawtime);
timeinfo = localtime(&rawtime);
if (gomp_global_icv.ult_var)
length = strftime(filename, 128, "ult_omp_team_time_%d-%m-%Y_%H-%M-%S-", timeinfo);
else
length = strftime(filename, 128, "bsl_omp_team_time_%d-%m-%Y_%H-%M-%S-", timeinfo);
snprintf(&filename[length], (128 - length), "(%llu).txt", (unsigned long long int) RDTSC());
FILE *file = fopen(filename, "w");
fprintf(file, "Time: %llu\n", ((unsigned long long int) (team_time->end - team_time->start)));
fflush(file);
fclose(file);
}
#endif