28 #ifndef VIENNACL_WITH_OPENCL
29 #define VIENNACL_WITH_OPENCL
48 #include <boost/thread.hpp>
55 template<
typename NumericT>
59 worker(std::size_t tid) : thread_id_(tid) {}
75 ss <<
"Result of thread " << thread_id_ <<
" on device " <<
viennacl::ocl::get_context(static_cast<long>(thread_id_)).
devices()[0].name() <<
": " << result << std::endl;
76 ss <<
" A: " << A << std::endl;
77 ss <<
" x: " << x << std::endl;
81 std::string message()
const {
return message_; }
85 std::size_t thread_id_;
98 std::cerr <<
"Error: No platform found!" << std::endl;
106 std::vector<viennacl::ocl::device>
const & devices = pf.
devices();
112 if (devices.size() > 1)
121 worker<ScalarType> work_functor0(0);
122 worker<ScalarType> work_functor1(1);
123 boost::thread worker_thread_0(boost::ref(work_functor0));
124 boost::thread worker_thread_1(boost::ref(work_functor1));
126 worker_thread_0.join();
127 worker_thread_1.join();
129 std::cout << work_functor0.message() << std::endl;
130 std::cout << work_functor1.message() << std::endl;
135 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.