-
Notifications
You must be signed in to change notification settings - Fork 13
/
benchmark.cpp
67 lines (47 loc) · 1.81 KB
/
benchmark.cpp
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
66
#include <cstdio>
#include "application.cpp"
#include "../benchmark.h"
#include "../memcpy.cpp"
#ifndef ITERATIONS
# define ITERATIONS 1000
#endif
class Application final: public ApplicationBase<Application> {
using super = ApplicationBase<Application>;
friend super;
public:
Application(const CommandLine& cmdline)
: super(cmdline, 1024, ITERATIONS) {}
void run() {
initialize();
run_all();
}
private:
virtual void custom_initialize() override {
printf("We report the time in cycles per input byte.\n");
printf("For reference, we present the time needed to copy %zu bytes.\n", get_input_size());
BEST_TIME(/**/, ::memcpy(output.get(), input.get(), get_input_size()), "memcpy", iterations, get_input_size());
#if defined(HAVE_AVX512_INSTRUCTIONS)
size_t inalign = reinterpret_cast<uintptr_t>(input.get()) & 63;
size_t outalign = reinterpret_cast<uintptr_t>(output.get()) & 63;
if((inalign !=0) || (outalign!=0))
printf("warning: your data pointers are unaligned: %zu %zu\n", inalign, outalign);
BEST_TIME(/**/, avx512_memcpy(output.get(),input.get(),get_input_size()), "memcpy (avx512)", iterations, get_input_size());
#endif
#if defined(HAVE_RVV_INSTRUCTIONS)
BEST_TIME(/**/, rvv_memcpy(output.get(), input.get(), get_output_size()), "memcpy (RVV)", iterations, get_output_size());
#endif
}
template<typename T>
void run_function_impl(const char* name, T function) {
auto fn = [this, function]() {
function(input.get(), get_input_size(), output.get());
};
BEST_TIME(, fn(), name, iterations, get_input_size());
}
};
int main(int argc, char* argv[]) {
CommandLine cmd(argc, argv);
Application app(cmd);
app.run();
return EXIT_SUCCESS;
}