ViennaCL - The Vienna Computing Library  1.7.0
Free open-source GPU-accelerated linear algebra and solver library.
kernel.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_OCL_KERNEL_HPP_
2 #define VIENNACL_OCL_KERNEL_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2015, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8  Portions of this software are copyright by UChicago Argonne, LLC.
9 
10  -----------------
11  ViennaCL - The Vienna Computing Library
12  -----------------
13 
14  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15 
16  (A list of authors and contributors can be found in the manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
25 #ifdef __APPLE__
26 #include <OpenCL/cl.h>
27 #else
28 #include <CL/cl.h>
29 #endif
30 
31 #include "viennacl/ocl/forwards.h"
32 #include "viennacl/ocl/handle.hpp"
33 #include "viennacl/ocl/program.hpp"
34 #include "viennacl/ocl/device.hpp"
36 
37 namespace viennacl
38 {
39  namespace ocl
40  {
46  {
48  cl_uint start;
50  cl_uint stride;
52  cl_uint size;
54  cl_uint internal_size;
55  };
56 
58  class kernel
59  {
60  template<typename KernelType>
61  friend void enqueue(KernelType & k, viennacl::ocl::command_queue const & queue);
62 
63  public:
65 
66  kernel() : handle_(), p_program_(NULL), p_context_(NULL), name_()
67  {
68  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
69  std::cout << "ViennaCL: Creating kernel object (default CTOR): " << name_ << std::endl;
70  #endif
71  }
72 
73  kernel(cl_kernel kernel_handle, viennacl::ocl::program const & kernel_program, viennacl::ocl::context const & kernel_context, std::string const & name)
74  : handle_(kernel_handle, kernel_context), p_program_(&kernel_program), p_context_(&kernel_context), name_(name)
75  {
76  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
77  std::cout << "ViennaCL: Creating kernel object (full CTOR): " << name_ << std::endl;
78  #endif
79  set_work_size_defaults();
80  }
81 
82  kernel(kernel const & other)
83  : handle_(other.handle_), p_program_(other.p_program_), p_context_(other.p_context_), name_(other.name_)
84  {
85  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
86  std::cout << "ViennaCL: Creating kernel object (Copy CTOR): " << name_ << std::endl;
87  #endif
88  local_work_size_[0] = other.local_work_size_[0];
89  local_work_size_[1] = other.local_work_size_[1];
90  local_work_size_[2] = other.local_work_size_[2];
91 
92  global_work_size_[0] = other.global_work_size_[0];
93  global_work_size_[1] = other.global_work_size_[1];
94  global_work_size_[2] = other.global_work_size_[2];
95  }
96 
98  {
99  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
100  std::cout << "ViennaCL: Assigning kernel object: " << other.name_ << std::endl;
101  #endif
102  handle_ = other.handle_;
103  p_program_ = other.p_program_;
104  p_context_ = other.p_context_;
105  name_ = other.name_;
106  local_work_size_[0] = other.local_work_size_[0];
107  local_work_size_[1] = other.local_work_size_[1];
108  local_work_size_[2] = other.local_work_size_[2];
109  global_work_size_[0] = other.global_work_size_[0];
110  global_work_size_[1] = other.global_work_size_[1];
111  global_work_size_[2] = other.global_work_size_[2];
112  return *this;
113  }
114 
116  void arg(unsigned int pos, cl_char val)
117  {
118  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
119  std::cout << "ViennaCL: Setting char kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
120  #endif
121  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(cl_char), (void*)&val);
122  VIENNACL_ERR_CHECK(err);
123  }
124 
126  void arg(unsigned int pos, cl_uchar val)
127  {
128  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
129  std::cout << "ViennaCL: Setting unsigned char kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
130  #endif
131  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(cl_uchar), (void*)&val);
132  VIENNACL_ERR_CHECK(err);
133  }
134 
136  void arg(unsigned int pos, cl_short val)
137  {
138  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
139  std::cout << "ViennaCL: Setting short kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
140  #endif
141  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(cl_short), (void*)&val);
142  VIENNACL_ERR_CHECK(err);
143  }
144 
146  void arg(unsigned int pos, cl_ushort val)
147  {
148  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
149  std::cout << "ViennaCL: Setting unsigned short kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
150  #endif
151  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(cl_ushort), (void*)&val);
152  VIENNACL_ERR_CHECK(err);
153  }
154 
155 
157  void arg(unsigned int pos, cl_uint val)
158  {
159  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
160  std::cout << "ViennaCL: Setting unsigned int kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
161  #endif
162  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(cl_uint), (void*)&val);
163  VIENNACL_ERR_CHECK(err);
164  }
165 
167  void arg(unsigned int pos, packed_cl_uint val)
168  {
169  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
170  std::cout << "ViennaCL: Setting packed_cl_uint kernel argument (" << val.start << ", " << val.stride << ", " << val.size << ", " << val.internal_size << ") at pos " << pos << " for kernel " << name_ << std::endl;
171  #endif
172  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(packed_cl_uint), (void*)&val);
173  VIENNACL_ERR_CHECK(err);
174  }
175 
177  void arg(unsigned int pos, float val)
178  {
179  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
180  std::cout << "ViennaCL: Setting floating point kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
181  #endif
182  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(float), (void*)&val);
183  VIENNACL_ERR_CHECK(err);
184  }
185 
187  void arg(unsigned int pos, double val)
188  {
189  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
190  std::cout << "ViennaCL: Setting double precision kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
191  #endif
192  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(double), (void*)&val);
193  VIENNACL_ERR_CHECK(err);
194  }
195 
197  void arg(unsigned int pos, cl_int val)
198  {
199  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
200  std::cout << "ViennaCL: Setting int precision kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
201  #endif
202  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(cl_int), (void*)&val);
203  VIENNACL_ERR_CHECK(err);
204  }
205 
207  void arg(unsigned int pos, cl_ulong val)
208  {
209  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
210  std::cout << "ViennaCL: Setting ulong precision kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
211  #endif
212  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(cl_ulong), (void*)&val);
213  VIENNACL_ERR_CHECK(err);
214  }
215 
217  void arg(unsigned int pos, cl_long val)
218  {
219  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
220  std::cout << "ViennaCL: Setting long precision kernel argument " << val << " at pos " << pos << " for kernel " << name_ << std::endl;
221  #endif
222  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(cl_long), (void*)&val);
223  VIENNACL_ERR_CHECK(err);
224  }
225 
226  //generic handling: call .handle() member
228  template<class VCL_TYPE>
229  void arg(unsigned int pos, VCL_TYPE const & val)
230  {
231  assert(&val.handle().opencl_handle().context() == &handle_.context() && bool("Kernel and memory object not in the same context!"));
232 
233  cl_mem temp = val.handle().opencl_handle().get();
234  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
235  std::cout << "ViennaCL: Setting generic kernel argument " << temp << " at pos " << pos << " for kernel " << name_ << std::endl;
236  #endif
237  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(cl_mem), (void*)&temp);
238  VIENNACL_ERR_CHECK(err);
239  }
240 
241  //forward handles directly:
243  template<class CL_TYPE>
244  void arg(unsigned int pos, viennacl::ocl::handle<CL_TYPE> const & h)
245  {
246  CL_TYPE temp = h.get();
247  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
248  std::cout << "ViennaCL: Setting handle kernel argument " << temp << " at pos " << pos << " for kernel " << name_ << std::endl;
249  #endif
250  cl_int err = clSetKernelArg(handle_.get(), pos, sizeof(CL_TYPE), (void*)&temp);
251  VIENNACL_ERR_CHECK(err);
252  }
253 
254 
255  //local buffer argument:
257  void arg(unsigned int pos, const local_mem & mem)
258  {
259  cl_uint size = static_cast<cl_uint>(mem.size());
260  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
261  std::cout << "ViennaCL: Setting local memory kernel argument of size " << size << " bytes at pos " << pos << " for kernel " << name_ << std::endl;
262  #endif
263  cl_int err = clSetKernelArg(handle_.get(), pos, size, 0);
264  VIENNACL_ERR_CHECK(err);
265  }
266 
267 
268 
270  template<typename T0>
271  kernel & operator()(T0 const & t0)
272  {
273  arg(0, t0);
274  return *this;
275  }
276 
278  template<typename T0, typename T1>
279  kernel & operator()(T0 const & t0, T1 const & t1)
280  {
281  arg(0, t0); arg(1, t1);
282  return *this;
283  }
284 
286  template<typename T0, typename T1, typename T2>
287  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2)
288  {
289  arg(0, t0); arg(1, t1); arg(2, t2);
290  return *this;
291  }
292 
294  template<typename T0, typename T1, typename T2, typename T3>
295  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3)
296  {
297  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3);
298  return *this;
299  }
300 
302  template<typename T0, typename T1, typename T2, typename T3, typename T4>
303  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4)
304  {
305  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4);
306  return *this;
307  }
308 
310  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
311  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5)
312  {
313  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
314  return *this;
315  }
316 
318  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
319  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5, T6 const & t6)
320  {
321  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5); arg(6, t6);
322  return *this;
323  }
324 
326  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
327  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5, T6 const & t6, T7 const & t7)
328  {
329  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5); arg(6, t6); arg(7, t7);
330  return *this;
331  }
332 
334  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
335  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5, T6 const & t6, T7 const & t7, T8 const & t8)
336  {
337  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5); arg(6, t6); arg(7, t7); arg(8, t8);
338  return *this;
339  }
340 
342  template<typename T0, typename T1, typename T2, typename T3, typename T4,
343  typename T5, typename T6, typename T7, typename T8, typename T9>
344  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4,
345  T5 const & t5, T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9)
346  {
347  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5); arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9);
348  return *this;
349  }
350 
352  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
353  typename T6, typename T7, typename T8, typename T9, typename T10>
354  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
355  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10)
356  {
357  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5); arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10);
358  return *this;
359  }
360 
362  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
363  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
364  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
365  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11)
366  {
367  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
368  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
369  return *this;
370  }
371 
373  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
374  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12>
375  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
376  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11, T12 const & t12)
377  {
378  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
379  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11); arg(12, t12);
380  return *this;
381  }
382 
384  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
385  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
386  typename T12, typename T13>
387  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
388  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
389  T12 const & t12, T13 const & t13)
390  {
391  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
392  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
393  arg(12, t12); arg(13, t13);
394  return *this;
395  }
396 
398  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
399  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
400  typename T12, typename T13, typename T14>
401  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
402  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
403  T12 const & t12, T13 const & t13, T14 const & t14)
404  {
405  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
406  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
407  arg(12, t12); arg(13, t13); arg(14, t14);
408  return *this;
409  }
410 
412  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
413  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
414  typename T12, typename T13, typename T14, typename T15>
415  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
416  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
417  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15)
418  {
419  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
420  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
421  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15);
422  return *this;
423  }
424 
426  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
427  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
428  typename T12, typename T13, typename T14, typename T15, typename T16>
429  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
430  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
431  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16)
432  {
433  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
434  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
435  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16);
436  return *this;
437  }
438 
440  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
441  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
442  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17>
443  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
444  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
445  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17)
446  {
447  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
448  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
449  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
450  return *this;
451  }
452 
454  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
455  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
456  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
457  typename T18>
458  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
459  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
460  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
461  T18 const & t18
462  )
463  {
464  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
465  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
466  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
467  arg(18, t18);
468  return *this;
469  }
470 
472  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
473  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
474  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
475  typename T18, typename T19>
476  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
477  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
478  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
479  T18 const & t18, T19 const & t19
480  )
481  {
482  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
483  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
484  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
485  arg(18, t18); arg(19, t19);
486  return *this;
487  }
488 
490  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
491  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
492  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
493  typename T18, typename T19, typename T20>
494  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
495  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
496  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
497  T18 const & t18, T19 const & t19, T20 const & t20
498  )
499  {
500  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
501  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
502  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
503  arg(18, t18); arg(19, t19); arg(20, t20);
504  return *this;
505  }
506 
508  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
509  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
510  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
511  typename T18, typename T19, typename T20, typename T21>
512  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
513  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
514  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
515  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21
516  )
517  {
518  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
519  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
520  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
521  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21);
522  return *this;
523  }
524 
526  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
527  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
528  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
529  typename T18, typename T19, typename T20, typename T21, typename T22>
530  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
531  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
532  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
533  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22
534  )
535  {
536  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
537  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
538  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
539  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22);
540  return *this;
541  }
542 
544  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
545  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
546  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
547  typename T18, typename T19, typename T20, typename T21, typename T22, typename T23>
548  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
549  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
550  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
551  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22, T23 const & t23
552  )
553  {
554  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
555  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
556  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
557  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22); arg(23, t23);
558  return *this;
559  }
560 
562  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
563  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
564  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
565  typename T18, typename T19, typename T20, typename T21, typename T22, typename T23,
566  typename T24>
567  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
568  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
569  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
570  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22, T23 const & t23,
571  T24 const & t24
572  )
573  {
574  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
575  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
576  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
577  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22); arg(23, t23);
578  arg(24, t24);
579  return *this;
580  }
581 
583  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
584  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
585  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
586  typename T18, typename T19, typename T20, typename T21, typename T22, typename T23,
587  typename T24, typename T25>
588  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
589  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
590  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
591  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22, T23 const & t23,
592  T24 const & t24, T25 const & t25
593  )
594  {
595  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
596  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
597  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
598  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22); arg(23, t23);
599  arg(24, t24); arg(25, t25);
600  return *this;
601  }
602 
604  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
605  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
606  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
607  typename T18, typename T19, typename T20, typename T21, typename T22, typename T23,
608  typename T24, typename T25, typename T26>
609  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
610  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
611  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
612  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22, T23 const & t23,
613  T24 const & t24, T25 const & t25, T26 const & t26
614  )
615  {
616  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
617  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
618  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
619  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22); arg(23, t23);
620  arg(24, t24); arg(25, t25); arg(26, t26);
621  return *this;
622  }
623 
625  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
626  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
627  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
628  typename T18, typename T19, typename T20, typename T21, typename T22, typename T23,
629  typename T24, typename T25, typename T26, typename T27>
630  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
631  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
632  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
633  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22, T23 const & t23,
634  T24 const & t24, T25 const & t25, T26 const & t26, T27 const & t27
635  )
636  {
637  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
638  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
639  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
640  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22); arg(23, t23);
641  arg(24, t24); arg(25, t25); arg(26, t26); arg(27, t27);
642  return *this;
643  }
644 
646  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
647  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
648  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
649  typename T18, typename T19, typename T20, typename T21, typename T22, typename T23,
650  typename T24, typename T25, typename T26, typename T27, typename T28>
651  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
652  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
653  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
654  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22, T23 const & t23,
655  T24 const & t24, T25 const & t25, T26 const & t26, T27 const & t27, T28 const & t28
656  )
657  {
658  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
659  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
660  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
661  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22); arg(23, t23);
662  arg(24, t24); arg(25, t25); arg(26, t26); arg(27, t27); arg(28, t28);
663  return *this;
664  }
665 
667  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
668  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
669  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
670  typename T18, typename T19, typename T20, typename T21, typename T22, typename T23,
671  typename T24, typename T25, typename T26, typename T27, typename T28, typename T29>
672  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
673  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
674  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
675  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22, T23 const & t23,
676  T24 const & t24, T25 const & t25, T26 const & t26, T27 const & t27, T28 const & t28, T29 const & t29
677  )
678  {
679  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
680  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
681  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
682  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22); arg(23, t23);
683  arg(24, t24); arg(25, t25); arg(26, t26); arg(27, t27); arg(28, t28); arg(29, t29);
684  return *this;
685  }
686 
688  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
689  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
690  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
691  typename T18, typename T19, typename T20, typename T21, typename T22, typename T23,
692  typename T24, typename T25, typename T26, typename T27, typename T28, typename T29,
693  typename T30>
694  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
695  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
696  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
697  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22, T23 const & t23,
698  T24 const & t24, T25 const & t25, T26 const & t26, T27 const & t27, T28 const & t28, T29 const & t29,
699  T30 const & t30
700  )
701  {
702  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
703  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
704  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
705  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22); arg(23, t23);
706  arg(24, t24); arg(25, t25); arg(26, t26); arg(27, t27); arg(28, t28); arg(29, t29);
707  arg(30, t30);
708  return *this;
709  }
710 
712  template<typename T0, typename T1, typename T2, typename T3, typename T4, typename T5,
713  typename T6, typename T7, typename T8, typename T9, typename T10, typename T11,
714  typename T12, typename T13, typename T14, typename T15, typename T16, typename T17,
715  typename T18, typename T19, typename T20, typename T21, typename T22, typename T23,
716  typename T24, typename T25, typename T26, typename T27, typename T28, typename T29,
717  typename T30, typename T31>
718  kernel & operator()(T0 const & t0, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5,
719  T6 const & t6, T7 const & t7, T8 const & t8, T9 const & t9, T10 const & t10, T11 const & t11,
720  T12 const & t12, T13 const & t13, T14 const & t14, T15 const & t15, T16 const & t16, T17 const & t17,
721  T18 const & t18, T19 const & t19, T20 const & t20, T21 const & t21, T22 const & t22, T23 const & t23,
722  T24 const & t24, T25 const & t25, T26 const & t26, T27 const & t27, T28 const & t28, T29 const & t29,
723  T30 const & t30, T31 const & t31
724  )
725  {
726  arg(0, t0); arg(1, t1); arg(2, t2); arg(3, t3); arg(4, t4); arg(5, t5);
727  arg(6, t6); arg(7, t7); arg(8, t8); arg(9, t9); arg(10, t10); arg(11, t11);
728  arg(12, t12); arg(13, t13); arg(14, t14); arg(15, t15); arg(16, t16); arg(17, t17);
729  arg(18, t18); arg(19, t19); arg(20, t20); arg(21, t21); arg(22, t22); arg(23, t23);
730  arg(24, t24); arg(25, t25); arg(26, t26); arg(27, t27); arg(28, t28); arg(29, t29);
731  arg(30, t30); arg(31, t31);
732  return *this;
733  }
734 
735 
736 
737 
742  size_type local_work_size(int index = 0) const
743  {
744  assert(index < 3 && bool("Work size index out of bounds"));
745  return local_work_size_[index];
746  }
751  size_type global_work_size(int index = 0) const
752  {
753  assert(index < 3 && bool("Work size index out of bounds"));
754  return global_work_size_[index];
755  }
756 
762  void local_work_size(int index, size_type s)
763  {
764  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
765  std::cout << "ViennaCL: Setting local work size to " << s << " at index " << index << " for kernel " << name_ << std::endl;
766  #endif
767  assert(index < 3 && bool("Work size index out of bounds"));
768  local_work_size_[index] = s;
769  }
775  void global_work_size(int index, size_type s)
776  {
777  #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_KERNEL)
778  std::cout << "ViennaCL: Setting global work size to " << s << " at index " << index << " for kernel " << name_ << std::endl;
779  #endif
780  assert(index < 3 && bool("Work size index out of bounds"));
781  global_work_size_[index] = s;
782  }
783 
784  std::string const & name() const { return name_; }
785 
786  viennacl::ocl::handle<cl_kernel> const & handle() const { return handle_; }
787 
788  viennacl::ocl::context const & context() const { return *p_context_; }
789 
790  private:
791 
792  inline void set_work_size_defaults(); //see context.hpp for implementation
793 
795  viennacl::ocl::program const * p_program_;
796  viennacl::ocl::context const * p_context_;
797  std::string name_;
798  size_type local_work_size_[3];
799  size_type global_work_size_[3];
800  };
801 
802  } //namespace ocl
803 } //namespace viennacl
804 
805 #endif
cl_uint stride
Increment between integers.
Definition: kernel.hpp:50
kernel & operator()(T0 const &t0, T1 const &t1)
Convenience function for setting two kernel parameters.
Definition: kernel.hpp:279
This file provides the forward declarations for the OpenCL layer of ViennaCL.
Helper class for packing four cl_uint numbers into a uint4 type for access inside an OpenCL kernel...
Definition: kernel.hpp:45
Represents an OpenCL device within ViennaCL.
void arg(unsigned int pos, cl_ulong val)
Sets an unsigned long argument at the provided position.
Definition: kernel.hpp:207
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3)
Convenience function for setting four kernel parameters.
Definition: kernel.hpp:295
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19)
Convenience function for setting twenty kernel parameters.
Definition: kernel.hpp:476
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22, T23 const &t23, T24 const &t24)
Convenience function for setting 25 kernel parameters.
Definition: kernel.hpp:567
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10)
Convenience function for setting eleven kernel parameters.
Definition: kernel.hpp:354
friend void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
Definition: enqueue.hpp:50
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11)
Convenience function for setting twelve kernel parameters.
Definition: kernel.hpp:364
viennacl::ocl::handle< cl_kernel > const & handle() const
Definition: kernel.hpp:786
Represents an OpenCL kernel within ViennaCL.
Definition: kernel.hpp:58
kernel(kernel const &other)
Definition: kernel.hpp:82
cl_uint start
Starting value of the integer stride.
Definition: kernel.hpp:48
size_type local_work_size(int index=0) const
Returns the local work size at the respective dimension.
Definition: kernel.hpp:742
void arg(unsigned int pos, float val)
Sets a single precision floating point argument at the provided position.
Definition: kernel.hpp:177
vcl_size_t size_type
Definition: kernel.hpp:64
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Definition: context.hpp:55
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14)
Convenience function for setting fifteen kernel parameters.
Definition: kernel.hpp:401
void arg(unsigned int pos, cl_uchar val)
Sets a char argument at the provided position.
Definition: kernel.hpp:126
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6)
Convenience function for setting seven kernel parameters.
Definition: kernel.hpp:319
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22)
Convenience function for setting 23 kernel parameters.
Definition: kernel.hpp:530
std::string const & name() const
Definition: kernel.hpp:784
A class representing a command queue.
void arg(unsigned int pos, const local_mem &mem)
Sets an OpenCL local memory object at the provided position.
Definition: kernel.hpp:257
void local_work_size(int index, size_type s)
Sets the local work size at the respective dimension.
Definition: kernel.hpp:762
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22, T23 const &t23, T24 const &t24, T25 const &t25, T26 const &t26, T27 const &t27)
Convenience function for setting 28 kernel parameters.
Definition: kernel.hpp:630
void arg(unsigned int pos, cl_ushort val)
Sets a argument of type unsigned short at the provided position.
Definition: kernel.hpp:146
cl_uint internal_size
Internal length of the buffer. Might be larger than 'size' due to padding.
Definition: kernel.hpp:54
viennacl::ocl::context const & context() const
Definition: handle.hpp:191
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15)
Convenience function for setting sixteen kernel parameters.
Definition: kernel.hpp:415
#define VIENNACL_ERR_CHECK(err)
Definition: error.hpp:681
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16)
Convenience function for setting seventeen kernel parameters.
Definition: kernel.hpp:429
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:34
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9)
Convenience function for setting ten kernel parameters.
Definition: kernel.hpp:344
const OCL_TYPE & get() const
Definition: handle.hpp:189
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22, T23 const &t23, T24 const &t24, T25 const &t25, T26 const &t26, T27 const &t27, T28 const &t28, T29 const &t29, T30 const &t30, T31 const &t31)
Convenience function for setting 32 kernel parameters.
Definition: kernel.hpp:718
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:235
A class representing local (shared) OpenCL memory. Typically used as kernel argument.
Definition: local_mem.hpp:33
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7)
Convenience function for setting eight kernel parameters.
Definition: kernel.hpp:327
Implements an OpenCL program class for ViennaCL.
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5)
Convenience function for setting six kernel parameters.
Definition: kernel.hpp:311
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2)
Convenience function for setting three kernel parameters.
Definition: kernel.hpp:287
Implementation of a smart-pointer-like class for handling OpenCL handles.
viennacl::ocl::kernel & operator=(const kernel &other)
Definition: kernel.hpp:97
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20)
Convenience function for setting twentyone kernel parameters.
Definition: kernel.hpp:494
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17)
Convenience function for setting eighteen kernel parameters.
Definition: kernel.hpp:443
kernel(cl_kernel kernel_handle, viennacl::ocl::program const &kernel_program, viennacl::ocl::context const &kernel_context, std::string const &name)
Definition: kernel.hpp:73
void arg(unsigned int pos, packed_cl_uint val)
Sets four packed unsigned integers as argument at the provided position.
Definition: kernel.hpp:167
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4)
Convenience function for setting five kernel parameters.
Definition: kernel.hpp:303
std::size_t vcl_size_t
Definition: forwards.h:75
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22, T23 const &t23, T24 const &t24, T25 const &t25, T26 const &t26, T27 const &t27, T28 const &t28, T29 const &t29, T30 const &t30)
Convenience function for setting 31 kernel parameters.
Definition: kernel.hpp:694
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22, T23 const &t23, T24 const &t24, T25 const &t25, T26 const &t26, T27 const &t27, T28 const &t28)
Convenience function for setting 29 kernel parameters.
Definition: kernel.hpp:651
Wrapper class for an OpenCL program.
Definition: program.hpp:42
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22, T23 const &t23)
Convenience function for setting 24 kernel parameters.
Definition: kernel.hpp:548
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18)
Convenience function for setting nineteen kernel parameters.
Definition: kernel.hpp:458
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22, T23 const &t23, T24 const &t24, T25 const &t25, T26 const &t26)
Convenience function for setting 27 kernel parameters.
Definition: kernel.hpp:609
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21)
Convenience function for setting twentytwo kernel parameters.
Definition: kernel.hpp:512
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22, T23 const &t23, T24 const &t24, T25 const &t25, T26 const &t26, T27 const &t27, T28 const &t28, T29 const &t29)
Convenience function for setting 30 kernel parameters.
Definition: kernel.hpp:672
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13)
Convenience function for setting fourteen kernel parameters.
Definition: kernel.hpp:387
void arg(unsigned int pos, cl_int val)
Sets an int argument at the provided position.
Definition: kernel.hpp:197
void arg(unsigned int pos, VCL_TYPE const &val)
Sets an OpenCL memory object at the provided position.
Definition: kernel.hpp:229
viennacl::ocl::context const & context() const
Definition: kernel.hpp:788
kernel & operator()(T0 const &t0)
Convenience function for setting one kernel parameter.
Definition: kernel.hpp:271
size_type global_work_size(int index=0) const
Returns the global work size at the respective dimension.
Definition: kernel.hpp:751
vcl_size_t size() const
Returns size in bytes.
Definition: local_mem.hpp:39
void arg(unsigned int pos, viennacl::ocl::handle< CL_TYPE > const &h)
Sets an OpenCL object at the provided position.
Definition: kernel.hpp:244
void arg(unsigned int pos, cl_char val)
Sets a char argument at the provided position.
Definition: kernel.hpp:116
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12, T13 const &t13, T14 const &t14, T15 const &t15, T16 const &t16, T17 const &t17, T18 const &t18, T19 const &t19, T20 const &t20, T21 const &t21, T22 const &t22, T23 const &t23, T24 const &t24, T25 const &t25)
Convenience function for setting 26 kernel parameters.
Definition: kernel.hpp:588
void arg(unsigned int pos, double val)
Sets a double precision floating point argument at the provided position.
Definition: kernel.hpp:187
void global_work_size(int index, size_type s)
Sets the global work size at the respective dimension.
Definition: kernel.hpp:775
A local (shared) memory object for OpenCL.
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8, T9 const &t9, T10 const &t10, T11 const &t11, T12 const &t12)
Convenience function for setting thirteen kernel parameters.
Definition: kernel.hpp:375
void arg(unsigned int pos, cl_long val)
Sets an unsigned long argument at the provided position.
Definition: kernel.hpp:217
void arg(unsigned int pos, cl_uint val)
Sets an unsigned integer argument at the provided position.
Definition: kernel.hpp:157
void arg(unsigned int pos, cl_short val)
Sets a argument of type short at the provided position.
Definition: kernel.hpp:136
Handle class the effectively represents a smart pointer for OpenCL handles.
Definition: forwards.h:51
cl_uint size
Number of values in the stride.
Definition: kernel.hpp:52
kernel & operator()(T0 const &t0, T1 const &t1, T2 const &t2, T3 const &t3, T4 const &t4, T5 const &t5, T6 const &t6, T7 const &t7, T8 const &t8)
Convenience function for setting nine kernel parameters.
Definition: kernel.hpp:335