ViennaCL - The Vienna Computing Library  1.5.2
viennacl/linalg/opencl/common.hpp
Go to the documentation of this file.
00001 #ifndef VIENNACL_LINALG_OPENCL_COMMON_HPP_
00002 #define VIENNACL_LINALG_OPENCL_COMMON_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 
00025 #include <cmath>
00026 
00027 #include "viennacl/forwards.h"
00028 #include "viennacl/ocl/platform.hpp"
00029 
00030 namespace viennacl
00031 {
00032   namespace linalg
00033   {
00034     namespace opencl
00035     {
00036 
00037       namespace detail
00038       {
00039         inline cl_uint make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
00040         {
00041           return static_cast<cl_uint>( ((length > 1) ? (cl_uint(length) << 2) : 0) + (reciprocal ? 2 : 0) + (flip_sign ? 1 : 0) );
00042         }
00043 
00044 
00046         inline std::string sparse_dense_matmult_kernel_name(bool B_transposed, bool B_row_major, bool C_row_major)
00047         {
00048           if (B_transposed)
00049           {
00050             if (B_row_major && C_row_major)
00051               return "trans_mat_mult_row_row";
00052             if (B_row_major && !C_row_major)
00053               return "trans_mat_mult_row_col";
00054             if (!B_row_major && C_row_major)
00055               return "trans_mat_mult_col_row";
00056 
00057             return "trans_mat_mult_col_col";
00058           }
00059 
00060           if (B_row_major && C_row_major)
00061             return "mat_mult_row_row";
00062           if (B_row_major && !C_row_major)
00063             return "mat_mult_row_col";
00064           if (!B_row_major && C_row_major)
00065             return "mat_mult_col_row";
00066 
00067           return "mat_mult_col_col";
00068         }
00069 
00070 
00071         inline std::string op_to_string(op_abs)   { return "abs";   }
00072         inline std::string op_to_string(op_acos)  { return "acos";  }
00073         inline std::string op_to_string(op_asin)  { return "asin";  }
00074         inline std::string op_to_string(op_atan)  { return "atan";  }
00075         inline std::string op_to_string(op_ceil)  { return "ceil";  }
00076         inline std::string op_to_string(op_cos)   { return "cos";   }
00077         inline std::string op_to_string(op_cosh)  { return "cosh";  }
00078         inline std::string op_to_string(op_exp)   { return "exp";   }
00079         inline std::string op_to_string(op_fabs)  { return "fabs";  }
00080         inline std::string op_to_string(op_floor) { return "floor"; }
00081         inline std::string op_to_string(op_log)   { return "log";   }
00082         inline std::string op_to_string(op_log10) { return "log10"; }
00083         inline std::string op_to_string(op_sin)   { return "sin";   }
00084         inline std::string op_to_string(op_sinh)  { return "sinh";  }
00085         inline std::string op_to_string(op_sqrt)  { return "sqrt";  }
00086         inline std::string op_to_string(op_tan)   { return "tan";   }
00087         inline std::string op_to_string(op_tanh)  { return "tanh";  }
00088       }
00089 
00090     } //namespace opencl
00091   } //namespace linalg
00092 } //namespace viennacl
00093 
00094 
00095 #endif