]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/ublas/test/opencl/transposition_test.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / numeric / ublas / test / opencl / transposition_test.hpp
1 #ifndef TEST_TRANS_OPENCL_HH
2 #define TEST_TRANS_OPENCL_HH
3 #include "test_opencl.hpp"
4
5
6 template <class T, class F, int number_of_tests, int max_dimension>
7 class bench_trans
8 {
9 public:
10
11 typedef test_opencl<T, F> test;
12
13 void run()
14 {
15 opencl::library lib;
16 int passedOperations = 0;
17 // get default device and setup context
18 compute::device device = compute::system::default_device();
19 compute::context context(device);
20 compute::command_queue queue(context, device);
21
22 std::srand(time(0));
23
24 ublas::matrix<T, F> a;
25 ublas::matrix<T, F> resultUBLAS;
26 ublas::matrix<T, F> resultOPENCL;
27
28
29 for (int i = 0; i<number_of_tests; i++)
30 {
31 int rowsA = std::rand() % max_dimension + 1;
32 int colsA = std::rand() % max_dimension + 1;
33
34 a.resize(rowsA, colsA);
35
36 test::init_matrix(a, 200);
37
38 resultUBLAS = ublas::trans(a);
39 resultOPENCL = opencl::trans(a, queue);
40
41
42 if (!test::compare(resultUBLAS, resultOPENCL))
43 {
44 std::cout << "Error in calculations" << std::endl;
45
46 std::cout << "passed: " << passedOperations << std::endl;
47 return;
48 }
49
50 passedOperations++;
51
52 }
53 std::cout << "All is well (matrix opencl prod) of " << typeid(T).name() << std::endl;
54
55
56
57 }
58
59 };
60
61 #endif