28 #ifndef VIENNACL_WITH_OPENCL
29 #define VIENNACL_WITH_OPENCL
50 #include <boost/thread.hpp>
57 template<
typename NumericT>
61 worker(std::size_t tid) : thread_id_(tid) {}
77 ss <<
"Result of thread " << thread_id_ <<
" on device " <<
viennacl::ocl::get_context(static_cast<long>(thread_id_)).
devices()[0].name() <<
": " << result << std::endl;
78 ss <<
" A: " << A << std::endl;
79 ss <<
" x: " << x << std::endl;
83 std::string message()
const {
return message_; }
87 std::size_t thread_id_;
100 std::cerr <<
"Error: No platform found!" << std::endl;
108 std::vector<viennacl::ocl::device>
const & devices = pf.
devices();
114 if (devices.size() > 1)
123 worker<ScalarType> work_functor0(0);
124 worker<ScalarType> work_functor1(1);
125 boost::thread worker_thread_0(boost::ref(work_functor0));
126 boost::thread worker_thread_1(boost::ref(work_functor1));
128 worker_thread_0.join();
129 worker_thread_1.join();
131 std::cout << work_functor0.message() << std::endl;
132 std::cout << work_functor1.message() << std::endl;
137 std::cout <<
"!!!! TUTORIAL COMPLETED SUCCESSFULLY !!!!" << std::endl;
T norm_2(std::vector< T, A > const &v1)
std::vector< platform > get_platforms()
Generic interface for the l^2-norm. See viennacl/linalg/vector_operations.hpp for implementations...
Represents an OpenCL device within ViennaCL.
Implementation of the dense matrix class.
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Implementations of the OpenCL backend, where all contexts are stored in.
viennacl::matrix_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_prod > outer_prod(const vector_base< NumericT > &vec1, const vector_base< NumericT > &vec2)
Returns a proxy class for the operation mat += vec1 * vec2^T, i.e. a rank 1 update.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
viennacl::ocl::context & get_context(long i)
Convenience function for returning the current context.
std::vector< viennacl::ocl::device > const & devices() const
Returns a vector with all devices in this context.
Implementation of the ViennaCL scalar class.
void setup_context(long i, std::vector< cl_device_id > const &devices)
Convenience function for setting devices for a context.