ViennaCL - The Vienna Computing Library  1.6.0
Free open-source GPU-accelerated linear algebra and solver library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bisect_kernel_calls.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_OPENCL_BISECT_KERNEL_CALLS_HPP_
2 #define VIENNACL_LINALG_OPENCL_BISECT_KERNEL_CALLS_HPP_
3 
4 
5 /* =========================================================================
6  Copyright (c) 2010-2014, Institute for Microelectronics,
7  Institute for Analysis and Scientific Computing,
8  TU Wien.
9  Portions of this software are copyright by UChicago Argonne, LLC.
10 
11  -----------------
12  ViennaCL - The Vienna Computing Library
13  -----------------
14 
15  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
16 
17  (A list of authors and contributors can be found in the PDF manual)
18 
19  License: MIT (X11), see file LICENSE in the base directory
20 ============================================================================= */
21 
22 
31 // includes, project
33 
34 namespace viennacl
35 {
36 namespace linalg
37 {
38 namespace opencl
39 {
40 const std::string BISECT_KERNEL_SMALL = "bisectKernel";
41 const std::string BISECT_KERNEL_LARGE = "bisectKernelLarge";
42 const std::string BISECT_KERNEL_LARGE_ONE_INTERVALS = "bisectKernelLarge_OneIntervals";
43 const std::string BISECT_KERNEL_LARGE_MULT_INTERVALS = "bisectKernelLarge_MultIntervals";
44 
45 template<typename NumericT>
48  const unsigned int mat_size,
49  const NumericT lg, const NumericT ug,
50  const NumericT precision)
51  {
52  viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(input.g_a).context());
54 
58 
59  viennacl::ocl::enqueue(kernel(viennacl::traits::opencl_handle(input.g_a),
60  viennacl::traits::opencl_handle(input.g_b),
61  static_cast<cl_uint>(mat_size),
62  viennacl::traits::opencl_handle(result.vcl_g_left),
63  viennacl::traits::opencl_handle(result.vcl_g_right),
64  viennacl::traits::opencl_handle(result.vcl_g_left_count),
65  viennacl::traits::opencl_handle(result.vcl_g_right_count),
66  static_cast<NumericT>(lg),
67  static_cast<NumericT>(ug),
68  static_cast<cl_uint>(0),
69  static_cast<cl_uint>(mat_size),
70  static_cast<NumericT>(precision)
71  ));
72 
73  }
74 
75 template<typename NumericT>
78  const unsigned int mat_size,
79  const NumericT lg, const NumericT ug,
80  const NumericT precision)
81  {
82  viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(input.g_a).context());
84 
88 
89  viennacl::ocl::enqueue(kernel(viennacl::traits::opencl_handle(input.g_a),
90  viennacl::traits::opencl_handle(input.g_b),
91  static_cast<cl_uint>(mat_size),
92  static_cast<NumericT>(lg),
93  static_cast<NumericT>(ug),
94  static_cast<cl_uint>(0),
95  static_cast<cl_uint>(mat_size),
96  static_cast<NumericT>(precision),
97  viennacl::traits::opencl_handle(result.g_num_one),
98  viennacl::traits::opencl_handle(result.g_num_blocks_mult),
99  viennacl::traits::opencl_handle(result.g_left_one),
100  viennacl::traits::opencl_handle(result.g_right_one),
101  viennacl::traits::opencl_handle(result.g_pos_one),
102  viennacl::traits::opencl_handle(result.g_left_mult),
103  viennacl::traits::opencl_handle(result.g_right_mult),
104  viennacl::traits::opencl_handle(result.g_left_count_mult),
105  viennacl::traits::opencl_handle(result.g_right_count_mult),
106  viennacl::traits::opencl_handle(result.g_blocks_mult),
107  viennacl::traits::opencl_handle(result.g_blocks_mult_sum)
108  ));
109 
110  }
111 
112 template<typename NumericT>
115  const unsigned int mat_size,
116  const NumericT precision)
117  {
118  unsigned int num_one_intervals = result.g_num_one;
119  unsigned int num_blocks = viennacl::linalg::detail::getNumBlocksLinear(num_one_intervals, VIENNACL_BISECT_MAX_THREADS_BLOCK);
120 
121  viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(input.g_a).context());
123 
125  kernel.global_work_size(0, num_blocks * VIENNACL_BISECT_MAX_THREADS_BLOCK);
126  kernel.local_work_size(0, VIENNACL_BISECT_MAX_THREADS_BLOCK);
127 
128  viennacl::ocl::enqueue(kernel(viennacl::traits::opencl_handle(input.g_a),
129  viennacl::traits::opencl_handle(input.g_b),
130  static_cast<cl_uint>(mat_size),
131  static_cast<cl_uint>(num_one_intervals),
132  viennacl::traits::opencl_handle(result.g_left_one),
133  viennacl::traits::opencl_handle(result.g_right_one),
134  viennacl::traits::opencl_handle(result.g_pos_one),
135  static_cast<NumericT>(precision)
136  ));
137  }
138 
139 
140 template<typename NumericT>
143  const unsigned int mat_size,
144  const NumericT precision)
145  {
146  unsigned int num_blocks_mult = result.g_num_blocks_mult;
147 
148  viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(input.g_a).context());
150 
152  kernel.global_work_size(0, num_blocks_mult * VIENNACL_BISECT_MAX_THREADS_BLOCK);
153  kernel.local_work_size(0, VIENNACL_BISECT_MAX_THREADS_BLOCK);
154 
155  viennacl::ocl::enqueue(kernel(viennacl::traits::opencl_handle(input.g_a),
156  viennacl::traits::opencl_handle(input.g_b),
157  static_cast<cl_uint>(mat_size),
158  viennacl::traits::opencl_handle(result.g_blocks_mult),
159  viennacl::traits::opencl_handle(result.g_blocks_mult_sum),
160  viennacl::traits::opencl_handle(result.g_left_mult),
161  viennacl::traits::opencl_handle(result.g_right_mult),
162  viennacl::traits::opencl_handle(result.g_left_count_mult),
163  viennacl::traits::opencl_handle(result.g_right_count_mult),
164  viennacl::traits::opencl_handle(result.g_lambda_mult),
165  viennacl::traits::opencl_handle(result.g_pos_mult),
166  static_cast<NumericT>(precision)
167  ));
168  }
169 } // namespace opencl
170 } // namespace linalg
171 } // namespace viennacl
172 
173 #endif
static void init(viennacl::ocl::context &ctx)
Definition: bisect.hpp:2528
viennacl::vector< NumericT > g_b
device side representation of superdiagonal
Definition: structs.hpp:62
void bisectLargeMultIntervals(const viennacl::linalg::detail::InputData< NumericT > &input, viennacl::linalg::detail::ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT precision)
viennacl::vector< NumericT > g_left_mult
Definition: structs.hpp:155
void bisectSmall(const viennacl::linalg::detail::InputData< NumericT > &input, viennacl::linalg::detail::ResultDataSmall< NumericT > &result, const unsigned int mat_size, const NumericT lg, const NumericT ug, const NumericT precision)
#define VIENNACL_BISECT_MAX_THREADS_BLOCK
Definition: config.hpp:31
viennacl::vector< NumericT > g_left_one
Definition: structs.hpp:143
Represents an OpenCL kernel within ViennaCL.
Definition: kernel.hpp:58
size_type local_work_size(int index=0) const
Returns the local work size at the respective dimension.
Definition: kernel.hpp:742
viennacl::scalar< unsigned int > g_num_blocks_mult
Definition: structs.hpp:139
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Definition: context.hpp:54
viennacl::vector< unsigned int > g_blocks_mult
Definition: structs.hpp:169
viennacl::vector< unsigned int > g_left_count_mult
Definition: structs.hpp:162
const std::string BISECT_KERNEL_SMALL
const std::string BISECT_KERNEL_LARGE_ONE_INTERVALS
viennacl::vector< unsigned int > g_right_count_mult
Definition: structs.hpp:166
const std::string BISECT_KERNEL_LARGE
In this class the input matrix is stored.
Definition: structs.hpp:53
void bisectLargeOneIntervals(const viennacl::linalg::detail::InputData< NumericT > &input, viennacl::linalg::detail::ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT precision)
viennacl::ocl::kernel & get_kernel(std::string const &program_name, std::string const &kernel_name)
Convenience function for retrieving the kernel of a program directly from the context.
Definition: context.hpp:607
unsigned int getNumBlocksLinear(const unsigned int num_threads, const unsigned int num_threads_block)
Definition: util.hpp:96
viennacl::vector< NumericT > vcl_g_right
right interval limits at the end of the computation
Definition: structs.hpp:105
viennacl::vector< NumericT > g_lambda_mult
Definition: structs.hpp:177
viennacl::vector< NumericT > vcl_g_left
left interval limits at the end of the computation
Definition: structs.hpp:103
viennacl::vector< unsigned int > vcl_g_left_count
number of eigenvalues smaller than the left interval limit
Definition: structs.hpp:107
viennacl::vector< unsigned int > g_pos_one
Definition: structs.hpp:151
OpenCL kernels for the bisection algorithm for eigenvalues.
#define VIENNACL_BISECT_MAX_THREADS_BLOCK_SMALL_MATRIX
Definition: config.hpp:34
const std::string BISECT_KERNEL_LARGE_MULT_INTERVALS
viennacl::vector< NumericT > g_right_one
Definition: structs.hpp:147
void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
Definition: enqueue.hpp:50
viennacl::vector< unsigned int > g_pos_mult
Definition: structs.hpp:181
viennacl::vector< unsigned int > vcl_g_right_count
number of eigenvalues bigger than the right interval limit
Definition: structs.hpp:109
In this class the data of the result for large matrices is stored.
Definition: structs.hpp:129
size_type global_work_size(int index=0) const
Returns the global work size at the respective dimension.
Definition: kernel.hpp:751
viennacl::vector< unsigned int > g_blocks_mult_sum
Definition: structs.hpp:173
viennacl::scalar< unsigned int > g_num_one
number of intervals containing one eigenvalue after the first step
Definition: structs.hpp:135
In this class the data of the result for small matrices is stored.
Definition: structs.hpp:98
Main kernel class for the generation of the bisection kernels and utilities.
Definition: bisect.hpp:2521
void bisectLarge(const viennacl::linalg::detail::InputData< NumericT > &input, viennacl::linalg::detail::ResultDataLarge< NumericT > &result, const unsigned int mat_size, const NumericT lg, const NumericT ug, const NumericT precision)
viennacl::vector< NumericT > g_a
device side representation of diagonal
Definition: structs.hpp:60
viennacl::vector< NumericT > g_right_mult
Definition: structs.hpp:158