ViennaCL - The Vienna Computing Library  1.5.1
uniform.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_RAND_UNIFORM_HPP_
2 #define VIENNACL_RAND_UNIFORM_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2014, 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 PDF manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
22 #include "viennacl/rand/utils.hpp"
23 
29 namespace viennacl{
30 
31 namespace rand{
32 
33 struct uniform_tag{
34  uniform_tag(unsigned int _a = 0, unsigned int _b = 1) : a(_a), b(_b){ }
35  float a;
36  float b;
37 };
38 
39 template<class ScalarType>
40 struct buffer_dumper<ScalarType, uniform_tag>{
41  static void dump(viennacl::backend::mem_handle const & buff, uniform_tag tag, cl_uint start, cl_uint size){
42  viennacl::ocl::kernel & k = viennacl::ocl::get_kernel(viennacl::linalg::kernels::rand<ScalarType,1>::program_name(),"dump_uniform");
43  k.global_work_size(0, viennacl::tools::align_to_multiple<unsigned int>(size,k.local_work_size(0)));
44  viennacl::ocl::enqueue(k(buff.opencl_handle(), start, size, cl_float(tag.a), cl_float(tag.b) , cl_uint(time(0))));
45  }
46 };
47 
48 
49 
50 }
51 
52 }
53 
56 #endif
viennacl::ocl::kernel & get_kernel(std::string const &prog_name, std::string const &kernel_name)
Convenience function for getting the kernel for a particular program from the current active context...
Definition: backend.hpp:318
Represents an OpenCL kernel within ViennaCL.
Definition: kernel.hpp:59
Unused: Helper functionality random number generation.
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144
void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
Definition: enqueue.hpp:48
result_of::size_type< T >::type start(T const &obj)
Definition: start.hpp:43
Implements the multi-memory-domain handle.
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Definition: mem_handle.hpp:62
size_type global_work_size(int index=0) const
Returns the global work size at the respective dimension.
Definition: kernel.hpp:759
size_type local_work_size(int index=0) const
Returns the local work size at the respective dimension.
Definition: kernel.hpp:750