-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsort.cpp
More file actions
48 lines (38 loc) · 1.3 KB
/
Copy pathsort.cpp
File metadata and controls
48 lines (38 loc) · 1.3 KB
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 <arrayfire_benchmark.h>
#include <arrayfire.h>
#include <vector>
using af::array;
using af::randu;
using af::deviceGC;
using af::deviceMemInfo;
using std::vector;
using af::sum;
void sortBench(benchmark::State& state, af_dtype type) {
af::dim4 dataDims(state.range(0), state.range(1));
unsigned sortDim = state.range(2);
array input = randu(dataDims, type);
array output;
size_t alloc_bytes, alloc_buffers, lock_bytes, lock_buffers;
deviceMemInfo(&alloc_bytes, &alloc_buffers, &lock_bytes, &lock_buffers);
af::sync();
output = sort(input, sortDim);
af::sync();
for(auto _ : state) {
output = sort(input, sortDim);
af::sync();
}
size_t alloc_bytes2, alloc_buffers2, lock_bytes2, lock_buffers2;
deviceMemInfo(&alloc_bytes2, &alloc_buffers2, &lock_bytes2, &lock_buffers2);
state.counters["Bytes"] = (alloc_bytes2 - alloc_bytes);
deviceGC();
}
int main(int argc, char** argv) {
vector<af_dtype> types = {f32, f64};
benchmark::Initialize(&argc, argv);
af::benchmark::RegisterBenchmark("sort", types, sortBench)
->Ranges({{8, 1<<12}, {8, 1<<12}, {0, 1}})
->ArgNames({"dim0", "dim1", "sortDim"})
->Unit(benchmark::kMicrosecond);
af::benchmark::AFReporter r;
benchmark::RunSpecifiedBenchmarks(&r);
}