ViennaCL - The Vienna Computing Library  1.7.0
Free open-source GPU-accelerated linear algebra and solver library.
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-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 #include <cmath>
26 
27 #include "viennacl/forwards.h"
30 
31 namespace viennacl
32 {
33 namespace linalg
34 {
35 namespace opencl
36 {
37 namespace detail
38 {
39 
40 
41 
42 inline cl_uint make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
43 {
44  return static_cast<cl_uint>( ((length > 1) ? (cl_uint(length) << 2) : 0) + (reciprocal ? 2 : 0) + (flip_sign ? 1 : 0) );
45 }
46 
47 
49 inline std::string sparse_dense_matmult_kernel_name(bool B_transposed, bool B_row_major, bool C_row_major)
50 {
51  if (B_transposed)
52  {
53  if (B_row_major && C_row_major)
54  return "trans_mat_mult_row_row";
55  if (B_row_major && !C_row_major)
56  return "trans_mat_mult_row_col";
57  if (!B_row_major && C_row_major)
58  return "trans_mat_mult_col_row";
59 
60  return "trans_mat_mult_col_col";
61  }
62 
63  if (B_row_major && C_row_major)
64  return "mat_mult_row_row";
65  if (B_row_major && !C_row_major)
66  return "mat_mult_row_col";
67  if (!B_row_major && C_row_major)
68  return "mat_mult_col_row";
69 
70  return "mat_mult_col_col";
71 }
72 
73 
74 
75 template<typename SomeT>
76 ocl::device const & current_device(SomeT const & obj) { return traits::opencl_handle(obj).context().current_device(); }
77 
78 inline std::string op_to_string(op_abs) { return "abs"; }
79 inline std::string op_to_string(op_acos) { return "acos"; }
80 inline std::string op_to_string(op_asin) { return "asin"; }
81 inline std::string op_to_string(op_atan) { return "atan"; }
82 inline std::string op_to_string(op_ceil) { return "ceil"; }
83 inline std::string op_to_string(op_cos) { return "cos"; }
84 inline std::string op_to_string(op_cosh) { return "cosh"; }
85 inline std::string op_to_string(op_exp) { return "exp"; }
86 inline std::string op_to_string(op_fabs) { return "fabs"; }
87 inline std::string op_to_string(op_floor) { return "floor"; }
88 inline std::string op_to_string(op_log) { return "log"; }
89 inline std::string op_to_string(op_log10) { return "log10"; }
90 inline std::string op_to_string(op_sin) { return "sin"; }
91 inline std::string op_to_string(op_sinh) { return "sinh"; }
92 inline std::string op_to_string(op_sqrt) { return "sqrt"; }
93 inline std::string op_to_string(op_tan) { return "tan"; }
94 inline std::string op_to_string(op_tanh) { return "tanh"; }
95 
96 } //namespace detail
97 } //namespace opencl
98 } //namespace linalg
99 } //namespace viennacl
100 
101 
102 #endif
A tag class representing the cosh() function.
Definition: forwards.h:155
A tag class representing the tan() function.
Definition: forwards.h:181
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:49
A tag class representing the modulus function for integers.
Definition: forwards.h:137
A tag class representing the ceil() function.
Definition: forwards.h:151
A class representing a compute device (e.g. a GPU)
Definition: device.hpp:49
This file provides the forward declarations for the main types used within ViennaCL.
A tag class representing the log() function.
Definition: forwards.h:171
A tag class representing the tanh() function.
Definition: forwards.h:183
A tag class representing the fabs() function.
Definition: forwards.h:159
A tag class representing the atan() function.
Definition: forwards.h:147
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:34
A tag class representing the sinh() function.
Definition: forwards.h:177
Definition: blas3.hpp:36
A tag class representing the exp() function.
Definition: forwards.h:157
cl_uint make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
Definition: common.hpp:42
ocl::device const & current_device(SomeT const &obj)
Definition: common.hpp:76
A tag class representing the sqrt() function.
Definition: forwards.h:179
std::size_t vcl_size_t
Definition: forwards.h:75
A tag class representing the sin() function.
Definition: forwards.h:175
A tag class representing the floor() function.
Definition: forwards.h:163
A tag class representing the asin() function.
Definition: forwards.h:141
Extracts the underlying OpenCL handle from a vector, a matrix, an expression etc. ...
A tag class representing the acos() function.
Definition: forwards.h:139
std::string op_to_string(op_abs)
Definition: common.hpp:78
A tag class representing the log10() function.
Definition: forwards.h:173
A tag class representing the cos() function.
Definition: forwards.h:153