-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench_main.cu
42 lines (40 loc) · 1.1 KB
/
bench_main.cu
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
#include <chrono>
#include <cstring>
#include <iostream>
#include <random>
#include "cluster2d_gpu.cuh"
#include "umatrix_gpu.cuh"
int main(int argc, char** argv)
{
if (argc != 4)
{
std::cerr << "./bench_main [n] [block size] [threads]" << std::endl;
return 1;
}
const auto n = std::atoll(argv[1]);
const auto bsize = std::atoll(argv[2]);
const auto nthread = std::atoll(argv[3]);
if (n % bsize != 0)
{
std::cerr << "n % bsize != 0" << std::endl;
return 2;
}
auto map_gpu = MatrixGPU<bool>(n, n);
auto rng = std::mt19937_64(0);
auto dist = std::uniform_real_distribution<>();
for (std::size_t ii = 0; ii < n * n; ++ii)
{
map_gpu[ii] = dist(rng) < 0.5;
}
map_gpu.push();
auto calc = UF2dGPU(map_gpu);
{
const auto t0 = std::chrono::system_clock::now();
calc.run(bsize, nthread);
const auto dt = std::chrono::system_clock::now() - t0;
std::cout
<< std::chrono::duration_cast<std::chrono::microseconds>(dt).count()
<< " usec" << std::endl;
}
return 0;
}