ViennaCL - The Vienna Computing Library  1.5.2
viennacl/rand/gaussian.hpp
Go to the documentation of this file.
00001 #ifndef VIENNACL_RAND_GAUSSIAN_HPP_
00002 #define VIENNACL_RAND_GAUSSIAN_HPP_
00003 
00004 /* =========================================================================
00005    Copyright (c) 2010-2014, Institute for Microelectronics,
00006                             Institute for Analysis and Scientific Computing,
00007                             TU Wien.
00008    Portions of this software are copyright by UChicago Argonne, LLC.
00009 
00010                             -----------------
00011                   ViennaCL - The Vienna Computing Library
00012                             -----------------
00013 
00014    Project Head:    Karl Rupp                   rupp@iue.tuwien.ac.at
00015 
00016    (A list of authors and contributors can be found in the PDF manual)
00017 
00018    License:         MIT (X11), see file LICENSE in the base directory
00019 ============================================================================= */
00020 
00021 #include "viennacl/backend/mem_handle.hpp"
00022 #include "viennacl/rand/utils.hpp"
00023 
00030 namespace viennacl{
00031 
00032 namespace rand{
00033 
00034 struct gaussian_tag{
00035     gaussian_tag(float _mu = 0, float _sigma = 1) : mu(_mu), sigma(_sigma){ }
00036     float mu;
00037     float sigma;
00038 };
00039 
00040 template<class ScalarType>
00041 struct buffer_dumper<ScalarType, gaussian_tag>{
00042     static void dump(viennacl::backend::mem_handle const & buff, gaussian_tag tag, cl_uint start, cl_uint size){
00043       viennacl::ocl::kernel & k = viennacl::ocl::get_kernel(viennacl::linalg::kernels::rand<ScalarType,1>::program_name(),"dump_gaussian");
00044       k.global_work_size(0, viennacl::tools::align_to_multiple<unsigned int>(size/2,k.local_work_size(0)));
00045       viennacl::ocl::enqueue(k(buff.opencl_handle(), start, size, cl_float(tag.mu), cl_float(tag.sigma) , cl_uint(time(0))));
00046     }
00047 };
00048 
00049 }
00050 
00051 }
00052 
00054 #endif