summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/numeric/ublas/test/opencl
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/numeric/ublas/test/opencl')
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/Jamfile31
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_test.cpp44
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_test.hpp114
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_with_constants_test.cpp48
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_with_constants_test.hpp86
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/inner_prod_test.cpp23
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/inner_prod_test.hpp64
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/norm2_test.cpp32
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/norm2_test.hpp59
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/norm_test.cpp22
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/norm_test.hpp59
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/outer_prod_test.cpp31
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/outer_prod_test.hpp65
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/prod_test.cpp48
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/prod_test.hpp88
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/test_opencl.hpp84
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/transposition_test.cpp33
-rw-r--r--src/boost/libs/numeric/ublas/test/opencl/transposition_test.hpp61
18 files changed, 992 insertions, 0 deletions
diff --git a/src/boost/libs/numeric/ublas/test/opencl/Jamfile b/src/boost/libs/numeric/ublas/test/opencl/Jamfile
new file mode 100644
index 00000000..51c74675
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/Jamfile
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2018 Stefan Seefeld
+#
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or
+# copy at http://www.boost.org/LICENSE_1_0.txt)
+
+import ac ;
+
+# work around a bug in Boost.Build
+import ../../opencl ;
+import ../../clblas ;
+using opencl ;
+using clblas ;
+
+project boost/ublas/test/opencl
+ : requirements
+ <toolset>gcc:<cxxflags>-Wno-ignored-attributes
+ [ ac.check-library /clblas//clblas : <library>/clblas//clblas <library>/opencl//opencl : <build>no ]
+ ;
+
+test-suite ocl
+ : [ run prod_test.cpp ]
+ [ run elementwise_operations_test.cpp ]
+ [ run inner_prod_test.cpp ]
+ [ run outer_prod_test.cpp ]
+ [ run transposition_test.cpp ]
+ [ run norm_test.cpp ]
+ [ run norm2_test.cpp ]
+ [ run elementwise_operations_with_constants_test.cpp ]
+ ;
diff --git a/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_test.cpp b/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_test.cpp
new file mode 100644
index 00000000..60c76e74
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_test.cpp
@@ -0,0 +1,44 @@
+#include "elementwise_operations_test.hpp"
+
+int main()
+{
+
+ ///testing row major flaot elementwise operations
+ bench_elementwise <float, ublas::basic_row_major<>, 10, 10> b1;
+
+ ///testing row major complex float elementwise operations
+ bench_elementwise <std::complex<float>, ublas::basic_row_major<>, 10, 10> b2;
+
+ ///testing row major double elementwise operations
+ bench_elementwise <double, ublas::basic_row_major<>, 10, 10> b5;
+
+ ///testing row major complex double elementwise operations
+ bench_elementwise <std::complex<double>, ublas::basic_row_major<>, 10, 10> b6;
+
+ ///testing column major flaot elementwise operations
+ bench_elementwise <float, ublas::basic_column_major<>, 10, 10> b3;
+
+ ///testing column major complex float elementwise operations
+ bench_elementwise <std::complex<float>, ublas::basic_column_major<>, 10, 10> b4;
+
+ ///testing column major double elementwise operations
+ bench_elementwise <double, ublas::basic_column_major<>, 10, 10> b7;
+
+ ///testing column major complex double elementwise operations
+ bench_elementwise <std::complex<double>, ublas::basic_column_major<>, 10, 10> b8;
+
+
+ std::cout << "row major:" << std::endl;
+ b1.run();
+ b2.run();
+ b5.run();
+ b6.run();
+
+
+ std::cout << "column major:" << std::endl;
+ b3.run();
+ b4.run();
+ b7.run();
+ b8.run();
+
+}
diff --git a/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_test.hpp b/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_test.hpp
new file mode 100644
index 00000000..2fe2e571
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_test.hpp
@@ -0,0 +1,114 @@
+#ifndef ELEMENT_OPENCL_HH
+#define ELEMENT_OPENCL_HH
+#include "test_opencl.hpp"
+
+template <class T, class F, int number_of_tests, int max_dimension>
+class bench_elementwise
+{
+public:
+ typedef test_opencl<T, F> test;
+ void run()
+ {
+ opencl::library lib;
+ int passedOperations = 0;
+ // get default device and setup context
+ compute::device device = compute::system::default_device();
+ compute::context context(device);
+ compute::command_queue queue(context, device);
+
+ std::srand(time(0));
+
+ ublas::matrix<T, F> a;
+ ublas::matrix<T, F> b;
+
+ //matrix-matrix operations of cpu
+ ublas::matrix<T, F> result_m_add;
+ ublas::matrix<T, F> result_m_sub;
+ ublas::matrix<T, F> result_m_mul;
+
+ //matrix-matrix operations of gpu
+ ublas::matrix<T, F> result_m_add_cl;
+ ublas::matrix<T, F> result_m_sub_cl;
+ ublas::matrix<T, F> result_m_mul_cl;
+
+
+ ublas::vector<T> va;
+ ublas::vector<T> vb;
+
+ //vector-vector operations of cpu
+ ublas::vector<T> result_v_add;
+ ublas::vector<T> result_v_sub;
+ ublas::vector<T> result_v_mul;
+
+ //vector-vector operations of gpu
+ ublas::vector<T> result_v_add_cl;
+ ublas::vector<T> result_v_sub_cl;
+ ublas::vector<T> result_v_mul_cl;
+
+
+ for (int i = 0; i<number_of_tests; i++)
+ {
+ int rows = std::rand() % max_dimension + 1;
+ int cols = std::rand() % max_dimension + 1;
+
+ a.resize(rows, cols);
+ b.resize(rows, cols);
+ va.resize(rows);
+ vb.resize(rows);
+
+
+ test::init_matrix(a, 200);
+ test::init_matrix(b, 200);
+ test::init_vector(va, 200);
+ test::init_vector(vb, 200);
+
+ result_m_add = a + b;
+ result_m_add_cl = opencl::element_add(a, b, queue);
+
+ result_m_sub = a - b;
+ result_m_sub_cl = opencl::element_sub(a, b, queue);
+
+ result_m_mul = ublas::element_prod(a, b);
+ result_m_mul_cl = opencl::element_prod(a, b, queue);
+
+
+ result_v_add = va + vb;
+ result_v_add_cl = opencl::element_add(va, vb, queue);
+
+ result_v_sub = va - vb;
+ result_v_sub_cl = opencl::element_sub(va, vb, queue);
+
+ result_v_mul = ublas::element_prod(va, vb);
+ result_v_mul_cl = opencl::element_prod(va, vb, queue);
+
+
+
+
+
+
+ if ((!test::compare(result_m_add, result_m_add_cl)) ||
+ (!test::compare(result_m_sub, result_m_sub_cl)) ||
+ (!test::compare(result_m_mul, result_m_mul_cl)) ||
+ (!test::compare(result_v_add, result_v_add_cl)) ||
+ (!test::compare(result_v_sub, result_v_sub_cl)) ||
+ (!test::compare(result_v_mul, result_v_mul_cl))
+ )
+ {
+ std::cout << "Error in calculations" << std::endl;
+
+ std::cout << "passed: " << passedOperations << std::endl;
+ return;
+ }
+
+ passedOperations++;
+
+ }
+ std::cout << "All is well (matrix opencl element wise operations) of " << typeid(T).name() << std::endl;
+
+
+
+ }
+
+};
+
+#endif
diff --git a/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_with_constants_test.cpp b/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_with_constants_test.cpp
new file mode 100644
index 00000000..4ec03f99
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_with_constants_test.cpp
@@ -0,0 +1,48 @@
+#include "elementwise_operations_with_constants_test.hpp"
+#include <boost/numeric/ublas/matrix.hpp>
+
+int main()
+{
+
+ ///testing row major flaot prod
+ bench_elementwise_constant<float, ublas::basic_row_major<>, 10, 10> b1;
+
+ ///testing row major complex float prod
+ bench_elementwise_constant<std::complex<float>, ublas::basic_row_major<>, 10, 10> b2;
+
+
+ ///testing row major double prod
+ bench_elementwise_constant<double, ublas::basic_row_major<>, 10, 10> b3;
+
+ ///testing row major complex float elementwise operations with constants
+ bench_elementwise_constant<std::complex<double>, ublas::basic_row_major<>, 10, 10> b4;
+
+
+ ///testing column major flaot elementwise operations with constants
+ bench_elementwise_constant<float, ublas::basic_column_major<>, 10, 10> b5;
+
+ ///testing column major complex float elementwise operations with constants
+ bench_elementwise_constant<std::complex<float>, ublas::basic_column_major<>, 10, 10> b6;
+
+ ///testing column major double elementwise operations with constants
+ bench_elementwise_constant<double, ublas::basic_column_major<>, 10, 10> b7;
+
+ ///testing column major complex double elementwise operations with constants
+ bench_elementwise_constant<std::complex<double>, ublas::basic_column_major<>, 10, 10> b8;
+
+
+ std::cout << "Row major:" << std::endl;
+ b1.run();
+ b2.run();
+ b3.run();
+ b4.run();
+
+ std::cout << "Column major:" << std::endl;
+ b5.run();
+ b6.run();
+ b7.run();
+ b8.run();
+
+ return 0;
+
+} \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_with_constants_test.hpp b/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_with_constants_test.hpp
new file mode 100644
index 00000000..f78a7382
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/elementwise_operations_with_constants_test.hpp
@@ -0,0 +1,86 @@
+#ifndef TEST_ELEMENT_CONSTANT_OPENCL_HH
+#define TEST_ELEMENT_CONSTANT_OPENCL_HH
+#include "test_opencl.hpp"
+
+
+template <class T, class F, int number_of_tests, int max_dimension>
+class bench_elementwise_constant
+{
+public:
+
+ typedef test_opencl<T, F> test;
+
+ void run()
+ {
+ opencl::library lib;
+ int passedOperations = 0;
+ // get default device and setup context
+ compute::device device = compute::system::default_device();
+ compute::context context(device);
+ compute::command_queue queue(context, device);
+
+ std::srand(time(0));
+
+ ublas::matrix<T, F> m;
+ ublas::matrix<T, F> m_result_add_ublas;
+ ublas::matrix<T, F> m_result_sub_ublas;
+ ublas::matrix<T, F> m_result_add_opencl;
+ ublas::matrix<T, F> m_result_sub_opencl;
+ ublas::vector<T> v;
+ ublas::vector<T> v_result_add_ublas;
+ ublas::vector<T> v_result_sub_ublas;
+ ublas::vector<T> v_result_add_opencl;
+ ublas::vector<T> v_result_sub_opencl;
+
+
+
+ for (int i = 0; i<number_of_tests; i++)
+ {
+ int rows = std::rand() % max_dimension + 1;
+ int cols = std::rand() % max_dimension + 1;
+
+ m.resize(rows, cols);
+ v.resize(rows);
+
+ test::init_matrix(m, 200);
+ test::init_vector(v, 200);
+
+ T constant = rand() % max_dimension;
+ ublas::matrix<T, F> m_constant_holder(rows, cols, constant);
+ ublas::vector<T> v_constant_holder(rows, constant);
+
+ m_result_add_ublas = m + m_constant_holder;
+ m_result_sub_ublas = m - m_constant_holder;
+ m_result_add_opencl = opencl::element_add(m, constant, queue);
+ m_result_sub_opencl = opencl::element_sub(m, constant, queue);
+
+ v_result_add_ublas = v + v_constant_holder;
+ v_result_sub_ublas = v - v_constant_holder;
+ v_result_add_opencl = opencl::element_add(v, constant, queue);
+ v_result_sub_opencl = opencl::element_sub(v, constant, queue);
+
+
+
+ if ((!test::compare(m_result_add_ublas, m_result_add_opencl))
+ || (!test::compare(m_result_sub_ublas, m_result_sub_opencl)) ||
+ (!test::compare(v_result_add_ublas, v_result_add_opencl))
+ || (!test::compare(v_result_sub_ublas, v_result_sub_opencl)))
+ {
+ std::cout << "Error in calculations" << std::endl;
+
+ std::cout << "passed: " << passedOperations << std::endl;
+ return;
+ }
+
+ passedOperations++;
+
+ }
+ std::cout << "All is well (matrix opencl elementwise operations with constants) of " << typeid(T).name() << std::endl;
+
+
+
+ }
+
+};
+
+#endif \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/inner_prod_test.cpp b/src/boost/libs/numeric/ublas/test/opencl/inner_prod_test.cpp
new file mode 100644
index 00000000..3f1480e0
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/inner_prod_test.cpp
@@ -0,0 +1,23 @@
+#include "inner_prod_test.hpp"
+#include <boost/numeric/ublas/matrix.hpp>
+
+int main()
+{
+ ///testing row major int inner prod
+ bench_inner_prod<int, 10, 10> b1;
+
+ ///testing row major float inner prod
+ bench_inner_prod<float, 10, 10> b2;
+
+
+ ///testing row major double inner prod
+ bench_inner_prod<double, 10, 10> b3;
+
+
+ b1.run();
+ b2.run();
+ b3.run();
+
+ return 0;
+
+} \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/inner_prod_test.hpp b/src/boost/libs/numeric/ublas/test/opencl/inner_prod_test.hpp
new file mode 100644
index 00000000..cf9dc646
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/inner_prod_test.hpp
@@ -0,0 +1,64 @@
+#ifndef TEST_INNER_PROD_HH
+#define TEST_INNER_PROD_HH
+#include "test_opencl.hpp"
+
+
+template <class T, int number_of_tests, int max_dimension>
+class bench_inner_prod
+{
+public:
+
+ typedef test_opencl<T> test;
+
+ void run()
+ {
+ opencl::library lib;
+ int passedOperations = 0;
+ // get default device and setup context
+ compute::device device = compute::system::default_device();
+ compute::context context(device);
+ compute::command_queue queue(context, device);
+
+ std::srand(time(0));
+
+ ublas::vector<T> va;
+ ublas::vector<T> vb;
+ T result_inner_prod_ublas;
+ T result_inner_prod_opencl;
+
+
+ for (int i = 0; i<number_of_tests; i++)
+ {
+ int size = std::rand() % max_dimension + 1;
+
+ va.resize(size);
+ vb.resize(size);
+
+ test::init_vector(va, 200);
+ test::init_vector(vb, 200);
+
+ result_inner_prod_ublas = ublas::inner_prod(va, vb);
+
+ result_inner_prod_opencl = opencl::inner_prod(va, vb, queue);
+
+
+ if (( result_inner_prod_ublas != result_inner_prod_opencl ))
+ {
+ std::cout << "Error in calculations" << std::endl;
+
+ std::cout << "passed: " << passedOperations << std::endl;
+ return;
+ }
+
+ passedOperations++;
+
+ }
+ std::cout << "All is well (matrix opencl inner prod) of " << typeid(T).name() << std::endl;
+
+
+
+ }
+
+};
+
+#endif
diff --git a/src/boost/libs/numeric/ublas/test/opencl/norm2_test.cpp b/src/boost/libs/numeric/ublas/test/opencl/norm2_test.cpp
new file mode 100644
index 00000000..1838ff32
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/norm2_test.cpp
@@ -0,0 +1,32 @@
+#include "norm2_test.hpp"
+#include <boost/numeric/ublas/matrix.hpp>
+
+int main()
+{
+
+ ///testing float norm2
+ bench_norm2<float, 10, 10> b1;
+
+
+ ///testing double norm2
+ bench_norm2<double, 10, 10> b2;
+
+
+ ///testing float norm2
+ bench_norm2<std::complex<float>, 10, 10> b3;
+
+
+ ///testing double norm2
+ bench_norm2<std::complex<double>, 10, 10> b4;
+
+
+
+ b1.run();
+ b2.run();
+ b3.run();
+ b4.run();
+
+
+ return 0;
+
+} \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/norm2_test.hpp b/src/boost/libs/numeric/ublas/test/opencl/norm2_test.hpp
new file mode 100644
index 00000000..8a7d6919
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/norm2_test.hpp
@@ -0,0 +1,59 @@
+#ifndef TEST_NORM2_OPENCL_HH
+#define TEST_NORM2_OPENCL_HH
+#include "test_opencl.hpp"
+
+
+template <class T, int number_of_tests, int max_dimension>
+class bench_norm2
+{
+public:
+
+ typedef test_opencl<T, ublas::basic_row_major<>> test;
+
+
+ void run()
+ {
+ opencl::library lib;
+ int passedOperations = 0;
+ // get default device and setup context
+ compute::device device = compute::system::default_device();
+ compute::context context(device);
+ compute::command_queue queue(context, device);
+
+ std::srand(time(0));
+
+ ublas::vector<T> v;
+
+
+ for (int i = 0; i<number_of_tests; i++)
+ {
+ int size = std::rand() % max_dimension + 1;
+
+ v.resize(size);
+ test::init_vector(v, 200);
+
+
+ T norm2_cpu = ublas::norm_2(v);
+ T norm2_opencl = opencl::norm_2(v, queue);
+
+
+ if ((abs(norm2_cpu - norm2_opencl) / abs(norm2_cpu)) > 1e-6) //precision of float
+ {
+ std::cout << "Error in calculations" << std::endl;
+
+ std::cout << "passed: " << passedOperations << std::endl;
+ return;
+ }
+
+ passedOperations++;
+
+ }
+ std::cout << "All is well (vector opencl a_sum) of " << typeid(T).name() << std::endl;
+
+
+
+ }
+
+};
+
+#endif \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/norm_test.cpp b/src/boost/libs/numeric/ublas/test/opencl/norm_test.cpp
new file mode 100644
index 00000000..79d6eabf
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/norm_test.cpp
@@ -0,0 +1,22 @@
+#include "norm_test.hpp"
+#include <boost/numeric/ublas/matrix.hpp>
+
+int main()
+{
+
+ ///testing float norm1
+ bench_norm<float, 10, 10> b1;
+
+
+ ///testing double norm1
+ bench_norm<double, 10, 10> b2;
+
+
+
+ b1.run();
+ b2.run();
+
+
+ return 0;
+
+} \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/norm_test.hpp b/src/boost/libs/numeric/ublas/test/opencl/norm_test.hpp
new file mode 100644
index 00000000..9623de90
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/norm_test.hpp
@@ -0,0 +1,59 @@
+#ifndef TEST_NORM_OPENCL_HH
+#define TEST_NORM_OPENCL_HH
+#include "test_opencl.hpp"
+
+
+template <class T, int number_of_tests, int max_dimension>
+class bench_norm
+{
+public:
+
+ typedef test_opencl<T, ublas::basic_row_major<>> test;
+
+
+ void run()
+ {
+ opencl::library lib;
+ int passedOperations = 0;
+ // get default device and setup context
+ compute::device device = compute::system::default_device();
+ compute::context context(device);
+ compute::command_queue queue(context, device);
+
+ std::srand(time(0));
+
+ ublas::vector<T> v;
+
+
+ for (int i = 0; i<number_of_tests; i++)
+ {
+ int size = std::rand() % max_dimension + 1;
+
+ v.resize(size);
+ test::init_vector(v, 200);
+
+
+ T norm_cpu = ublas::norm_1(v);
+ T norm_opencl = opencl::norm_1(v, queue);
+
+
+ if (norm_cpu != norm_opencl) //precision of float
+ {
+ std::cout << "Error in calculations" << std::endl;
+
+ std::cout << "passed: " << passedOperations << std::endl;
+ return;
+ }
+
+ passedOperations++;
+
+ }
+ std::cout << "All is well (vector opencl a_sum) of " << typeid(T).name() << std::endl;
+
+
+
+ }
+
+};
+
+#endif \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/outer_prod_test.cpp b/src/boost/libs/numeric/ublas/test/opencl/outer_prod_test.cpp
new file mode 100644
index 00000000..e7195ecb
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/outer_prod_test.cpp
@@ -0,0 +1,31 @@
+#include "outer_prod_test.hpp"
+
+int main()
+{
+
+
+ ///testing float outer prod
+ bench_outer_prod<float, 10, 10> b1;
+
+
+ ///testing double outer prod
+ bench_outer_prod<double, 10, 10> b2;
+
+
+ ///testing complex of float outer prod
+ bench_outer_prod<std::complex<float>, 10, 10> b3;
+
+
+ ///testing complex of double outer prod
+ bench_outer_prod<std::complex<double>, 10, 10> b4;
+
+
+
+ b1.run();
+ b2.run();
+ b3.run();
+ b4.run();
+
+ return 0;
+
+} \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/outer_prod_test.hpp b/src/boost/libs/numeric/ublas/test/opencl/outer_prod_test.hpp
new file mode 100644
index 00000000..348d0b1d
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/outer_prod_test.hpp
@@ -0,0 +1,65 @@
+#ifndef TEST_PROD_OPENCL_HH
+#define TEST_PROD_OPENCL_HH
+#include "test_opencl.hpp"
+
+
+template <class T, int number_of_tests, int max_dimension>
+class bench_outer_prod
+{
+public:
+
+ typedef test_opencl<T> test;
+
+ void run()
+ {
+ opencl::library lib;
+ int passedOperations = 0;
+ // get default device and setup context
+ compute::device device = compute::system::default_device();
+ compute::context context(device);
+ compute::command_queue queue(context, device);
+
+ std::srand(time(0));
+
+ ublas::vector<T> va;
+ ublas::vector<T> vb;
+ ublas::matrix<T> resultUBLAS;
+ ublas::matrix<T> resultOPENCL;
+
+
+ for (int i = 0; i<number_of_tests; i++)
+ {
+ int rows = std::rand() % max_dimension + 1;
+ int cols = std::rand() % max_dimension + 1;
+
+ va.resize(rows);
+ vb.resize(cols);
+
+ test::init_vector(va, 200);
+ test::init_vector(vb, 200);
+
+ //matrix_matrix
+ resultUBLAS = ublas::outer_prod(va, vb);
+ resultOPENCL = opencl::outer_prod(va, vb, queue);
+
+
+ if (!test::compare(resultUBLAS, resultOPENCL))
+ {
+ std::cout << "Error in calculations" << std::endl;
+
+ std::cout << "passed: " << passedOperations << std::endl;
+ return;
+ }
+
+ passedOperations++;
+
+ }
+ std::cout << "All is well (matrix opencl outer prod) of " << typeid(T).name() << std::endl;
+
+
+
+ }
+
+};
+
+#endif \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/prod_test.cpp b/src/boost/libs/numeric/ublas/test/opencl/prod_test.cpp
new file mode 100644
index 00000000..28c39007
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/prod_test.cpp
@@ -0,0 +1,48 @@
+#include "prod_test.hpp"
+#include <boost/numeric/ublas/matrix.hpp>
+
+int main()
+{
+
+ ///testing row major flaot prod
+ bench_prod<float, ublas::basic_row_major<>, 10, 10> b1;
+
+ ///testing row major complex float prod
+ bench_prod<std::complex<float>, ublas::basic_row_major<>, 10, 10> b2;
+
+
+ ///testing row major double prod
+ bench_prod<double, ublas::basic_row_major<>, 10, 10> b3;
+
+ ///testing row major complex float prod
+ bench_prod<std::complex<double>, ublas::basic_row_major<>, 10, 10> b4;
+
+
+ ///testing column major flaot prod
+ bench_prod<float, ublas::basic_column_major<>, 10, 10> b5;
+
+ ///testing column major complex float prod
+ bench_prod<std::complex<float>, ublas::basic_column_major<>, 10, 10> b6;
+
+ ///testing column major double prod
+ bench_prod<double, ublas::basic_column_major<>, 10, 10> b7;
+
+ ///testing column major complex double prod
+ bench_prod<std::complex<double>, ublas::basic_column_major<>, 10, 10> b8;
+
+
+ std::cout << "Row major:" << std::endl;
+ b1.run();
+ b2.run();
+ b3.run();
+ b4.run();
+
+ std::cout << "Column major:" << std::endl;
+ b5.run();
+ b6.run();
+ b7.run();
+ b8.run();
+
+ return 0;
+
+} \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/prod_test.hpp b/src/boost/libs/numeric/ublas/test/opencl/prod_test.hpp
new file mode 100644
index 00000000..e760a842
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/prod_test.hpp
@@ -0,0 +1,88 @@
+#ifndef TEST_PROD_OPENCL_HH
+#define TEST_PROD_OPENCL_HH
+#include "test_opencl.hpp"
+
+
+template <class T, class F, int number_of_tests, int max_dimension>
+class bench_prod
+{
+public:
+
+ typedef test_opencl<T, F> test;
+
+ void run()
+ {
+ opencl::library lib;
+ int passedOperations = 0;
+ // get default device and setup context
+ compute::device device = compute::system::default_device();
+ compute::context context(device);
+ compute::command_queue queue(context, device);
+
+ std::srand(time(0));
+
+ ublas::matrix<T, F> a;
+ ublas::matrix<T, F> b;
+ ublas::matrix<T, F> resultUBLAS;
+ ublas::matrix<T, F> resultOPENCL;
+ ublas::vector<T> va;
+ ublas::vector<T> vb;
+ ublas::vector<T> result_vector_ublas_mv;
+ ublas::vector<T> result_vector_ublas_vm;
+ ublas::vector<T> result_vector_opencl_mv;
+ ublas::vector<T> result_vector_opencl_vm;
+
+
+
+ for (int i = 0; i<number_of_tests; i++)
+ {
+ int rowsA = std::rand() % max_dimension + 1;
+ int colsA = std::rand() % max_dimension + 1;
+ int colsB = std::rand() % max_dimension + 1;
+
+ a.resize(rowsA, colsA);
+ b.resize(colsA, colsB);
+ va.resize(colsA);
+ vb.resize(rowsA);
+
+
+ test::init_matrix(a, 200);
+ test::init_matrix(b, 200);
+ test::init_vector(va, 200);
+ test::init_vector(vb, 200);
+
+ //matrix_matrix
+ resultUBLAS = prod(a, b);
+ resultOPENCL = opencl::prod(a, b, queue);
+
+
+ //matrix_vector
+ result_vector_ublas_mv = ublas::prod(a, va);
+ result_vector_opencl_mv = opencl::prod(a, va, queue);
+
+
+ //vector-matrix
+ result_vector_ublas_vm = ublas::prod(vb, a);
+ result_vector_opencl_vm = opencl::prod(vb, a, queue);
+
+
+ if ((!test::compare(resultUBLAS, resultOPENCL)) || (!test::compare(result_vector_opencl_mv, result_vector_ublas_mv)) || (!test::compare(result_vector_opencl_vm, result_vector_ublas_vm)))
+ {
+ std::cout << "Error in calculations" << std::endl;
+
+ std::cout << "passed: " << passedOperations << std::endl;
+ return;
+ }
+
+ passedOperations++;
+
+ }
+ std::cout << "All is well (matrix opencl prod) of " << typeid(T).name() << std::endl;
+
+
+
+ }
+
+};
+
+#endif \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/test_opencl.hpp b/src/boost/libs/numeric/ublas/test/opencl/test_opencl.hpp
new file mode 100644
index 00000000..fe1af32e
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/test_opencl.hpp
@@ -0,0 +1,84 @@
+#ifndef TEST_OPENCL_HEADER_HH
+#define TEST_OPENCL_HEADER_HH
+#include <stdio.h>
+
+#define BOOST_UBLAS_ENABLE_OPENCL
+#include <boost/numeric/ublas/opencl.hpp>
+#include <boost/numeric/ublas/matrix.hpp>
+#include <time.h>
+#include <math.h>
+
+
+
+
+namespace ublas = boost::numeric::ublas;
+namespace opencl = boost::numeric::ublas::opencl;
+namespace compute = boost::compute;
+
+template <class T, class F = ublas::basic_row_major<>>
+class test_opencl
+{
+public:
+ static bool compare(ublas::matrix<T, F>& a, ublas::matrix<T, F>& b)
+ {
+ typedef typename ublas::matrix<T, F>::size_type size_type;
+ if ((a.size1() != b.size1()) || (a.size2() != b.size2()))
+ return false;
+
+ for (size_type i = 0; i<a.size1(); i++)
+ for (size_type j = 0; j<a.size2(); j++)
+ if (a(i, j) != b(i, j))
+ {
+ return false;
+ }
+ return true;
+
+ }
+
+
+ static bool compare(ublas::vector<T>& a, ublas::vector<T>& b)
+ {
+ typedef typename ublas::vector<T>::size_type size_type;
+ if (a.size() != b.size())
+ return false;
+
+ for (size_type i = 0; i<a.size(); i++)
+ if ((a[i] != b[i]))
+ {
+ return false;
+ }
+ return true;
+
+ }
+
+
+
+ static void init_matrix(ublas::matrix<T, F>& m, int max_value)
+ {
+ typedef typename ublas::matrix<T, F>::size_type size_type;
+ for (size_type i = 0; i < m.size1(); i++)
+ {
+ for (size_type j = 0; j<m.size2(); j++)
+ m(i, j) = (std::rand() % max_value) + 1;
+
+ }
+ }
+
+
+ static void init_vector(ublas::vector<T>& v, int max_value)
+ {
+ typedef typename ublas::vector<T>::size_type size_type;
+ for (size_type i = 0; i <v.size(); i++)
+ {
+ v[i] = (std::rand() % max_value) + 1;
+ }
+ }
+
+
+ virtual void run()
+ {
+ }
+
+};
+
+#endif
diff --git a/src/boost/libs/numeric/ublas/test/opencl/transposition_test.cpp b/src/boost/libs/numeric/ublas/test/opencl/transposition_test.cpp
new file mode 100644
index 00000000..f6dd6782
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/transposition_test.cpp
@@ -0,0 +1,33 @@
+#include "transposition_test.hpp"
+
+int main()
+{
+
+ //Row-major
+ bench_trans<float, ublas::basic_row_major<>, 10, 10> b1;
+ bench_trans<double, ublas::basic_row_major<>, 10, 10> b2;
+ bench_trans<std::complex<float>, ublas::basic_row_major<>, 10, 10> b3;
+ bench_trans<std::complex<double>, ublas::basic_row_major<>, 10, 10> b4;
+
+ //Column-major
+ bench_trans<float, ublas::basic_column_major<>, 10, 10> b5;
+ bench_trans<double, ublas::basic_column_major<>, 10, 10> b6;
+ bench_trans<std::complex<float>, ublas::basic_column_major<>, 10, 10> b7;
+ bench_trans<std::complex<double>, ublas::basic_column_major<>, 10, 10> b8;
+
+ std::cout << "Row-major:" << std::endl;
+ b1.run();
+ b2.run();
+ b3.run();
+ b4.run();
+
+ std::cout << std::endl << "Column-major:" << std::endl;
+
+ b5.run();
+ b6.run();
+ b7.run();
+ b8.run();
+
+ return 0;
+
+} \ No newline at end of file
diff --git a/src/boost/libs/numeric/ublas/test/opencl/transposition_test.hpp b/src/boost/libs/numeric/ublas/test/opencl/transposition_test.hpp
new file mode 100644
index 00000000..eca469f9
--- /dev/null
+++ b/src/boost/libs/numeric/ublas/test/opencl/transposition_test.hpp
@@ -0,0 +1,61 @@
+#ifndef TEST_TRANS_OPENCL_HH
+#define TEST_TRANS_OPENCL_HH
+#include "test_opencl.hpp"
+
+
+template <class T, class F, int number_of_tests, int max_dimension>
+class bench_trans
+{
+public:
+
+ typedef test_opencl<T, F> test;
+
+ void run()
+ {
+ opencl::library lib;
+ int passedOperations = 0;
+ // get default device and setup context
+ compute::device device = compute::system::default_device();
+ compute::context context(device);
+ compute::command_queue queue(context, device);
+
+ std::srand(time(0));
+
+ ublas::matrix<T, F> a;
+ ublas::matrix<T, F> resultUBLAS;
+ ublas::matrix<T, F> resultOPENCL;
+
+
+ for (int i = 0; i<number_of_tests; i++)
+ {
+ int rowsA = std::rand() % max_dimension + 1;
+ int colsA = std::rand() % max_dimension + 1;
+
+ a.resize(rowsA, colsA);
+
+ test::init_matrix(a, 200);
+
+ resultUBLAS = ublas::trans(a);
+ resultOPENCL = opencl::trans(a, queue);
+
+
+ if (!test::compare(resultUBLAS, resultOPENCL))
+ {
+ std::cout << "Error in calculations" << std::endl;
+
+ std::cout << "passed: " << passedOperations << std::endl;
+ return;
+ }
+
+ passedOperations++;
+
+ }
+ std::cout << "All is well (matrix opencl prod) of " << typeid(T).name() << std::endl;
+
+
+
+ }
+
+};
+
+#endif \ No newline at end of file