ViennaCL - The Vienna Computing Library  1.5.1
common.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_OPENCL_COMMON_HPP_
2 #define VIENNACL_LINALG_OPENCL_COMMON_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 
25 #include <cmath>
26 
27 #include "viennacl/forwards.h"
29 
30 namespace viennacl
31 {
32  namespace linalg
33  {
34  namespace opencl
35  {
36 
37  namespace detail
38  {
39  inline cl_uint make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
40  {
41  return static_cast<cl_uint>( ((length > 1) ? (cl_uint(length) << 2) : 0) + (reciprocal ? 2 : 0) + (flip_sign ? 1 : 0) );
42  }
43 
44 
46  inline std::string sparse_dense_matmult_kernel_name(bool B_transposed, bool B_row_major, bool C_row_major)
47  {
48  if (B_transposed)
49  {
50  if (B_row_major && C_row_major)
51  return "trans_mat_mult_row_row";
52  if (B_row_major && !C_row_major)
53  return "trans_mat_mult_row_col";
54  if (!B_row_major && C_row_major)
55  return "trans_mat_mult_col_row";
56 
57  return "trans_mat_mult_col_col";
58  }
59 
60  if (B_row_major && C_row_major)
61  return "mat_mult_row_row";
62  if (B_row_major && !C_row_major)
63  return "mat_mult_row_col";
64  if (!B_row_major && C_row_major)
65  return "mat_mult_col_row";
66 
67  return "mat_mult_col_col";
68  }
69 
70 
71  inline std::string op_to_string(op_abs) { return "abs"; }
72  inline std::string op_to_string(op_acos) { return "acos"; }
73  inline std::string op_to_string(op_asin) { return "asin"; }
74  inline std::string op_to_string(op_atan) { return "atan"; }
75  inline std::string op_to_string(op_ceil) { return "ceil"; }
76  inline std::string op_to_string(op_cos) { return "cos"; }
77  inline std::string op_to_string(op_cosh) { return "cosh"; }
78  inline std::string op_to_string(op_exp) { return "exp"; }
79  inline std::string op_to_string(op_fabs) { return "fabs"; }
80  inline std::string op_to_string(op_floor) { return "floor"; }
81  inline std::string op_to_string(op_log) { return "log"; }
82  inline std::string op_to_string(op_log10) { return "log10"; }
83  inline std::string op_to_string(op_sin) { return "sin"; }
84  inline std::string op_to_string(op_sinh) { return "sinh"; }
85  inline std::string op_to_string(op_sqrt) { return "sqrt"; }
86  inline std::string op_to_string(op_tan) { return "tan"; }
87  inline std::string op_to_string(op_tanh) { return "tanh"; }
88  }
89 
90  } //namespace opencl
91  } //namespace linalg
92 } //namespace viennacl
93 
94 
95 #endif
A tag class representing the cosh() function.
Definition: forwards.h:107
std::size_t vcl_size_t
Definition: forwards.h:58
A tag class representing the tan() function.
Definition: forwards.h:133
Implements a OpenCL platform within ViennaCL.
std::string sparse_dense_matmult_kernel_name(bool B_transposed, bool B_row_major, bool C_row_major)
Returns the OpenCL kernel string for the operation C = A * B with A sparse, B, C dense matrices...
Definition: common.hpp:46
A tag class representing the modulus function for integers.
Definition: forwards.h:93
A tag class representing the ceil() function.
Definition: forwards.h:103
This file provides the forward declarations for the main types used within ViennaCL.
A tag class representing the log() function.
Definition: forwards.h:123
A tag class representing the tanh() function.
Definition: forwards.h:135
A tag class representing the fabs() function.
Definition: forwards.h:111
A tag class representing the atan() function.
Definition: forwards.h:99
A tag class representing the sinh() function.
Definition: forwards.h:129
A tag class representing the exp() function.
Definition: forwards.h:109
NumericT flip_sign(NumericT val)
Definition: vector_operations.hpp:54
cl_uint make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
Definition: common.hpp:39
A tag class representing the sqrt() function.
Definition: forwards.h:131
A tag class representing the sin() function.
Definition: forwards.h:127
A tag class representing the floor() function.
Definition: forwards.h:115
A tag class representing the asin() function.
Definition: forwards.h:97
A tag class representing the acos() function.
Definition: forwards.h:95
std::string op_to_string(op_abs)
Definition: common.hpp:71
A tag class representing the log10() function.
Definition: forwards.h:125
A tag class representing the cos() function.
Definition: forwards.h:105