-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathshared.c
41 lines (34 loc) · 1.14 KB
/
shared.c
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
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include "shared.h"
Cuda _cuda = {0};
Params params = {0};
double getTimestamp()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_usec + tv.tv_sec*1e6;
}
void printTimings(double start, double end, double poses_per_wi)
{
double ms = ((end-start)/params.iterations)*1e-3;
// Compute FLOP/s
double runtime = ms*1e-3;
double ops_per_wi = 27*poses_per_wi
+ params.natlig*(3 + 18*poses_per_wi + params.natpro*(11 + 30*poses_per_wi))
+ poses_per_wi;
double total_ops = ops_per_wi * (params.nposes/poses_per_wi);
double flops = total_ops / runtime;
double gflops = flops / 1e9;
double interactions =
(double)params.nposes
* (double)params.natlig
* (double)params.natpro;
double interactions_per_sec = interactions / runtime;
// Print stats
printf("- Total time: %7.2lf ms\n", (end-start)*1e-3);
printf("- Average time: %7.2lf ms\n", ms);
printf("- Interactions/s: %7.2lf billion\n", (interactions_per_sec / 1e9));
printf("- GFLOP/s: %7.2lf\n", gflops);
}